Makefile: run tests in parallel
This commit is contained in:
parent
babca8bdc4
commit
097fa42329
12
Makefile
12
Makefile
@ -79,6 +79,9 @@ FFLAGS += -J$(OBJDIR) -I$(INCDIR) -ffree-line-length-none -fPIC -frecursive
|
||||
LDFLAGS += -L$(LIBDIR)
|
||||
CPPFLAGS += -DREVISION=\"$(GIT_REV)$(GIT_DIRTY)\" -DPREFIX=\"$(PREFIX)\"
|
||||
|
||||
# Sync the output from jobs running in parallel
|
||||
MAKEFLAGS += --output-sync
|
||||
|
||||
ifndef DETERMINISTIC
|
||||
ifdef AR_DEFAULT_DETERMINISTIC
|
||||
# Write timestamps to allow partial updates
|
||||
@ -122,9 +125,12 @@ all: $(BINARIES) $(LIBRARIES)
|
||||
clean:
|
||||
rm -r $(BUILDDIR)
|
||||
|
||||
# Run tests
|
||||
check: $(GRAY)
|
||||
python -Bm tests --binary $^
|
||||
# Run all tests
|
||||
check: $(shell python -Bm tests --list-cases)
|
||||
|
||||
# Run a test case
|
||||
tests.%: $(GRAY)
|
||||
python -Bm tests '$@' --binary '$(GRAY)'
|
||||
|
||||
# Install libraries, binaries and documentation
|
||||
install: $(BINARIES) $(LIBRARIES) $(SHAREDIR)/doc $(MANPAGES)
|
||||
|
@ -3,9 +3,24 @@ import unittest
|
||||
import tests
|
||||
|
||||
|
||||
def get_cases(suite):
|
||||
'''
|
||||
Get a list of TestCase from a TestSuite
|
||||
'''
|
||||
if hasattr(suite, '__iter__'):
|
||||
res = set()
|
||||
for x in suite:
|
||||
res |= get_cases(x)
|
||||
return res
|
||||
|
||||
mod = type(suite).__module__
|
||||
cls = type(suite).__name__
|
||||
return {f'{mod}.{cls}'}
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# handle custom CLI arguments
|
||||
parser = argparse.ArgumentParser(add_help=False)
|
||||
parser = argparse.ArgumentParser(prog='tests.main')
|
||||
parser.add_argument('--keep-failed', action='store_true',
|
||||
help='whether to keep output files of failed tests')
|
||||
parser.add_argument('--visual', action='store_true',
|
||||
@ -15,8 +30,15 @@ if __name__ == '__main__':
|
||||
'current ones')
|
||||
parser.add_argument('--binary', type=str, default='build/bin/gray',
|
||||
help='the gray binary to be tested')
|
||||
parser.add_argument('--list-cases', action='store_true',
|
||||
help='only list the test cases')
|
||||
options, other_args = parser.parse_known_args()
|
||||
tests.options = options
|
||||
|
||||
if options.list_cases:
|
||||
# list all test cases
|
||||
suite = unittest.TestLoader().discover('.')
|
||||
print(*sorted(get_cases(suite)), sep='\n')
|
||||
else:
|
||||
# start the test runner
|
||||
unittest.main(module=None, argv=["tests.main"] + other_args)
|
||||
|
Loading…
Reference in New Issue
Block a user