From 25890c814a515e7ef13f278c3bafef899f9d2d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Fri, 2 Aug 2019 13:24:52 +0200 Subject: [PATCH] compile_and_test_for_board: add --with-test-only Add an option to only compile applications that have available test. The target usage is when running hardware tests to save time by only compiling what will be tested. --- .../compile_and_test_for_board.py | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/dist/tools/compile_and_test_for_board/compile_and_test_for_board.py b/dist/tools/compile_and_test_for_board/compile_and_test_for_board.py index a18c0d0ced..b291e1dbf0 100755 --- a/dist/tools/compile_and_test_for_board/compile_and_test_for_board.py +++ b/dist/tools/compile_and_test_for_board/compile_and_test_for_board.py @@ -34,7 +34,7 @@ Usage ``` usage: compile_and_test_for_board.py [-h] [--applications APPLICATIONS] [--applications-exclude APPLICATIONS_EXCLUDE] - [--no-test] + [--no-test] [--with-test-only] [--loglevel {debug,info,warning,error,fatal,critical}] [--incremental] [--clean-after] [--compile-targets COMPILE_TARGETS] @@ -59,6 +59,8 @@ optional arguments: applications. Also applied after "--applications". (default: None) --no-test Disable executing tests (default: False) + --with-test-only Only compile applications that have a test (default: + False) --loglevel {debug,info,warning,error,fatal,critical} Python logger log level (default: info) --incremental Do not rerun successful compilation and tests @@ -275,7 +277,9 @@ class RIOTApplication(): return (str(err), err.application.appdir, err.errorfile) def compilation_and_test(self, clean_after=False, runtest=True, - incremental=False, jobs=False): + incremental=False, jobs=False, + with_test_only=False): + # pylint:disable=too-many-arguments """Compile and execute test if available. Checks for board supported/enough memory, compiles. @@ -303,6 +307,13 @@ class RIOTApplication(): self._write_resultfile('skip', 'not_enough_memory') return + has_test = self.has_test() + + if with_test_only and not has_test: + create_directory(self.resultdir, clean=True) + self._write_resultfile('skip', 'disabled_has_no_tests') + return + # Normal case for supported apps create_directory(self.resultdir, clean=not incremental) @@ -319,7 +330,7 @@ class RIOTApplication(): self.clean_intermediates() if runtest: - if self.has_test(): + if has_test: setuptasks = collections.OrderedDict( [('flash', ['flash-only'])]) self.make_with_outfile('test', self.TEST_TARGETS, @@ -558,6 +569,8 @@ PARSER.add_argument( ) PARSER.add_argument('--no-test', action='store_true', default=False, help='Disable executing tests') +PARSER.add_argument('--with-test-only', action='store_true', default=False, + help='Only compile applications that have a test') PARSER.add_argument('--loglevel', choices=LOG_LEVELS, default='info', help='Python logger log level') PARSER.add_argument('--incremental', action='store_true', default=False, @@ -619,7 +632,8 @@ def main(): errors = [app.run_compilation_and_test(clean_after=args.clean_after, runtest=not args.no_test, incremental=args.incremental, - jobs=args.jobs) + jobs=args.jobs, + with_test_only=args.with_test_only) for app in applications] errors = [e for e in errors if e is not None] num_errors = len(errors)