about summary refs log tree commit diff
path: root/pkgs/test
diff options
context:
space:
mode:
authorSilvan Mosberger <silvan.mosberger@tweag.io>2023-10-19 02:42:22 +0200
committerSilvan Mosberger <silvan.mosberger@tweag.io>2023-10-24 01:15:56 +0200
commit96f6a350fa74e995dbbf750b17cad2d6cbb3186e (patch)
treeb649f4bd6e87a76942fcfdd867116f68293f80d4 /pkgs/test
parenta755aa7d0251e4282ebdfdd33cbb00382b9a004c (diff)
tests.nixpkgs-check-by-name: Intermediate PathInterpolation error
Diffstat (limited to 'pkgs/test')
-rw-r--r--pkgs/test/nixpkgs-check-by-name/src/check_result.rs14
-rw-r--r--pkgs/test/nixpkgs-check-by-name/src/references.rs22
2 files changed, 24 insertions, 12 deletions
diff --git a/pkgs/test/nixpkgs-check-by-name/src/check_result.rs b/pkgs/test/nixpkgs-check-by-name/src/check_result.rs
index cc004e0129313..ed00f383f193c 100644
--- a/pkgs/test/nixpkgs-check-by-name/src/check_result.rs
+++ b/pkgs/test/nixpkgs-check-by-name/src/check_result.rs
@@ -5,6 +5,12 @@ use std::io;
 use std::path::PathBuf;
 
 pub enum CheckError {
+    PathInterpolation {
+        relative_package_dir: PathBuf,
+        subpath: PathBuf,
+        line: usize,
+        text: String,
+    },
     SearchPath {
         relative_package_dir: PathBuf,
         subpath: PathBuf,
@@ -35,6 +41,14 @@ impl CheckError {
 impl fmt::Display for CheckError {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match self {
+            CheckError::PathInterpolation { relative_package_dir, subpath, line, text } =>
+                write!(
+                    f,
+                    "{}: File {} at line {line} contains the path expression \"{}\", which is not yet supported and may point outside the directory of that package.",
+                    relative_package_dir.display(),
+                    subpath.display(),
+                    text
+                ),
             CheckError::SearchPath { relative_package_dir, subpath, line, text } =>
                 write!(
                     f,
diff --git a/pkgs/test/nixpkgs-check-by-name/src/references.rs b/pkgs/test/nixpkgs-check-by-name/src/references.rs
index dacac9c9ee5ce..6cc933e721a35 100644
--- a/pkgs/test/nixpkgs-check-by-name/src/references.rs
+++ b/pkgs/test/nixpkgs-check-by-name/src/references.rs
@@ -133,18 +133,16 @@ fn check_nix_file<W: io::Write>(
 
         // Filters out ./foo/${bar}/baz
         // TODO: We can just check ./foo
-        if node.children().count() != 0 {
-            context.error_writer.write(&format!(
-                "{}: File {} at line {line} contains the path expression \"{}\", which is not yet supported and may point outside the directory of that package.",
-                context.relative_package_dir.display(),
-                subpath.display(),
-                text
-            ))?;
-            continue;
-        }
-
-        // Filters out search paths like <nixpkgs>
-        let check_result = if text.starts_with('<') {
+        let check_result = if node.children().count() != 0 {
+            CheckError::PathInterpolation {
+                relative_package_dir: context.relative_package_dir.clone(),
+                subpath: subpath.to_path_buf(),
+                line,
+                text,
+            }
+            .into_result()
+        } else if text.starts_with('<') {
+            // Filters out search paths like <nixpkgs>
             CheckError::SearchPath {
                 relative_package_dir: context.relative_package_dir.clone(),
                 subpath: subpath.to_path_buf(),