#!/usr/bin/env python3 # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at https://mozilla.org/MPL/2.0/. import argparse import dataclasses import os import pathlib import subprocess SCRIPT = pathlib.Path(__file__) IOT_CONTACT_GO = SCRIPT.parent NATIVE_SIM_FIRMWARE_DEFAULT = ( IOT_CONTACT_GO.parent / "iot-contact" / "build" / "fw" / "sim" / "build" / "zephyr" / "zephyr.exe" ) def main() -> None: args = Arguments.from_cli() env = os.environ.copy() env["IOT_CONTACT_NATIVE_SIM_FIRMWARE"] = str(args.native_sim_firmware) subprocess.run( [ "go", "test", "-v", "--count=1", "./...", ], shell=False, check=True, cwd=str(IOT_CONTACT_GO), env=env, ) @dataclasses.dataclass(frozen=True, kw_only=True) class Arguments: native_sim_firmware: pathlib.Path def __post_init__(self) -> None: assert isinstance(self.native_sim_firmware, pathlib.Path) assert self.native_sim_firmware.is_file() @staticmethod def from_cli() -> "Arguments": parser = argparse.ArgumentParser() parser.add_argument( "-n", "--native-sim", type=pathlib.Path, default=pathlib.Path(NATIVE_SIM_FIRMWARE_DEFAULT), help="path to iot-contact native sim firmware", ) args = parser.parse_args() return Arguments( native_sim_firmware=args.native_sim.absolute(), ) if __name__ == "__main__": main()