1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use std::path::{Path, PathBuf};
use ui_test::{dependencies::DependencyBuilder, spanned::Spanned};
fn main() -> ui_test::color_eyre::Result<()> {
let root = Path::new(env!("CARGO_MANIFEST_DIR"));
// Strict suite: every diagnostic must be annotated (these pin exact macro-expansion errors).
let strict = base_config(root.join("tests/compile_fail"), root);
// Cascade suite: the `SettingsNested` trait-bound failure necessarily repeats across every
// site that names `<T as SettingsNested>::Flags`, dragging in notes that quote std, clap and
// serde internals — those churn on every toolchain and dependency bump. So this dir asserts
// only its own `//~ ERROR` annotations: `Ice` as the required level exempts the unannotated
// errors from the exhaustiveness sweep, and the `.stderr` snapshot is not compared at all.
let mut cascade = base_config(root.join("tests/compile_fail_cascade"), root);
cascade.comment_defaults.base().require_annotations_for_level = Spanned::dummy(ui_test::diagnostics::Level::Ice).into();
cascade.output_conflict_handling = ui_test::ignore_output_conflict;
ui_test::run_tests(strict)?;
ui_test::run_tests(cascade)
}
fn base_config(dir: PathBuf, root: &Path) -> ui_test::Config {
let mut config = ui_test::Config::rustc(dir);
// Resolve extern crates through cargo from a side manifest, so a case can reference both
// `v_utils_macros` and the `cli`-featured `v_utils` facade (the latter is needed for the
// `SettingsNested` trait-bound diagnostic, which only surfaces at type-check time in code
// the macro emits against `v_utils::...` paths). Hand-picking rlibs cannot pin features.
config.comment_defaults.base().set_custom(
"dependencies",
DependencyBuilder {
crate_manifest_path: root.join("tests/compile_fail_deps/Cargo.toml"),
..DependencyBuilder::default()
},
);
config.bless_command = Some("cargo test --test compile_fail -- --bless".to_string());
config.path_stderr_filter(root, "$DIR");
config
}