From c067629c83651c98154bef44a23ec7e5d81be179 Mon Sep 17 00:00:00 2001 From: Okke Formsma Date: Sat, 14 Nov 2020 19:39:01 +0100 Subject: Create `west test` command to run zmk testsuite. --- app/scripts/west-commands.yml | 9 +++++++++ app/scripts/west_commands/test.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 app/scripts/west-commands.yml create mode 100644 app/scripts/west_commands/test.py (limited to 'app/scripts') diff --git a/app/scripts/west-commands.yml b/app/scripts/west-commands.yml new file mode 100644 index 0000000..98e2899 --- /dev/null +++ b/app/scripts/west-commands.yml @@ -0,0 +1,9 @@ +# Copyright (c) 2020, ZMK Contributors +# SPDX-License-Identifier: MIT + +west-commands: + - file: scripts/west_commands/test.py + commands: + - name: test + class: Test + help: run zmk testsuite \ No newline at end of file diff --git a/app/scripts/west_commands/test.py b/app/scripts/west_commands/test.py new file mode 100644 index 0000000..26f95f7 --- /dev/null +++ b/app/scripts/west_commands/test.py @@ -0,0 +1,33 @@ +# Copyright (c) 2020 The ZMK Contributors +# +# SPDX-License-Identifier: MIT +'''Test runner for ZMK.''' + +import os +from textwrap import dedent # just for nicer code indentation + +from west.commands import WestCommand +from west import log # use this for user output + + +class Test(WestCommand): + def __init__(self): + super().__init__( + 'test', # gets stored as self.name + 'run zmk testsuite', # self.help + # self.description: + dedent('''Run the zmk testsuite.''')) + + def do_add_parser(self, parser_adder): + parser = parser_adder.add_parser(self.name, + help=self.help, + description=self.description) + + parser.add_argument('test_path', default="all", + help='The path to the test. Defaults to "all".', nargs="?") + return parser # gets stored as self.parser + + def do_run(self, args, unknown_args): + # the run-test script assumes the app directory is the current dir. + os.chdir(f'{self.topdir}/app') + exit(os.system(f'{self.topdir}/app/run-test.sh {args.test_path}')) -- cgit v1.2.3