Skip to content

Commit

Permalink
Support west test when invoked as module
Browse files Browse the repository at this point in the history
  • Loading branch information
urob committed Aug 14, 2024
1 parent de990f7 commit 5f4b513
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app/scripts/west_commands/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# SPDX-License-Identifier: MIT
"""Test runner for ZMK."""

import os
import subprocess
from pathlib import Path

from west.commands import WestCommand
from west import log # use this for user output
from west.commands import WestCommand


class Test(WestCommand):
Expand All @@ -17,6 +17,8 @@ def __init__(self):
description="Run the ZMK testsuite.",
)

self.appdir = Path(__file__).resolve().parents[2]

def do_add_parser(self, parser_adder):
parser = parser_adder.add_parser(
self.name,
Expand All @@ -34,8 +36,7 @@ def do_add_parser(self, parser_adder):

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")
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)

0 comments on commit 5f4b513

Please sign in to comment.