mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-05 15:32:49 +00:00
tests: do not shell out taplo to gather forgotten test files
It would be annoying if forgotten tests wouldn't be reported locally.
This commit is contained in:
parent
5a735182ac
commit
105c892ce4
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -4006,6 +4006,7 @@ dependencies = [
|
||||
"pollster",
|
||||
"rand",
|
||||
"tempfile",
|
||||
"toml_edit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -29,6 +29,7 @@ jj-lib = { workspace = true, features = ["testing"] }
|
||||
pollster = { workspace = true }
|
||||
rand = { workspace = true }
|
||||
tempfile = { workspace = true }
|
||||
toml_edit = { workspace = true }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -26,7 +26,6 @@ use std::process::Command;
|
||||
use std::process::Stdio;
|
||||
use std::sync::Arc;
|
||||
|
||||
use bstr::ByteSlice as _;
|
||||
use itertools::Itertools as _;
|
||||
use jj_lib::backend;
|
||||
use jj_lib::backend::Backend;
|
||||
@ -635,38 +634,21 @@ pub fn assert_abandoned_with_parent(
|
||||
}
|
||||
|
||||
pub fn assert_no_forgotten_test_files(test_dir: &Path) {
|
||||
// We require `taplo` for this check; if it's not installed, that's ok unless
|
||||
// we're running in CI.
|
||||
if !is_external_tool_installed("taplo") {
|
||||
ensure_running_outside_ci("`taplo` must be in the PATH");
|
||||
eprintln!(
|
||||
"Skipping check for forgotten test files because taplo is not installed on the system"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Use taplo to find all the test executable main modules listed in `[[test]]`.
|
||||
let taplo_output = Command::new("taplo")
|
||||
.args(["get", "test[*].name", "-f", "Cargo.toml"])
|
||||
.current_dir(test_dir.parent().unwrap())
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(
|
||||
taplo_output.status.success(),
|
||||
"taplo returned with status {}: {}",
|
||||
taplo_output.status,
|
||||
taplo_output.stderr.to_str_lossy(),
|
||||
);
|
||||
let test_bin_mods = taplo_output
|
||||
.stdout
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.trim()
|
||||
.lines()
|
||||
.map(ToString::to_string)
|
||||
.collect_vec();
|
||||
// Parse the integration tests' main modules from the Cargo manifest.
|
||||
let manifest = {
|
||||
let file_path = test_dir.parent().unwrap().join("Cargo.toml");
|
||||
let text = fs::read_to_string(&file_path).unwrap();
|
||||
toml_edit::ImDocument::parse(text).unwrap()
|
||||
};
|
||||
let test_bin_mods = if let Some(item) = manifest.get("test") {
|
||||
let tables = item.as_array_of_tables().unwrap();
|
||||
tables
|
||||
.iter()
|
||||
.map(|test| test.get("name").unwrap().as_str().unwrap().to_owned())
|
||||
.collect()
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
|
||||
// Add to that all submodules which are declared in the main test modules via
|
||||
// `mod`.
|
||||
|
Loading…
x
Reference in New Issue
Block a user