From a2ae2e1500377f1528163a4bb6c76707d0526dac Mon Sep 17 00:00:00 2001 From: alexion Date: Fri, 18 Sep 2026 23:13:09 -0400 Subject: [PATCH] test(xatu): use fixture files --- src/xatu/BUILD | 4 ++++ src/xatu/testdata/clean.nix | 1 + src/xatu/testdata/empty_inherit.nix | 1 + src/xatu/xatu_test.rs | 12 +++++++++--- 4 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 src/xatu/testdata/clean.nix create mode 100644 src/xatu/testdata/empty_inherit.nix diff --git a/src/xatu/BUILD b/src/xatu/BUILD index 9624c64..99e020f 100644 --- a/src/xatu/BUILD +++ b/src/xatu/BUILD @@ -27,6 +27,10 @@ rust_test( rust_test( name = "xatu_test", srcs = ["xatu_test.rs"], + compile_data = [ + "testdata/clean.nix", + "testdata/empty_inherit.nix", + ], deps = [":xatu_lib"], ) diff --git a/src/xatu/testdata/clean.nix b/src/xatu/testdata/clean.nix new file mode 100644 index 0000000..a48f8c9 --- /dev/null +++ b/src/xatu/testdata/clean.nix @@ -0,0 +1 @@ +{ inherit foo; } diff --git a/src/xatu/testdata/empty_inherit.nix b/src/xatu/testdata/empty_inherit.nix new file mode 100644 index 0000000..73a66e4 --- /dev/null +++ b/src/xatu/testdata/empty_inherit.nix @@ -0,0 +1 @@ +{ inherit; } diff --git a/src/xatu/xatu_test.rs b/src/xatu/xatu_test.rs index 43a73de..601e983 100644 --- a/src/xatu/xatu_test.rs +++ b/src/xatu/xatu_test.rs @@ -12,8 +12,11 @@ fn source_file(path: &str, source: &str) -> SourceFile { #[test] fn future_sight_reports_empty_inherit_findings() { let report = xatu::future_sight(vec![ - source_file("clean.nix", "{ inherit foo; }"), - source_file("empty.nix", "{ inherit; }"), + source_file("clean.nix", include_str!("testdata/clean.nix")), + source_file( + "empty_inherit.nix", + include_str!("testdata/empty_inherit.nix"), + ), ]) .expect("sources should parse"); @@ -21,6 +24,9 @@ fn future_sight_reports_empty_inherit_findings() { assert_eq!(1, report.diagnostics.len()); let diagnostic = &report.diagnostics[0]; - assert_eq!(PathBuf::from("empty.nix"), report.files.get(diagnostic.file_id).path); + assert_eq!( + PathBuf::from("empty_inherit.nix"), + report.files.get(diagnostic.file_id).path, + ); assert_eq!("empty_inherit", diagnostic.finding.rule_id); }