Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions smoketests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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:]])

Expand All @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion smoketests/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
Loading