compile_and_test_for_board: use 'test/available' to detect test

Use the new 'test/available' target to detect if there are tests.
This prevents issues where calling make would print unrelated debug
messages that would be taken as an output.

The targets executed to check if there are tests can be set with
'--test-available-targets'.
This commit is contained in:
Gaëtan Harter 2019-03-23 18:05:18 +01:00
parent ec4d83727a
commit 87a1d08602
No known key found for this signature in database
GPG Key ID: 76DF6BCF1B1F883B

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,