test: install binaries in the inst directory, run from there

This avoids having to determine the rigth path in the Cargo target
directory, which is tricky when --target is used.
This commit is contained in:
Lars Wirzenius
2026-08-24 18:07:38 +03:00
parent 8632bed993
commit f80dbd95eb
2 changed files with 33 additions and 9 deletions
+31 -4
View File
@@ -1,4 +1,25 @@
TESTS =
# The "install_test" target installs the subplot binary so that
# $(SUBPLOT) refers to it. This lets us run Subplot without invoking
# "cargo run" every time. This means we invoke in a way that's more
# natural and have to jump through fewer hoops. Also the binary can be
# run from Python tests directly.
SUBPLOT_DIR = $(abspath inst)
# Individual tests run by `test` or `fast-test` targets.
TESTS =
# Set this to "--offline --locked" to build offline.
OFFLINE =
# Cargo target architecture.
TARGET =
ifdef TARGET
TARGET_ARG = --target $(TARGET)
else
TARGET_ARG =
endif
all: check build test doc shear
@@ -11,11 +32,17 @@ build:
cargo build --all-targets --workspace
subplot docgen ci-broker.subplot -o ci-broker.html
fast-test: build
timeout 60 cargo test --workspace -- --skip upgrades $(TESTS)
install_test_binary:
rm -rf "$(SUBPLOT_DIR)"
cargo install $(TARGET_ARG) --locked $(OFFLINE) --path=. --root="$(SUBPLOT_DIR)" --debug
mv "$(SUBPLOT_DIR)"/bin/* "$(SUBPLOT_DIR)"
rm -rf "$(SUBPLOT_DIR)"/.crate* "$(SUBPLOT_DIR)"/bin
fast-test: install_test_binary build
env SUBPLOT_DIR="$(SUBPLOT_DIR)" timeout 60 cargo test --workspace -- --skip upgrades $(TESTS)
test: fast-test
timeout 300 cargo test --workspace -- $(TESTS)
env SUBPLOT_DIR="$(SUBPLOT_DIR)" timeout 300 cargo test --workspace -- $(TESTS)
.PHONY: doc
doc:
+2 -5
View File
@@ -383,11 +383,8 @@ fn head(rad_home: &Path, repo: &Path) -> Result<Oid, Box<dyn std::error::Error>>
}
fn bindir() -> PathBuf {
let path = if let Ok(target) = std::env::var("CARGO_TARGET_DIR") {
Path::new(&target).join("debug")
} else {
PathBuf::from("target/debug")
};
let path = std::env::var("SUBPLOT_DIR").expect("SUBPLOT_DIR must be set");
let path = Path::new(&path);
path.canonicalize().unwrap()
}