]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
oe-selftest: timestamp the test runs
authorRoss Burton <ross.burton@intel.com>
Mon, 22 Jun 2015 16:20:42 +0000 (17:20 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 26 Jun 2015 13:08:03 +0000 (14:08 +0100)
The selftest can take a couple of hours to run, so add a custom result class to
timestamp the output to make it easy to spot any slow tests.

Signed-off-by: Ross Burton <ross.burton@intel.com>
scripts/oe-selftest

index a04e9fc96cc07eee6f13f6f57800b6a8328e251c..fd58a66123ed8effe8bb53bcc5d86e0c8ebd3921 100755 (executable)
@@ -176,7 +176,7 @@ def main():
         suite = unittest.TestSuite()
         loader = unittest.TestLoader()
         loader.sortTestMethodsUsing = None
-        runner = unittest.TextTestRunner(verbosity=2)
+        runner = unittest.TextTestRunner(verbosity=2, resultclass=StampedResult)
         # we need to do this here, otherwise just loading the tests
         # will take 2 minutes (bitbake -e calls)
         oeSelfTest.testlayer_path = get_test_layer()
@@ -196,6 +196,17 @@ def main():
         else:
             return 1
 
+class StampedResult(unittest.TextTestResult):
+    """
+    Custom TestResult that prints the time when a test starts.  As oe-selftest
+    can take a long time (ie a few hours) to run, timestamps help us understand
+    what tests are taking a long time to execute.
+    """
+    def startTest(self, test):
+        import time
+        self.stream.write(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + " - ")
+        super(StampedResult, self).startTest(test)
+
 if __name__ == "__main__":
     try:
         ret = main()