From 29858360ebc2a5a32080c4fe6a8307073795ce6c Mon Sep 17 00:00:00 2001 From: Productive2 Date: Fri, 29 Jan 2021 18:42:45 +0100 Subject: [PATCH] Update build.py to support jats --- build.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/build.py b/build.py index 121aaa1..d175825 100755 --- a/build.py +++ b/build.py @@ -157,20 +157,27 @@ def build(path: str, flags: Dict[str, str] = {}, options: Dict[str, bool] = {}, logging.info("Running tests under tests/") logging.debug("Compiling test suite") start = time() - tests_path = "./tests/runtests" if os.name != "nt" else ".\tests\runtests" - _, stderr, status = run_command(f"nim compile {tests_path}", stdout=DEVNULL, stderr=PIPE) + test_runner_path = "./tests/jatr" if os.name != "nt" else ".\tests\jatr" + tests_path = "./tests/jats" if os.name != "nt" else ".\tests\jats" + command = "nim {flags} compile {path}".format(flags=nim_flags, path=test_runner_path) + _, stderr, status = run_command(command, stdout=DEVNULL, stderr=PIPE) if status != 0: logging.error(f"Command '{command}' exited with non-0 exit code {status}, output below:\n{stderr.decode()}") else: - logging.debug(f"Test suite compilation completed in {time() - start:.2f} seconds") - logging.debug("Running tests") - start = time() - # TODO: Find a better way of running the test suite - process = run_command(f"{tests_path}", mode="run", shell=True, stderr=PIPE) + command = f"nim compile {tests_path}" + _, stderr, status = run_command(command, stdout=DEVNULL, stderr=PIPE) if status != 0: logging.error(f"Command '{command}' exited with non-0 exit code {status}, output below:\n{stderr.decode()}") else: - logging.debug(f"Test suite ran in {time() - start:.2f} seconds") + logging.debug(f"Test suite compilation completed in {time() - start:.2f} seconds") + logging.debug("Running tests") + start = time() + # TODO: Find a better way of running the test suite + process = run_command(f"{tests_path}", mode="run", shell=True, stderr=PIPE) + if status != 0: + logging.error(f"Command '{command}' exited with non-0 exit code {status}, output below:\n{stderr.decode()}") + else: + logging.debug(f"Test suite ran in {time() - start:.2f} seconds") logging.info("Test suite completed!") if args.install: if os.name == "nt": @@ -263,4 +270,4 @@ if __name__ == "__main__": logging.warning(f"Could not remove test results file due to a {type(error).__name__}: {error}") logging.debug("Build tool exited") except KeyboardInterrupt: - logging.info("Interrupted by the user") \ No newline at end of file + logging.info("Interrupted by the user")