diff options
author | Carlos Garcia Campos <carlosgc@gnome.org> | 2011-09-13 20:09:56 +0200 |
---|---|---|
committer | Carlos Garcia Campos <carlosgc@gnome.org> | 2011-09-13 20:09:56 +0200 |
commit | da1b5437148e1e6317246b16f7235c8bc280be97 (patch) | |
tree | 749736f7868a296a015a91fc8cc7d2f635d655d6 | |
parent | b730b2c1d9666f62f940762663c8318e64049d61 (diff) |
regtest: Add a way to skip files
A new command line option --skip has been added to give a file with the
list of test to skip. When --skip is not used, it look for a file named
Skipped in the tests dir. Lines starting with '#' are considered
comments and are ignored.
-rw-r--r-- | regtest/TestReferences.py | 9 | ||||
-rw-r--r-- | regtest/TestRun.py | 9 | ||||
-rw-r--r-- | regtest/Utils.py | 20 | ||||
-rw-r--r-- | regtest/main.py | 6 |
4 files changed, 39 insertions, 5 deletions
diff --git a/regtest/TestReferences.py b/regtest/TestReferences.py index 5d95e6fb..042b0d43 100644 --- a/regtest/TestReferences.py +++ b/regtest/TestReferences.py @@ -20,13 +20,14 @@ import os import errno from backends import get_backend, get_all_backends from Config import Config -from Utils import get_document_paths_from_dir +from Utils import get_document_paths_from_dir, get_skipped_tests class TestReferences: def __init__(self, docsdir, refsdir): self._docsdir = docsdir self._refsdir = refsdir + self._skipped = get_skipped_tests(docsdir) self.config = Config() try: @@ -38,6 +39,10 @@ class TestReferences: raise def create_refs_for_file(self, filename, n_doc = 1, total_docs = 1): + if filename in self._skipped: + print("Skipping test '%s' (%d/%d)" % (os.path.join(self._docsdir, filename), n_doc, total_docs)) + return + refs_path = os.path.join(self._refsdir, filename) try: os.makedirs(refs_path) @@ -55,7 +60,7 @@ class TestReferences: for backend in backends: if not self.config.force and backend.has_md5(refs_path): - print "Checksum file found, skipping '%s' for %s backend" % (doc_path, backend.get_name()) + print "Checksum file found, skipping '%s' for %s backend (%d/%d)" % (doc_path, backend.get_name(), n_doc, total_docs) continue print "Creating refs for '%s' using %s backend (%d/%d)" % (doc_path, backend.get_name(), n_doc, total_docs) if backend.create_refs(doc_path, refs_path): diff --git a/regtest/TestRun.py b/regtest/TestRun.py index 25e8fb7e..ba74b1a6 100644 --- a/regtest/TestRun.py +++ b/regtest/TestRun.py @@ -18,7 +18,7 @@ from backends import get_backend, get_all_backends from Config import Config -from Utils import get_document_paths_from_dir +from Utils import get_document_paths_from_dir, get_skipped_tests import sys import os import errno @@ -29,6 +29,7 @@ class TestRun: self._docsdir = docsdir self._refsdir = refsdir self._outdir = outdir + self._skipped = get_skipped_tests(docsdir) self.config = Config() # Results @@ -105,6 +106,10 @@ class TestRun: return def run_test(self, filename, n_doc = 1, total_docs = 1): + if filename in self._skipped: + print("Skipping test '%s' (%d/%d)" % (os.path.join(self._docsdir, filename), n_doc, total_docs)) + return + out_path = os.path.join(self._outdir, filename) try: os.makedirs(out_path) @@ -117,7 +122,7 @@ class TestRun: refs_path = os.path.join(self._refsdir, filename) if not os.path.isdir(refs_path): - print "Reference dir not found for %s, skipping" % (doc_path) + print "Reference dir not found for %s, skipping (%d/%d)" % (doc_path, n_doc, total_docs) return if self.config.backends: diff --git a/regtest/Utils.py b/regtest/Utils.py index 6656fac1..90a6eead 100644 --- a/regtest/Utils.py +++ b/regtest/Utils.py @@ -32,4 +32,24 @@ def get_document_paths_from_dir(docsdir): paths.sort() return paths, n_paths +def get_skipped_tests(docsdir): + from Config import Config + config = Config() + if config.skipped_file: + skipped_file = config.skipped_file + elif os.path.exists(os.path.join(docsdir, 'Skipped')): + skipped_file = os.path.join(docsdir, 'Skipped') + else: + return [] + + skipped = [] + f = open(skipped_file, 'r') + for line in f.readlines(): + line = line.rstrip('\n \t\b\r') + if not line or line[0] == '#': + continue + skipped.append(line) + f.close() + return skipped + diff --git a/regtest/main.py b/regtest/main.py index 1254caea..4c8a3905 100644 --- a/regtest/main.py +++ b/regtest/main.py @@ -49,11 +49,15 @@ def main(args): parser.add_argument('--help-command', metavar = 'COMMAND', action = HelpAction, help = 'Show help for a given command') - parser.add_argument('--utils-dir', action = 'store', dest = 'utils_dir', default = os.path.abspath("../utils"), + parser.add_argument('--utils-dir', + action = 'store', dest = 'utils_dir', default = os.path.abspath("../utils"), help = 'Directory of poppler utils used for the tests') parser.add_argument('-b', '--backends', action = ListAction, dest = 'backends', help = 'List of backends that will be used (separated by comma)') + parser.add_argument('--skip', metavar = 'FILE', + action = 'store', dest = 'skipped_file', + help = 'File containing tests to skip') ns, args = parser.parse_known_args(args) if not args: |