Support west test when invoked as module
This commit is contained in:
parent
b42d06ecf7
commit
dc1946810b
1 changed files with 5 additions and 4 deletions
|
@ -2,11 +2,11 @@
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
"""Test runner for ZMK."""
|
"""Test runner for ZMK."""
|
||||||
|
|
||||||
import os
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from west.commands import WestCommand
|
|
||||||
from west import log # use this for user output
|
from west import log # use this for user output
|
||||||
|
from west.commands import WestCommand
|
||||||
|
|
||||||
|
|
||||||
class Test(WestCommand):
|
class Test(WestCommand):
|
||||||
|
@ -17,6 +17,8 @@ class Test(WestCommand):
|
||||||
description="Run the ZMK testsuite.",
|
description="Run the ZMK testsuite.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.appdir = Path(__file__).resolve().parents[2]
|
||||||
|
|
||||||
def do_add_parser(self, parser_adder):
|
def do_add_parser(self, parser_adder):
|
||||||
parser = parser_adder.add_parser(
|
parser = parser_adder.add_parser(
|
||||||
self.name,
|
self.name,
|
||||||
|
@ -34,8 +36,7 @@ class Test(WestCommand):
|
||||||
|
|
||||||
def do_run(self, args, unknown_args):
|
def do_run(self, args, unknown_args):
|
||||||
# the run-test script assumes the app directory is the current dir.
|
# the run-test script assumes the app directory is the current dir.
|
||||||
os.chdir(f"{self.topdir}/app")
|
|
||||||
completed_process = subprocess.run(
|
completed_process = subprocess.run(
|
||||||
[f"{self.topdir}/app/run-test.sh", args.test_path]
|
["./run-test.sh", args.test_path], cwd=self.appdir
|
||||||
)
|
)
|
||||||
exit(completed_process.returncode)
|
exit(completed_process.returncode)
|
||||||
|
|
Loading…
Add table
Reference in a new issue