mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-05 23:42:50 +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",
|
"pollster",
|
||||||
"rand",
|
"rand",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
|
"toml_edit",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -29,6 +29,7 @@ jj-lib = { workspace = true, features = ["testing"] }
|
|||||||
pollster = { workspace = true }
|
pollster = { workspace = true }
|
||||||
rand = { workspace = true }
|
rand = { workspace = true }
|
||||||
tempfile = { workspace = true }
|
tempfile = { workspace = true }
|
||||||
|
toml_edit = { workspace = true }
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
@ -26,7 +26,6 @@ use std::process::Command;
|
|||||||
use std::process::Stdio;
|
use std::process::Stdio;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use bstr::ByteSlice as _;
|
|
||||||
use itertools::Itertools as _;
|
use itertools::Itertools as _;
|
||||||
use jj_lib::backend;
|
use jj_lib::backend;
|
||||||
use jj_lib::backend::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) {
|
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
|
// Parse the integration tests' main modules from the Cargo manifest.
|
||||||
// we're running in CI.
|
let manifest = {
|
||||||
if !is_external_tool_installed("taplo") {
|
let file_path = test_dir.parent().unwrap().join("Cargo.toml");
|
||||||
ensure_running_outside_ci("`taplo` must be in the PATH");
|
let text = fs::read_to_string(&file_path).unwrap();
|
||||||
eprintln!(
|
toml_edit::ImDocument::parse(text).unwrap()
|
||||||
"Skipping check for forgotten test files because taplo is not installed on the system"
|
};
|
||||||
);
|
let test_bin_mods = if let Some(item) = manifest.get("test") {
|
||||||
return;
|
let tables = item.as_array_of_tables().unwrap();
|
||||||
}
|
tables
|
||||||
|
.iter()
|
||||||
// Use taplo to find all the test executable main modules listed in `[[test]]`.
|
.map(|test| test.get("name").unwrap().as_str().unwrap().to_owned())
|
||||||
let taplo_output = Command::new("taplo")
|
.collect()
|
||||||
.args(["get", "test[*].name", "-f", "Cargo.toml"])
|
} else {
|
||||||
.current_dir(test_dir.parent().unwrap())
|
vec![]
|
||||||
.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();
|
|
||||||
|
|
||||||
// Add to that all submodules which are declared in the main test modules via
|
// Add to that all submodules which are declared in the main test modules via
|
||||||
// `mod`.
|
// `mod`.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user