diff --git a/smoketests/__init__.py b/smoketests/__init__.py index 66d33a175d5..d9f724db6a9 100644 --- a/smoketests/__init__.py +++ b/smoketests/__init__.py @@ -20,10 +20,15 @@ TEST_DIR = Path(__file__).parent STDB_DIR = TEST_DIR.parent exe_suffix = ".exe" if sys.platform == "win32" else "" -SPACETIME_BIN = STDB_DIR / ("target/debug/spacetime" + exe_suffix) TEMPLATE_TARGET_DIR = STDB_DIR / "target/_stdbsmoketests" BASE_STDB_CONFIG_PATH = TEST_DIR / "config.toml" +SPACETIME_BIN = None +def update_spacetime_bin_path(build_dir): + global SPACETIME_BIN + SPACETIME_BIN = build_dir / ("debug/spacetime" + exe_suffix) +update_spacetime_bin_path(STDB_DIR / "target") + # the contents of files for the base smoketest project template TEMPLATE_LIB_RS = open(STDB_DIR / "crates/cli/templates/basic-rust/server/src/lib.rs").read() TEMPLATE_CARGO_TOML = open(STDB_DIR / "crates/cli/templates/basic-rust/server/Cargo.toml").read() @@ -142,7 +147,7 @@ def log_cmd(args): logging.debug(f"$ {' '.join(str(arg) for arg in args)}") -def run_cmd(*args, capture_stderr=True, check=True, full_output=False, cmd_name=None, log=True, **kwargs): +def run_cmd(*args, capture_stdout=True, capture_stderr=True, check=True, full_output=False, cmd_name=None, log=True, **kwargs): if log: log_cmd(args if cmd_name is None else [cmd_name, *args[1:]]) @@ -162,7 +167,7 @@ def run_cmd(*args, capture_stderr=True, check=True, full_output=False, cmd_name= if capture_stderr and output.stderr.strip() != "": logging.debug(f"--- stderr ---\n{output.stderr.strip()}") needs_close = True - if output.stdout.strip() != "": + if capture_stdout and output.stdout.strip() != "": logging.debug(f"--- stdout ---\n{output.stdout.strip()}") needs_close = True if needs_close: diff --git a/smoketests/__main__.py b/smoketests/__main__.py index 6161dc5a7aa..e1c92bb5332 100644 --- a/smoketests/__main__.py +++ b/smoketests/__main__.py @@ -7,7 +7,7 @@ import re import fnmatch import json -from . import TEST_DIR, SPACETIME_BIN, BASE_STDB_CONFIG_PATH, exe_suffix, build_template_target +from . import TEST_DIR, SPACETIME_BIN, BASE_STDB_CONFIG_PATH, exe_suffix, build_template_target, update_spacetime_bin_path import smoketests import sys import logging @@ -82,6 +82,9 @@ def main(): if not args.no_build_cli: logging.info("Compiling spacetime cli...") smoketests.run_cmd("cargo", "build", cwd=TEST_DIR.parent, capture_stderr=False) + build_metadata = smoketests.run_cmd("cargo", "metadata", "--format-version", "1", "--no-deps", cwd=TEST_DIR.parent, capture_stdout=False) + parsed = json.loads(build_metadata) + update_spacetime_bin_path(Path(parsed['target_directory'])) update_bin_name = "spacetimedb-update" + exe_suffix try: