All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ola x Nilsson <ola.x.nilsson@axis.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 1/2] oeqa/selftest/case: Add recipeinc method
Date: Mon, 28 Aug 2017 16:58:15 +0200	[thread overview]
Message-ID: <20170828145816.17208-1-olani@axis.com> (raw)

The recipeinc method returns the absolute path of the test_recipe.inc
file of a specified recipe.  It replaces four instances of identical
code, and make it possible to access the filename from a testcase for
cleanup.

The write_recipeinc and append_recipeinc methods are changed to return
the path to the file in case that is useful.

The test_recipe.inc file is usually cleaned up in a finally block,
but that block executes before any teardown operations.  This blocks
any teardown that requires the presence of the test_recipe.inc file.

Signed-off-by: Ola x Nilsson <olani@axis.com>
---
 meta/lib/oeqa/selftest/case.py | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/meta/lib/oeqa/selftest/case.py b/meta/lib/oeqa/selftest/case.py
index 871009c568..e09915b495 100644
--- a/meta/lib/oeqa/selftest/case.py
+++ b/meta/lib/oeqa/selftest/case.py
@@ -212,27 +212,33 @@ to ensure accurate results.")
         self.logger.debug("Removing from: %s\n%s\n" % (self.testinc_path, data))
         ftools.remove_from_file(self.testinc_path, data)
 
+    def recipeinc(self, recipe):
+        """Return absolute path of meta-sefltest/recipes-test/<recipe>/test_recipe.inc"""
+        return os.path.join(self.testlayer_path, 'recipes-test', recipe, 'test_recipe.inc')
+
     def write_recipeinc(self, recipe, data):
         """Write to meta-sefltest/recipes-test/<recipe>/test_recipe.inc"""
-        inc_file = os.path.join(self.testlayer_path, 'recipes-test', recipe, 'test_recipe.inc')
+        inc_file = self.recipeinc(recipe)
         self.logger.debug("Writing to: %s\n%s\n" % (inc_file, data))
         ftools.write_file(inc_file, data)
+        return inc_file
 
     def append_recipeinc(self, recipe, data):
         """Append data to meta-sefltest/recipes-test/<recipe>/test_recipe.inc"""
-        inc_file = os.path.join(self.testlayer_path, 'recipes-test', recipe, 'test_recipe.inc')
+        inc_file = self.recipeinc(recipe)
         self.logger.debug("Appending to: %s\n%s\n" % (inc_file, data))
         ftools.append_file(inc_file, data)
+        return inc_file
 
     def remove_recipeinc(self, recipe, data):
         """Remove data from meta-sefltest/recipes-test/<recipe>/test_recipe.inc"""
-        inc_file = os.path.join(self.testlayer_path, 'recipes-test', recipe, 'test_recipe.inc')
+        inc_file = self.recipeinc(recipe)
         self.logger.debug("Removing from: %s\n%s\n" % (inc_file, data))
         ftools.remove_from_file(inc_file, data)
 
     def delete_recipeinc(self, recipe):
         """Delete meta-sefltest/recipes-test/<recipe>/test_recipe.inc file"""
-        inc_file = os.path.join(self.testlayer_path, 'recipes-test', recipe, 'test_recipe.inc')
+        inc_file = self.recipeinc(recipe)
         self.logger.debug("Deleting file: %s" % inc_file)
         try:
             os.remove(inc_file)
@@ -259,13 +265,13 @@ to ensure accurate results.")
         self.logger.debug("Writing to: %s\n%s\n" % (self.machineinc_path, data))
         ftools.write_file(self.machineinc_path, data)
 
-    # check does path exist    
+    # check does path exist
     def assertExists(self, expr, msg=None):
         if not os.path.exists(expr):
             msg = self._formatMessage(msg, "%s does not exist" % safe_repr(expr))
             raise self.failureException(msg)
-    
-    # check does path not exist 
+
+    # check does path not exist
     def assertNotExists(self, expr, msg=None):
         if os.path.exists(expr):
             msg = self._formatMessage(msg, "%s exists when it should not" % safe_repr(expr))
-- 
2.11.0



             reply	other threads:[~2017-08-28 15:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-28 14:58 Ola x Nilsson [this message]
2017-08-28 14:58 ` [PATCH 2/2] externalsrc.bbclass: Avoid symlink clashes for virtclasses Ola x Nilsson
2017-09-12 11:23   ` Ola x Nilsson
2017-09-13 10:41     ` Richard Purdie
2017-09-13 11:26       ` Ola x Nilsson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170828145816.17208-1-olani@axis.com \
    --to=ola.x.nilsson@axis.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.