[11/12] oeqa/sdkext/devtool: use finally instead of repeating cleanup

Message ID 1488384162-18397-11-git-send-email-richard.purdie@linuxfoundation.org
State Accepted
Commit 9f0f6326083ee76b72b431fbfcbe12c1ab2793b2
Headers show
Series
  • [01/12] oeqa/sdkext/devtool: rename recipe name to match upstream
Related show

Commit Message

Richard Purdie March 1, 2017, 4:02 p.m.
From: Ross Burton <ross.burton@intel.com>


Use the finally: block to always to cleanup.

Now that the test harness in testsdk.bbclass has monkey-patched
CalledProcessException to display the output we don't need to do that in the
test case.

Signed-off-by: Ross Burton <ross.burton@intel.com>

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>

---
 meta/classes/testsdk.bbclass          |  4 +++-
 meta/lib/oeqa/sdkext/cases/devtool.py | 35 ++++++++++-------------------------
 2 files changed, 13 insertions(+), 26 deletions(-)

-- 
2.7.4

-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Patch

diff --git a/meta/classes/testsdk.bbclass b/meta/classes/testsdk.bbclass
index 802e57f..0e6949e 100644
--- a/meta/classes/testsdk.bbclass
+++ b/meta/classes/testsdk.bbclass
@@ -100,7 +100,7 @@  def testsdkext_main(d):
     import logging
 
     from bb.utils import export_proxies
-    from oeqa.utils import avoid_paths_in_environ, make_logger_bitbake_compatible
+    from oeqa.utils import avoid_paths_in_environ, make_logger_bitbake_compatible, subprocesstweak
     from oeqa.sdkext.context import OESDKExtTestContext, OESDKExtTestContextExecutor
 
     pn = d.getVar("PN")
@@ -109,6 +109,8 @@  def testsdkext_main(d):
     # extensible sdk use network
     export_proxies(d)
 
+    subprocesstweak.errors_have_output()
+
     # extensible sdk can be contaminated if native programs are
     # in PATH, i.e. use perl-native instead of eSDK one.
     paths_to_avoid = [d.getVar('STAGING_DIR'),
diff --git a/meta/lib/oeqa/sdkext/cases/devtool.py b/meta/lib/oeqa/sdkext/cases/devtool.py
index ffaa2f0..63431aa 100644
--- a/meta/lib/oeqa/sdkext/cases/devtool.py
+++ b/meta/lib/oeqa/sdkext/cases/devtool.py
@@ -29,38 +29,32 @@  class DevtoolTest(OESDKExtTestCase):
         self._run('devtool add myapp %s' % directory)
         try:
             self._run('devtool build myapp')
-        except Exception as e:
-            print(e.output)
+        finally:
             self._run('devtool reset myapp')
-            raise e
-        self._run('devtool reset myapp')
 
     def _test_devtool_build_package(self, directory):
         self._run('devtool add myapp %s' % directory)
         try:
             self._run('devtool package myapp')
-        except Exception as e:
-            print(e.output)
+        finally:
             self._run('devtool reset myapp')
-            raise e
-        self._run('devtool reset myapp')
 
     def test_devtool_location(self):
         output = self._run('which devtool')
         self.assertEqual(output.startswith(self.tc.sdk_dir), True, \
             msg="Seems that devtool isn't the eSDK one: %s" % output)
-    
+
     @OETestDepends(['test_devtool_location'])
     def test_devtool_add_reset(self):
         self._run('devtool add myapp %s' % self.myapp_dst)
         self._run('devtool reset myapp')
-    
+
     @OETestID(1605)
     @OETestDepends(['test_devtool_location'])
     @skipIfNotDataVar('SDK_INCLUDE_TOOLCHAIN', '1', 'SDK does not include toolchain')
     def test_devtool_build_make(self):
         self._test_devtool_build(self.myapp_dst)
-    
+
     @OETestID(1606)
     @OETestDepends(['test_devtool_location'])
     @skipIfNotDataVar('SDK_INCLUDE_TOOLCHAIN', '1', 'SDK does not include toolchain')
@@ -72,7 +66,7 @@  class DevtoolTest(OESDKExtTestCase):
     @skipIfNotDataVar('SDK_INCLUDE_TOOLCHAIN', '1', 'SDK does not include toolchain')
     def test_devtool_build_cmake(self):
         self._test_devtool_build(self.myapp_cmake_dst)
-    
+
     @OETestID(1608)
     @OETestDepends(['test_devtool_location'])
     @skipIfNotDataVar('SDK_INCLUDE_TOOLCHAIN', '1', 'SDK does not include toolchain')
@@ -82,11 +76,8 @@  class DevtoolTest(OESDKExtTestCase):
         self._run('devtool add %s %s' % (recipe, req) )
         try:
             self._run('devtool build %s' % recipe)
-        except Exception as e:
-            print(e.output)
+        finally:
             self._run('devtool reset %s' % recipe)
-            raise e
-        self._run('devtool reset %s' % recipe)
 
     @OETestID(1609)
     @OETestDepends(['test_devtool_location'])
@@ -97,11 +88,8 @@  class DevtoolTest(OESDKExtTestCase):
         self._run('devtool add %s %s' % (recipe, docfile) )
         try:
             self._run('devtool build %s' % recipe)
-        except Exception as e:
-            print(e.output)
+        finally:
             self._run('devtool reset %s' % recipe)
-            raise e
-        self._run('devtool reset %s' % recipe)
 
     @OETestID(1610)
     @OETestDepends(['test_devtool_location'])
@@ -111,8 +99,5 @@  class DevtoolTest(OESDKExtTestCase):
         self._run('devtool add %s ' % package_nodejs)
         try:
             self._run('devtool build %s ' % package_nodejs)
-        except Exception as e:
-            print(e.output)
-            self._run('devtool reset %s' % package_nodejs)
-            raise e
-        self._run('devtool reset %s '% package_nodejs)
+        finally:
+            self._run('devtool reset %s '% package_nodejs)