2020-11-15 05:39:01 +11:00
|
|
|
# Copyright (c) 2020 The ZMK Contributors
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
'''Test runner for ZMK.'''
|
|
|
|
|
|
|
|
import os
|
2020-12-10 06:36:03 +11:00
|
|
|
import subprocess
|
2020-11-15 05:39:01 +11:00
|
|
|
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
|
2020-11-22 06:50:12 +11:00
|
|
|
'run ZMK testsuite', # self.help
|
2020-11-15 05:39:01 +11:00
|
|
|
# self.description:
|
2020-11-22 06:50:12 +11:00
|
|
|
dedent('''Run the ZMK testsuite.'''))
|
2020-11-15 05:39:01 +11:00
|
|
|
|
|
|
|
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')
|
2020-12-10 06:36:03 +11:00
|
|
|
completed_process = subprocess.run(
|
|
|
|
[f'{self.topdir}/app/run-test.sh', args.test_path])
|
|
|
|
exit(completed_process.returncode)
|