mirror of
https://seed.radicle.dev/rad:zwTxygwuz5LDGBq255RA2CbNGrz8.git
synced 2026-10-18 19:30:29 +08:00
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:
@@ -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
|
all: check build test doc shear
|
||||||
|
|
||||||
@@ -11,11 +32,17 @@ build:
|
|||||||
cargo build --all-targets --workspace
|
cargo build --all-targets --workspace
|
||||||
subplot docgen ci-broker.subplot -o ci-broker.html
|
subplot docgen ci-broker.subplot -o ci-broker.html
|
||||||
|
|
||||||
fast-test: build
|
install_test_binary:
|
||||||
timeout 60 cargo test --workspace -- --skip upgrades $(TESTS)
|
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
|
test: fast-test
|
||||||
timeout 300 cargo test --workspace -- $(TESTS)
|
env SUBPLOT_DIR="$(SUBPLOT_DIR)" timeout 300 cargo test --workspace -- $(TESTS)
|
||||||
|
|
||||||
.PHONY: doc
|
.PHONY: doc
|
||||||
doc:
|
doc:
|
||||||
|
|||||||
+2
-5
@@ -383,11 +383,8 @@ fn head(rad_home: &Path, repo: &Path) -> Result<Oid, Box<dyn std::error::Error>>
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn bindir() -> PathBuf {
|
fn bindir() -> PathBuf {
|
||||||
let path = if let Ok(target) = std::env::var("CARGO_TARGET_DIR") {
|
let path = std::env::var("SUBPLOT_DIR").expect("SUBPLOT_DIR must be set");
|
||||||
Path::new(&target).join("debug")
|
let path = Path::new(&path);
|
||||||
} else {
|
|
||||||
PathBuf::from("target/debug")
|
|
||||||
};
|
|
||||||
path.canonicalize().unwrap()
|
path.canonicalize().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user