[Buildroot] [PATCHv3] support/tests: allow properly indented config fragment

Yann E. MORIN yann.morin.1998 at free.fr
Tue Jul 18 20:38:39 UTC 2017


Currently, defining a config fragment in the runtime test infra requires
that the fragment not to be indented. This is beark, and causes grievance
when looking at the code (e.g. to fix it).

Just strip out all leading spaces/tabs when writing the configuration
lines into the config file, allowing in-line indented config fragments,
like so:

    class TestFoo(bla):
        config = bla.config + \
            """
            FOO=y
            # BAR is not set
            """

Signed-off-by: "Yann E. MORIN" <yann.morin.1998 at free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
Cc: Arnout Vandecappelle <arnout at mind.be>

---
Changes v2 -> v3:
  - use and fix code snippet provided by Arnout, thanks! ;-)
  - do it in our base test class, not on the builder class  (Arnout)

Changes v1 -> v2:
  - add example in commit log  (Thomas)
---
 support/testing/infra/basetest.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/support/testing/infra/basetest.py b/support/testing/infra/basetest.py
index 1a082bb441..07c180e232 100644
--- a/support/testing/infra/basetest.py
+++ b/support/testing/infra/basetest.py
@@ -41,6 +41,7 @@ class BRTest(unittest.TestCase):
         self.testname = self.__class__.__name__
         self.builddir = self.outputdir and os.path.join(self.outputdir, self.testname)
         self.emulator = None
+        self.config = '\n'.join([line.lstrip() for line in self.config.splitlines()])
 
     def show_msg(self, msg):
         print "{} {:40s} {}".format(datetime.datetime.now().strftime("%H:%M:%S"),
-- 
2.11.0



More information about the buildroot mailing list