[3/4] crucible: ensure tempfile is removed even if there's an error.

Submitted by Dylan Baker on May 2, 2018, 8:57 p.m.

Details

Message ID 20180502205755.4207-3-dylan@pnwbakers.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Piglit

Not browsing as part of any series.

Commit Message

Dylan Baker May 2, 2018, 8:57 p.m.
---
 tests/crucible.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/tests/crucible.py b/tests/crucible.py
index 71ccf9d70..476869a31 100644
--- a/tests/crucible.py
+++ b/tests/crucible.py
@@ -57,11 +57,13 @@  class CrucibleTest(Test):
         super(CrucibleTest, self).__init__(command)
 
     def interpret_result(self):
-        test = backends.junit.REGISTRY.load(self.__out_xml, 'none')
-        result = test.get_result(next(six.iterkeys(test.tests)))
-        self.result.result = result.name
-        super(CrucibleTest, self).interpret_result()
-        os.remove(self.__out_xml)
+        try:
+            test = backends.junit.REGISTRY.load(self.__out_xml, 'none')
+            result = test.get_result(next(six.iterkeys(test.tests)))
+            self.result.result = result.name
+            super(CrucibleTest, self).interpret_result()
+        finally:
+            os.remove(self.__out_xml)
 
 def gen_caselist_txt(bin_):
     with open('crucible.txt', 'w') as d: