Improve the format of error messages for failing examples.

- Compiler error messages are usually formatted as follows:

    PROGRAM:FILE_NAME:LINENO: MESSAGE

  - When an example fails, format it accordingly.

  - This has the advantage that IDEs like emacs can jump to the
    specified location.
This commit is contained in:
Neal H. Walfield 2024-11-15 10:58:18 +01:00
parent 10cb342612
commit f419837b31
No known key found for this signature in database
GPG Key ID: 6863C9AD5B4D22D3

View File

@ -195,7 +195,7 @@ macro_rules! test_examples {
eprintln!("Testing example from {}:{}", file!(), line!());
for action in $actions.actions {
for (i, action) in $actions.actions.into_iter().enumerate() {
let command = if let Some(command) = action.command() {
command
} else {
@ -222,7 +222,11 @@ macro_rules! test_examples {
let res = cmd.assert();
intermediate = Some(res.get_output().stdout.clone());
res.success();
if let Err(err) = res.try_success() {
eprintln!("example:{}:{}: executing example #{}: {}",
file!(), line!(), i + 1, err);
panic!("executing example failed");
}
}
}
}