Commit da1b5437 authored by Carlos Garcia Campos's avatar Carlos Garcia Campos

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.
parent b730b2c1
......@@ -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):
......
......@@ -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:
......
......@@ -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
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment