Patchwork [036,of,179,tests-refactor] run-tests: move keyword processing into Test.run()

login
register
mail settings
Submitter Gregory Szorc
Date May 2, 2014, 6:37 p.m.
Message ID <da0668d3b1d16d88b678.1399055873@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/4532/
State Accepted
Commit bfe929a4b45b879c163eb70cfb03edb23086e7fc
Headers show

Comments

Gregory Szorc - May 2, 2014, 6:37 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1397966750 25200
#      Sat Apr 19 21:05:50 2014 -0700
# Branch stable
# Node ID da0668d3b1d16d88b6788f113012d911692504fa
# Parent  8f54e7d2536ab22b6117f5e77e2c6981b9b14c6b
run-tests: move keyword processing into Test.run()

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -588,16 +588,26 @@  class Test(object):
         if not (options.whitelisted and self._test in options.whitelisted):
             if options.blacklist and self._test in options.blacklist:
                 result.skipped = True
                 return self.skip('blacklisted')
 
             if options.retest and not os.path.exists('%s.err' % self._test):
                 return self.ignore('not retesting')
 
+            if options.keywords:
+                f = open(self._test)
+                t = f.read().lower() + self._test.lower()
+                f.close()
+                for k in options.keywords.lower().split():
+                    if k in t:
+                        break
+                    else:
+                        return self.ignore("doesn't match keyword")
+
         # Remove any previous output files.
         if os.path.exists(self._errpath):
             os.remove(self._errpath)
 
         testtmp = os.path.join(self._threadtmp, os.path.basename(self._path))
         os.mkdir(testtmp)
         replacements, port = self._getreplacements(testtmp)
         env = self._getenv(testtmp, port)
@@ -1118,27 +1128,16 @@  def runone(options, test, count):
         if options.verbose:
             log("\nSkipping %s: %s" % (testpath, msg))
         return 's', test, msg
 
     testpath = os.path.join(TESTDIR, test)
     err = os.path.join(TESTDIR, test + ".err")
     lctest = test.lower()
 
-    if not (options.whitelisted and test in options.whitelisted):
-        if options.keywords:
-            fp = open(test)
-            t = fp.read().lower() + test.lower()
-            fp.close()
-            for k in options.keywords.lower().split():
-                if k in t:
-                    break
-                else:
-                    return ignore("doesn't match keyword")
-
     if not os.path.basename(lctest).startswith("test-"):
         return skip("not a test file")
     for ext, cls, out in testtypes:
         if lctest.endswith(ext):
             runner = cls
             ref = os.path.join(TESTDIR, test + out)
             break
     else: