Every env!("CARGO_MANIFEST_DIR") in validation's runtime_lane.rs and runtime_lane/ and in
metal2vulkan-runtime/src/tests (135 sites) named the directory the test binary was built in. A
nextest archive built on msi and run on another node with --workspace-remap read msi's path there:
teardown_threads panicked reading runtime_examples.ll, and public_cases read no case shard.
metal2vulkan-devtools gets one resolver, workspace_dir(): two levels above the manifest directory
the runner names as the test runs (cargo and nextest name the test's crate; a remapped archive
names it in the running machine's checkout), where that root holds the validation fixtures, else
above the dev-tools crate as built (the fallback fixtures_dir already had). validation_dir() and
fixtures_dir() sit on it; engine_dir() is unchanged. The sites move onto them:
- fixture reads (fixtures/public, engine/ and examples/) onto fixtures_dir() and engine_dir(),
with the two hand-rolled "runtime variable else built" copies (attachment_reads, encoder_holds);
- committed cases and observations (validation_dir()/corpus), and public_cases and
public_case_names now read the public source rows through source::public_sources_under on
fixtures_dir() instead of source::public_sources(), which bakes the path;
- the runtime tests' device profiles (validation_dir()/profiles) and degradation_sites' read of
the lane's sources;
- the conformance recordings, docs/API.md and the runtime's own src/ through workspace_dir().
The imports of std::path the moves left unused are removed.
Test-only. tests::the_carried_tests_read_the_checkout_where_the_runner_names_it (devtools, the
previous commit) fails before this commit and passes after. Verification: the msi job that builds
both commits, runs the remapped archive at each and lints the tip is reported with this sha.
With 4e06c87523 (the scan check), e9a0927685 (render_state.rs and line_width tests; the scan covers all of runtime/src),
74aa3e44cc and 086962f1fa (fixes; source.rs fixture reads through fixtures_dir). Test code only.
Compiled in m3-max-31605 (msi: clippy x3; scan passes; lavapipe suites 6235 passed, failures all pre-existing pin-97
items or the runtime-sources pin; remapped run with the build tree hidden 201/202, the last needing an all-targets
archive, 31641). Base 4e06c87523 (31508): scan lists 135 sites; remapped run fails 63/202.
60 lines
2.5 KiB
Rust
60 lines
2.5 KiB
Rust
//! Checks of the test trees that read the checkout through this crate's directory helpers.
|
|
|
|
use std::path::{Path, PathBuf};
|
|
|
|
/// The test trees, relative to the workspace, that run from nextest archives carried to other
|
|
/// machines (`cargo nextest run --archive-file ... --workspace-remap <checkout>`): the runtime
|
|
/// lanes and the runtime's lib tests (`src/tests/` and the test modules beside its sources).
|
|
const CARRIED: [&str; 3] = [
|
|
"crates/metal2vulkan-validation/src/runtime_lane",
|
|
"crates/metal2vulkan-validation/src/runtime_lane.rs",
|
|
"crates/metal2vulkan-runtime/src",
|
|
];
|
|
|
|
/// The `.rs` files at or below `path`.
|
|
fn sources(path: &Path, out: &mut Vec<PathBuf>) {
|
|
if path.is_dir() {
|
|
for entry in std::fs::read_dir(path).unwrap() {
|
|
sources(&entry.unwrap().path(), out);
|
|
}
|
|
} else if path.extension().is_some_and(|extension| extension == "rs") {
|
|
out.push(path.to_path_buf());
|
|
}
|
|
}
|
|
|
|
/// `env!("CARGO_MANIFEST_DIR")` is the directory the test binary was built in. A carried archive
|
|
/// runs where that directory does not exist, so a test that reads a fixture, a committed case, a
|
|
/// profile or a source file by it fails there ("No such file or directory"), or finds nothing to
|
|
/// read. The carried trees read the checkout through [`crate::workspace_dir`] and the helpers on it,
|
|
/// which take the directory the test runner names as the test runs; this lists every baked site
|
|
/// left, as `file:line`.
|
|
#[test]
|
|
fn the_carried_tests_read_the_checkout_where_the_runner_names_it() {
|
|
let root = crate::workspace_dir();
|
|
let mut files = Vec::new();
|
|
for tree in CARRIED {
|
|
let path = root.join(tree);
|
|
assert!(path.exists(), "{} is missing", path.display());
|
|
sources(&path, &mut files);
|
|
}
|
|
files.sort();
|
|
assert!(files.len() > 500, "{} sources read", files.len());
|
|
let mut baked = Vec::new();
|
|
for file in &files {
|
|
let text = std::fs::read_to_string(file).unwrap();
|
|
let relative = file.strip_prefix(&root).unwrap().display().to_string();
|
|
for (at, line) in text.lines().enumerate() {
|
|
if line.contains("env!(\"CARGO_MANIFEST_DIR\")") {
|
|
baked.push(format!("{relative}:{}", at + 1));
|
|
}
|
|
}
|
|
}
|
|
assert!(
|
|
baked.is_empty(),
|
|
"{} reads of the build's directory in the carried tests (read through \
|
|
metal2vulkan_devtools::{{workspace_dir, validation_dir, fixtures_dir, engine_dir}}):\n{}",
|
|
baked.len(),
|
|
baked.join("\n")
|
|
);
|
|
}
|