diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-09-11 07:40:41 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-09-11 07:40:41 +0000 |
commit | 5b19853bbf6ed1dcb1a0b6150f042de8da75c8a3 (patch) | |
tree | 1c6fab0ecdf12fd112cac9c9fee391f4c6e92852 | |
parent | 4035a94813da138f345be8f1e863e16d475eb668 (diff) | |
parent | 6068ae53a9d85d83b6fcdb96530581794c2b0845 (diff) | |
download | obnam2-5b19853bbf6ed1dcb1a0b6150f042de8da75c8a3.tar.gz |
Merge branch 'cargo-target' into 'main'
test: tell Subplot-generated test program where the binaries are
Closes #133
See merge request obnam/obnam!176
-rwxr-xr-x | check | 40 | ||||
-rw-r--r-- | subplot/client.py | 5 | ||||
-rw-r--r-- | subplot/server.py | 8 |
3 files changed, 25 insertions, 28 deletions
@@ -5,28 +5,24 @@ set -eu hideok=chronic -if [ "$#" -gt 0 ] -then - case "$1" in +if [ "$#" -gt 0 ]; then + case "$1" in verbose | -v | --verbose) - hideok= - shift - ;; - esac + hideok= + shift + ;; + esac fi -require_cmd() -{ - if ! command -v "$1" > /dev/null - then - echo "Need to have $1 installed, but can't find it" 1>&2 - return 1 - fi +require_cmd() { + if ! command -v "$1" >/dev/null; then + echo "Need to have $1 installed, but can't find it" 1>&2 + return 1 + fi } -got_cargo_cmd() -{ - cargo "$1" --help > /dev/null +got_cargo_cmd() { + cargo "$1" --help >/dev/null } require_cmd rustc @@ -43,7 +39,7 @@ require_cmd pdflatex # daemonize installation location changed from Debian 10 to 11. require_cmd daemonize || require_cmd /usr/sbin/daemonize -got_cargo_cmd clippy && cargo clippy --all-targets -q +got_cargo_cmd clippy && cargo clippy --all-targets -q $hideok cargo build --all-targets got_cargo_cmd fmt && $hideok cargo fmt -- --check $hideok cargo test @@ -51,13 +47,13 @@ $hideok cargo test subplot docgen obnam.md -o obnam.html subplot docgen obnam.md -o obnam.pdf +target="$(cargo metadata --format-version=1 | python3 -c 'import sys, json; o = json.load(sys.stdin); print(o["target_directory"])')" subplot codegen obnam.md -o test.py rm -f test.log -if [ "$(id -un)" = root ] -then - echo Not running tests as root. +if [ "$(id -un)" = root ]; then + echo Not running tests as root. else - $hideok python3 test.py --log test.log "$@" + $hideok python3 test.py --log test.log --env "CARGO_TARGET_DIR=$target" "$@" fi echo "Everything seems to be in order." diff --git a/subplot/client.py b/subplot/client.py index d0beba5..bea3b18 100644 --- a/subplot/client.py +++ b/subplot/client.py @@ -8,7 +8,10 @@ def install_obnam(ctx): srcdir = globals()["srcdir"] # Add the directory with built Rust binaries to the path. - runcmd_prepend_to_path(ctx, dirname=os.path.join(srcdir, "target", "debug")) + default_target = os.path.join(srcdir, "target") + target = os.environ.get("CARGO_TARGET_DIR", default_target) + runcmd_prepend_to_path(ctx, dirname=os.path.join(target, "debug")) + ctx["server-binary"] = os.path.join(target, "debug", "obnam-server") def uninstall_obnam(ctx): diff --git a/subplot/server.py b/subplot/server.py index 52ad8f4..2a3e397 100644 --- a/subplot/server.py +++ b/subplot/server.py @@ -33,9 +33,7 @@ def start_chunk_server(ctx, env=None): "address": f"localhost:{port}", } - server_binary = os.path.abspath( - os.path.join(srcdir, "target", "debug", "obnam-server") - ) + server_binary = ctx["server-binary"] filename = "config.yaml" yaml.safe_dump(config, stream=open(filename, "w")) @@ -44,8 +42,7 @@ def start_chunk_server(ctx, env=None): ctx["server_url"] = f"https://{config['address']}" daemon_start_on_port( - ctx, name="obnam-server", path=server_binary, args=filename, port=port, - env=env + ctx, name="obnam-server", path=server_binary, args=filename, port=port, env=env ) @@ -202,6 +199,7 @@ def _expand_vars(ctx, s): s = s[m.end() :] return "".join(result) + def _server_stderr_contains(ctx, wanted): daemon_get_stderr = globals()["daemon_get_stderr"] |