Mentions légales du service

Skip to content
Snippets Groups Projects
Commit f953208c authored by Mathieu Giraud's avatar Mathieu Giraud
Browse files

src/should.py: --only-f

Closes #28.
parent ec390cd4
No related branches found
No related tags found
No related merge requests found
Pipeline #408387 failed
......@@ -227,6 +227,10 @@ for p in (parser, options):
parser.add_argument('--shuffle', action='store_true', help='shuffle the tests')
group = parser.add_argument_group('filter options')
group.add_argument('--only-f', action='store_true', help="launches only 'f' tests")
output = parser.add_argument_group('output options')
output.add_argument('--log', action='append_const', dest='output', const=OUT_LOG, help='stores the output into .log files')
......@@ -426,6 +430,7 @@ class ExternalTestCase(TestCaseAbstract):
self.name = name
self.status = status
self.info = info
self.modifiers = ''
def str_additional_status(self, verbose = False):
s = ''
......@@ -748,7 +753,7 @@ class TestSuite():
self.stats.up(test.status)
self.status = SKIP
def test(self, variables=[], verbose=0, colorize=True):
def test(self, variables=[], verbose=0, colorize=True, only=None):
self.variables_all = self.variables + variables
if verbose > 1:
......@@ -814,6 +819,13 @@ class TestSuite():
self.test_lines = open(self.source).readlines() if self.source else self.stdout
for test in self.tests:
# Filter
if only:
if not only(test):
test.status = SKIP
continue
# Test the test
test.test(self.test_lines, variables=self.variables_all, verbose=verbose-1)
self.stats.up(test.status)
......@@ -907,7 +919,7 @@ class FileSet():
def __len__(self):
return len(self.files)
def test(self, variables=None, cd=None, cd_same=False, output=None, verbose=0):
def test(self, variables=None, cd=None, cd_same=False, output=None, verbose=0, only=None):
self.status = True
try:
......@@ -919,7 +931,7 @@ class FileSet():
self.sets.append(s)
s.load(open(f))
s.test(variables, verbose - 1)
s.test(variables, verbose - 1, only=only)
self.stats.up(s.status, f)
if not s.status:
self.status = False
......@@ -1033,8 +1045,14 @@ if __name__ == '__main__':
print("Shuffling test files")
random.shuffle(args.file)
# Filters
only = None
if args.only_f:
only = lambda test: MOD_TODO in test.modifiers
# Launch tests
fs = FileSet(args.file, timeout = args.timeout, modifiers=''.join(args.mod if args.mod else []))
status = fs.test(variables = variables, cd = args.cd, cd_same = args.cd_same, output = args.output, verbose = args.verbose)
status = fs.test(variables = variables, cd = args.cd, cd_same = args.cd_same, output = args.output, verbose = args.verbose, only = only)
if len(fs) > 1:
retry = fs.write_retry(sys.argv[1:], args.file, verbose = args.verbose)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment