support/tests: allow properly indented config fragment
authorYann E. MORIN <yann.morin.1998@free.fr>
Tue, 18 Jul 2017 20:38:39 +0000 (22:38 +0200)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Tue, 18 Jul 2017 21:46:09 +0000 (23:46 +0200)
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@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Arnout Vandecappelle <arnout@mind.be>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
support/testing/infra/basetest.py

index 1a082bb4417bdfbe3b5b5b3fdd03c492e99fe4f4..07c180e232919118b4df0ce4da5e0d3751fdf7f2 100644 (file)
@@ -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"),