Merge pull request #11269 from cladmi/pr/makefiles/tests/refactoring/test/available

Makefile.include: add a 'test/available' target
This commit is contained in:
Kevin "Bear Puncher" Weiss 2019-03-28 12:08:02 +01:00 committed by GitHub
commit 831955c742
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 6 deletions

View File

@ -569,6 +569,7 @@ reset:
$(call check_cmd,$(RESET),Reset program) $(call check_cmd,$(RESET),Reset program)
$(RESET) $(RESET_FLAGS) $(RESET) $(RESET_FLAGS)
.PHONY: test test/available
TESTS ?= $(foreach file,$(wildcard $(APPDIR)/tests/*),\ TESTS ?= $(foreach file,$(wildcard $(APPDIR)/tests/*),\
$(shell test -f $(file) -a -x $(file) && echo $(file))) $(shell test -f $(file) -a -x $(file) && echo $(file)))
test: $(TEST_DEPS) test: $(TEST_DEPS)
@ -576,6 +577,10 @@ test: $(TEST_DEPS)
$$t || exit 1; \ $$t || exit 1; \
done done
test/available:
$(Q)test -n "$(strip $(TESTS))"
# Default OBJDUMPFLAGS for platforms which do not specify it: # Default OBJDUMPFLAGS for platforms which do not specify it:
OBJDUMPFLAGS ?= -S -D -h OBJDUMPFLAGS ?= -S -D -h

View File

@ -39,6 +39,7 @@ usage: compile_and_test_for_board.py [-h] [--applications APPLICATIONS]
[--incremental] [--clean-after] [--incremental] [--clean-after]
[--compile-targets COMPILE_TARGETS] [--compile-targets COMPILE_TARGETS]
[--test-targets TEST_TARGETS] [--test-targets TEST_TARGETS]
[--test-available-targets TEST_AVAILABLE_TARGETS]
[--jobs JOBS] [--jobs JOBS]
riot_directory board [result_directory] riot_directory board [result_directory]
@ -67,6 +68,9 @@ optional arguments:
List of make targets to compile (default: clean all) List of make targets to compile (default: clean all)
--test-targets TEST_TARGETS --test-targets TEST_TARGETS
List of make targets to run test (default: test) List of make targets to run test (default: test)
--test-available-targets TEST_AVAILABLE_TARGETS
List of make targets to know if a test is present
(default: test/available)
--jobs JOBS, -j JOBS Parallel building (0 means not limit, like '--jobs') --jobs JOBS, -j JOBS Parallel building (0 means not limit, like '--jobs')
(default: None) (default: None)
``` ```
@ -201,6 +205,7 @@ class RIOTApplication():
COMPILE_TARGETS = ('clean', 'all',) COMPILE_TARGETS = ('clean', 'all',)
TEST_TARGETS = ('test',) TEST_TARGETS = ('test',)
TEST_AVAILABLE_TARGETS = ('test/available',)
def __init__(self, board, riotdir, appdir, resultdir): def __init__(self, board, riotdir, appdir, resultdir):
self.board = board self.board = board
@ -220,13 +225,14 @@ class RIOTApplication():
def has_test(self): def has_test(self):
"""Detect if the application has tests. """Detect if the application has tests.
Use '--silent' to disable the message from packages: Check TEST_AVAILABLE_TARGETS execute without error.
make[1]: Nothing to be done for 'Makefile.include'
""" """
tests = self.make(['--silent', 'info-debug-variable-TESTS'], try:
log_error=True).strip() self.make(self.TEST_AVAILABLE_TARGETS)
return bool(tests) except subprocess.CalledProcessError:
return False
else:
return True
def board_is_supported(self): def board_is_supported(self):
"""Return if current board is supported.""" """Return if current board is supported."""
@ -573,6 +579,9 @@ PARSER.add_argument('--compile-targets', type=list_from_string,
PARSER.add_argument('--test-targets', type=list_from_string, PARSER.add_argument('--test-targets', type=list_from_string,
default=' '.join(RIOTApplication.TEST_TARGETS), default=' '.join(RIOTApplication.TEST_TARGETS),
help='List of make targets to run test') help='List of make targets to run test')
PARSER.add_argument('--test-available-targets', type=list_from_string,
default=' '.join(RIOTApplication.TEST_AVAILABLE_TARGETS),
help='List of make targets to know if a test is present')
PARSER.add_argument( PARSER.add_argument(
'--jobs', '-j', type=int, default=None, '--jobs', '-j', type=int, default=None,
@ -607,6 +616,7 @@ def main():
# Overwrite the compile/test targets from command line arguments # Overwrite the compile/test targets from command line arguments
RIOTApplication.COMPILE_TARGETS = args.compile_targets RIOTApplication.COMPILE_TARGETS = args.compile_targets
RIOTApplication.TEST_TARGETS = args.test_targets RIOTApplication.TEST_TARGETS = args.test_targets
RIOTApplication.TEST_AVAILABLE_TARGETS = args.test_available_targets
# List of applications for board # List of applications for board
applications = [RIOTApplication(board, args.riot_directory, app_dir, applications = [RIOTApplication(board, args.riot_directory, app_dir,

View File

@ -20,3 +20,10 @@ testing.
From the test application directory run: From the test application directory run:
BOARD=<board_of_your_choice> make flash test BOARD=<board_of_your_choice> make flash test
An automated way of knowing if a test is available is to execute the
'test/available' target from the test application directory.
It executes without error if tests run by 'make test' are present.
make test/available