diff --git a/tests/tests.rs b/tests/tests.rs index ea1b30a..acc4ad5 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -3,9 +3,9 @@ extern crate compiletest_rs as compiletest; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; -fn find_rlib(dependency_path: &str, dependency_name: &str) -> std::io::Result> { +fn find_rlib(dependency_path: &Path, dependency_name: &str) -> std::io::Result> { use std::fs::read_dir; for entry in read_dir(dependency_path)? { @@ -23,8 +23,8 @@ fn find_rlib(dependency_path: &str, dependency_name: &str) -> std::io::Result String { - let mut flags = format!("--edition=2021 -L dependency={} ", dependency_path); +fn rustc_flags(dependency_path: &Path, dependencies: &[&str]) -> String { + let mut flags = format!("--edition=2021 -L dependency={} ", dependency_path.display()); for dep in dependencies { let rlib_path = find_rlib(dependency_path, dep).expect("io error").expect("rlib not found"); @@ -35,6 +35,14 @@ fn rustc_flags(dependency_path: &str, dependencies: &[&str]) -> String { flags } +fn dependency_path() -> PathBuf { + std::env::args() + .next() + .map(PathBuf::from) + .and_then(|p| p.parent().map(ToOwned::to_owned)) + .expect("could not find dependency path") +} + #[test] fn compile_tests() { use compiletest::common::Mode; @@ -48,7 +56,7 @@ fn compile_tests() { let dependencies = ["archery", "static_assertions"]; - config.target_rustcflags = Some(rustc_flags("target/debug/deps/", &dependencies)); + config.target_rustcflags = Some(rustc_flags(&dependency_path(), &dependencies)); compiletest::run_tests(&config); } diff --git a/tools/codecov.sh b/tools/codecov.sh index f9586ab..5168ac7 100755 --- a/tools/codecov.sh +++ b/tools/codecov.sh @@ -36,7 +36,8 @@ done # TODO it seems the `--force-clean` is not working. cargo clean -cargo tarpaulin --force-clean --ignore-panics --engine llvm --timeout 1200 --out $output_format --all-features +cargo tarpaulin --force-clean --ignore-panics --engine llvm --timeout 1200 --out $output_format \ + --run-types Lib --all-features if [ "$output_format" == "html" ]; then echo