.pytool/Plugin/EccCheck: Remove temp directory on exception
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2986 Add try/except to RunBuildPlugin() to remove temporary directory if a KeyboardInterrupt exception or an unexpected exception is detected. Cc: Sean Brogan <sean.brogan@microsoft.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Michael Kubacki <michael.kubacki@microsoft.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Acked-by: Sean Brogan <sean.brogan@microsoft.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
parent
69877614fd
commit
854462bd34
|
@ -72,6 +72,7 @@ class EccCheck(ICiBuildPlugin):
|
||||||
|
|
||||||
# Create temp directory
|
# Create temp directory
|
||||||
temp_path = os.path.join(workspace_path, 'Build', '.pytool', 'Plugin', 'EccCheck')
|
temp_path = os.path.join(workspace_path, 'Build', '.pytool', 'Plugin', 'EccCheck')
|
||||||
|
try:
|
||||||
# Delete temp directory
|
# Delete temp directory
|
||||||
if os.path.exists(temp_path):
|
if os.path.exists(temp_path):
|
||||||
shutil.rmtree(temp_path)
|
shutil.rmtree(temp_path)
|
||||||
|
@ -112,6 +113,21 @@ class EccCheck(ICiBuildPlugin):
|
||||||
shutil.rmtree(temp_path)
|
shutil.rmtree(temp_path)
|
||||||
tc.SetFailed("EccCheck failed for {0}".format(packagename), "CHECK FAILED")
|
tc.SetFailed("EccCheck failed for {0}".format(packagename), "CHECK FAILED")
|
||||||
return 1
|
return 1
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
# If EccCheck is interrupted by keybard interrupt, then return failure
|
||||||
|
# Delete temp directory
|
||||||
|
if os.path.exists(temp_path):
|
||||||
|
shutil.rmtree(temp_path)
|
||||||
|
tc.SetFailed("EccCheck interrupted for {0}".format(packagename), "CHECK FAILED")
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
# If EccCheck fails for any other exception type, raise the exception
|
||||||
|
# Delete temp directory
|
||||||
|
if os.path.exists(temp_path):
|
||||||
|
shutil.rmtree(temp_path)
|
||||||
|
tc.SetFailed("EccCheck exception for {0}".format(packagename), "CHECK FAILED")
|
||||||
|
raise
|
||||||
|
return 1
|
||||||
|
|
||||||
def GetDiff(self, pkg: str) -> List[str]:
|
def GetDiff(self, pkg: str) -> List[str]:
|
||||||
return_buffer = StringIO()
|
return_buffer = StringIO()
|
||||||
|
|
Loading…
Reference in New Issue