summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOkke Formsma <okke@formsma.nl>2020-11-14 19:39:01 +0100
committerPete Johanson <peter@peterjohanson.com>2020-11-21 14:47:01 -0500
commitc067629c83651c98154bef44a23ec7e5d81be179 (patch)
treed28b0bcea613a32242cc72dbadce80e7bb8e32f5
parent5d0532c6d939fa40cb18b395a18a1b020f8300d3 (diff)
Create `west test` command to run zmk testsuite.
-rw-r--r--.github/workflows/test.yml2
-rw-r--r--app/scripts/west-commands.yml9
-rw-r--r--app/scripts/west_commands/test.py33
-rw-r--r--app/west.yml2
-rw-r--r--docs/docs/development/tests.md4
5 files changed, 47 insertions, 3 deletions
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index a6af058..f3e9351 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -61,7 +61,7 @@ jobs:
id: west-build
with:
entrypoint: /bin/bash
- args: '-c "cd app && ./run-test.sh all"'
+ args: '-c "west test"'
- name: Archive Build
if: ${{ always() }}
uses: actions/upload-artifact@v2
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}'))
diff --git a/app/west.yml b/app/west.yml
index cba53ab..7657fde 100644
--- a/app/west.yml
+++ b/app/west.yml
@@ -37,4 +37,4 @@ manifest:
remote: microsoft
path: tools/uf2
self:
- path: zmk
+ west-commands: scripts/west-commands.yml \ No newline at end of file
diff --git a/docs/docs/development/tests.md b/docs/docs/development/tests.md
index 8df6cb1..9ad689b 100644
--- a/docs/docs/development/tests.md
+++ b/docs/docs/development/tests.md
@@ -4,7 +4,9 @@ sidebar_label: Tests
---
Running tests requires [native posix support](posix-board). Any folder under `/app/tests`
-containing `native_posix.keymap` will be selected when running `./run-test.sh all`.
+containing `native_posix.keymap` will be selected when running `west test`.
+
+Run a single test with `west test <testname>`, like `west test tests/toggle-layer/normal`.
## Creating a New Test Set