summaryrefslogtreecommitdiff
path: root/regtest
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2014-10-26 11:08:45 +0100
committerCarlos Garcia Campos <carlosgc@gnome.org>2014-10-26 11:33:38 +0100
commit7c21b95852e891060cd2e276949acf0945306ab7 (patch)
tree98ab4ac5a2bef3244c7d328935c44d5cb1e7de59 /regtest
parent53be607edc18a861aeb0b6663bac3c05de46c84c (diff)
regtest: Allow to run groups of tests individually
Now it's possible to pass more than one argument to run-tests command and optionally the docs directory. When more than one test is passed and the docs directory is not provided, the common base path of all passed tests is used as docs directory. The tests passed can be documents or directories, using absolute paths or paths relative to the docs directory. This also allows us to update the refs for a group of tests.
Diffstat (limited to 'regtest')
-rw-r--r--regtest/TestRun.py26
-rw-r--r--regtest/Utils.py7
-rw-r--r--regtest/commands/run-tests.py29
3 files changed, 49 insertions, 13 deletions
diff --git a/regtest/TestRun.py b/regtest/TestRun.py
index 6aba62fb..7a2f5dfd 100644
--- a/regtest/TestRun.py
+++ b/regtest/TestRun.py
@@ -172,8 +172,30 @@ class TestRun:
self.run_test(doc)
self._queue.task_done()
- def run_tests(self):
- docs, total_docs = get_document_paths_from_dir(self._docsdir)
+ def run_tests(self, tests = []):
+ if not tests:
+ docs, total_docs = get_document_paths_from_dir(self._docsdir)
+ else:
+ docs = []
+ total_docs = 0
+ for test in tests:
+ if os.path.isdir(test):
+ test_dir = test
+ elif os.path.isdir(os.path.join(self._docsdir, test)):
+ test_dir = os.path.join(self._docsdir, test)
+ else:
+ test_dir = None
+
+ if test_dir is not None:
+ dir_docs, dir_n_docs = get_document_paths_from_dir(test_dir, self._docsdir)
+ docs.extend(dir_docs)
+ total_docs += dir_n_docs
+ else:
+ if test.startswith(self._docsdir):
+ test = test[len(self._docsdir):].lstrip(os.path.sep)
+ docs.append(test)
+ total_docs += 1
+
backends = self._get_backends()
self._total_tests = total_docs * len(backends)
diff --git a/regtest/Utils.py b/regtest/Utils.py
index 90a6eead..f491a6dd 100644
--- a/regtest/Utils.py
+++ b/regtest/Utils.py
@@ -18,7 +18,10 @@
import os
-def get_document_paths_from_dir(docsdir):
+def get_document_paths_from_dir(docsdir, basedir = None):
+ if basedir is None:
+ basedir = docsdir
+
paths = []
n_paths = 0
for root, dirs, files in os.walk(docsdir, False):
@@ -26,7 +29,7 @@ def get_document_paths_from_dir(docsdir):
if not entry.lower().endswith('.pdf'):
continue
- test_path = os.path.join(root[len(docsdir):], entry)
+ test_path = os.path.join(root[len(basedir):], entry)
paths.append(test_path.lstrip(os.path.sep))
n_paths += 1
paths.sort()
diff --git a/regtest/commands/run-tests.py b/regtest/commands/run-tests.py
index 29e7dfae..5f1914fe 100644
--- a/regtest/commands/run-tests.py
+++ b/regtest/commands/run-tests.py
@@ -39,6 +39,9 @@ class RunTests(Command):
parser.add_argument('-o', '--out-dir',
action = 'store', dest = 'out_dir', default = os.path.join(tempfile.gettempdir(), 'out'),
help = 'Directory where test results will be created')
+ parser.add_argument('--docs-dir',
+ action = 'store', dest = 'docs_dir',
+ help = 'Base documents directory')
parser.add_argument('--keep-results',
action = 'store_true', dest = 'keep_results', default = False,
help = 'Do not remove result files for passing tests')
@@ -48,7 +51,8 @@ class RunTests(Command):
parser.add_argument('--update-refs',
action = 'store_true', dest = 'update_refs', default = False,
help = 'Update references for failed tests')
- parser.add_argument('tests')
+ parser.add_argument('tests', metavar = 'TEST', nargs = '+',
+ help = 'Tests directory or individual test to run')
def run(self, options):
config = Config()
@@ -57,17 +61,24 @@ class RunTests(Command):
config.update_refs = options['update_refs']
t = Timer()
- doc = options['tests']
- if os.path.isdir(doc):
- docs_dir = doc
+ docs = options['tests']
+ docs_dir = options['docs_dir']
+
+ if len(docs) == 1:
+ if os.path.isdir(docs[0]):
+ if docs_dir is None:
+ docs_dir = docs[0]
+ if docs_dir == docs[0]:
+ docs = []
+ else:
+ if docs_dir is None:
+ docs_dir = os.path.dirname(docs[0])
else:
- docs_dir = os.path.dirname(doc)
+ if docs_dir is None:
+ docs_dir = os.path.commonprefix(docs).rpartition(os.path.sep)[0]
tests = TestRun(docs_dir, options['refs_dir'], options['out_dir'])
- if doc == docs_dir:
- status = tests.run_tests()
- else:
- status = tests.run_test(os.path.basename(doc))
+ status = tests.run_tests(docs)
tests.summary()
get_printer().printout_ln("Tests run in %s" % (t.elapsed_str()))