From eccb45b085a5b0e930b29efbd74deaeb4e2b5b73 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Wed, 15 Sep 2021 08:25:56 +0300 Subject: test: handle user-chosen cargo target directory Sponsored-by: author --- subplot/ewww.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'subplot') diff --git a/subplot/ewww.py b/subplot/ewww.py index a6c4c4f..11915ae 100644 --- a/subplot/ewww.py +++ b/subplot/ewww.py @@ -10,12 +10,6 @@ import urllib.parse import yaml -# Name of Rust binary, debug-build. -def _binary(name): - srcdir = globals()["srcdir"] - return os.path.abspath(os.path.join(srcdir, "target", "debug", name)) - - # Write a file with given content. def _write(filename, content): open(filename, "w").write(content) @@ -59,6 +53,7 @@ def copy_test_certificate(ctx, cert=None, key=None): # Start server using named configuration file. def start_server(ctx, filename=None): get_file = globals()["get_file"] + srcdir = globals()["srcdir"] daemon_start_on_port = globals()["daemon_start_on_port"] logging.debug(f"Starting ewww with config file {filename}") @@ -72,9 +67,10 @@ def start_server(ctx, filename=None): config = yaml.safe_dump(config) _write(filename, config) - daemon_start_on_port( - ctx, path=_binary("ewww"), args=filename, name="ewww", port=port - ) + target = os.environ.get("CARGO_TARGET_DIR", os.path.join(srcdir, "target")) + logging.debug(f"Cargo target directory: {target}") + binary = os.path.join(target, "debug", "ewww") + daemon_start_on_port(ctx, binary, args=filename, name="ewww", port=port) # Stop previously started server. -- cgit v1.2.1