chore(glue/tests): pretty print the errors

Previously we'd print out raw error structure, now it's pretty printed:

thread 'tests::eval_okay::code_path_04_src_tests_snix_tests_eval_okay_fetchgit_nix' panicked at glue/src/tests/mod.rs:79:9:
/home/domen/dev/snix/snix/glue/src/tests/snix_tests/eval-okay-fetchgit.nix: evaluation of eval-okay test should succeed, but failed with:
note: while evaluating this as native code (final_deep_force)
  --> /home/domen/dev/snix/snix/glue/src/tests/snix_tests/eval-okay-fetchgit.nix:1:1
   |
1  | / let
2  | | assertTimestamps = result:
3  | |   let
4  | |     requiredAttrs = ["lastModified" "lastModifiedDate"];
...  |
27 | |       #}))
28 | |     ]
   | |_____^
note: while evaluating this as native code (deep_force)
  --> /home/domen/dev/snix/snix/glue/src/tests/snix_tests/eval-okay-fetchgit.nix:11:5
   |
11 |     builtins.removeAttrs result requiredAttrs;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: while evaluating this as native code (force)
  --> /home/domen/dev/snix/snix/glue/src/tests/snix_tests/eval-okay-fetchgit.nix:14:26
   |
14 |         (assertTimestamps (builtins.fetchGit {
   |  __________________________^
15 | |         url = "https://git.snix.dev/snix/snix.git";
16 | |         ref = "canon";
17 | |         rev = "75d788b0f2";
18 | |       }))
   | |_______^
error[E997]: error from producer: clone fetch error: An IO error occurred when talking to the server
  --> /home/domen/dev/snix/snix/glue/src/tests/snix_tests/eval-okay-fetchgit.nix:14:26
   |
14 |         (assertTimestamps (builtins.fetchGit {
   |  __________________________^
15 | |         url = "https://git.snix.dev/snix/snix.git";
16 | |         ref = "canon";
17 | |         rev = "75d788b0f2";
18 | |       }))
   | |_______^

Change-Id: I451714d682e42bf5ef8df3e80299807ca37683b7
Reviewed-on: https://cl.snix.dev/c/snix/+/30184
Reviewed-by: Florian Klink <flokli@flokli.de>
Tested-by: besadii
This commit is contained in:
Domen Kožar 2025-03-20 16:51:42 +00:00 committed by Domen Kožar
parent fdf7a68946
commit 1621ae21e7

View file

@ -69,10 +69,17 @@ fn eval_test(code_path: PathBuf, expect_success: bool) {
_ => !result.errors.is_empty(),
};
if expect_success && failed {
let error_details = result
.errors
.iter()
.map(|error| error.fancy_format_str())
.collect::<Vec<String>>();
let error_string = error_details.join("\n");
panic!(
"{}: evaluation of eval-okay test should succeed, but failed with {:?}",
"{}: evaluation of eval-okay test should succeed, but failed with:\n{}",
code_path.display(),
result.errors,
error_string,
);
}