summaryrefslogtreecommitdiff
path: root/subplot
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-09-15 08:25:56 +0300
committerLars Wirzenius <liw@liw.fi>2021-09-15 08:25:56 +0300
commiteccb45b085a5b0e930b29efbd74deaeb4e2b5b73 (patch)
tree84245aed6bb97d975cd0ca08a6ac4a9480f32ea5 /subplot
parent83a4ed97f0d70726e3a06c95ec2c7d8a8ba3cfb5 (diff)
downloadewww-eccb45b085a5b0e930b29efbd74deaeb4e2b5b73.tar.gz
test: handle user-chosen cargo target directory
Sponsored-by: author
Diffstat (limited to 'subplot')
-rw-r--r--subplot/ewww.py14
1 files changed, 5 insertions, 9 deletions
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.