diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-09-19 18:01:47 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-09-19 18:01:47 +0300 |
commit | 832658d9326656d81242ef8dda81f577c20914c6 (patch) | |
tree | 13a5982c8f46719d7022f9696e934d97753b84f7 | |
parent | 3badce737414a95836da7a3ebbdf5e86f5d3122a (diff) | |
download | clab-832658d9326656d81242ef8dda81f577c20914c6.tar.gz |
fix: work with current Subplot, and with user-defined cargo target
Sponsored-by: author
-rwxr-xr-x | check | 26 | ||||
-rw-r--r-- | subplot/clab.py | 5 | ||||
-rw-r--r-- | subplot/clab.yaml | 8 |
3 files changed, 22 insertions, 17 deletions
@@ -5,19 +5,17 @@ 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 -got_cargo_cmd() -{ - cargo "$1" --help > /dev/null +got_cargo_cmd() { + cargo "$1" --help >/dev/null } got_cargo_cmd clippy && cargo clippy -q --all-targets @@ -28,13 +26,13 @@ $hideok cargo test subplot docgen clab.md -o clab.html subplot docgen clab.md -o clab.pdf +target="$(cargo metadata --format-version=1 | python3 -c 'import sys, json; o = json.load(sys.stdin); print(o["target_directory"])')" subplot codegen clab.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/clab.py b/subplot/clab.py index 94b2e51..a16a5b8 100644 --- a/subplot/clab.py +++ b/subplot/clab.py @@ -8,7 +8,10 @@ def install_clab(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 stdout_is_yaml(ctx): diff --git a/subplot/clab.yaml b/subplot/clab.yaml index 7e013ff..9eeb26e 100644 --- a/subplot/clab.yaml +++ b/subplot/clab.yaml @@ -1,5 +1,9 @@ - given: "an installed clab" - function: install_clab + impl: + python: + function: install_clab - then: "stdout is valid YAML" - function: stdout_is_yaml + impl: + python: + function: stdout_is_yaml |