Canop / bacon

background rust code check
https://dystroy.org/bacon
GNU Affero General Public License v3.0
1.78k stars 62 forks source link

No test output when running `cargo test` with warnings #204

Closed bruceg closed 1 month ago

bruceg commented 1 month ago

I have the following job in my bacon.toml:

[jobs.test]
command = ["cargo", "test", "--color", "always"]
need_stdout = true

In addition to the problematic behavior of #196, I see another glitch in the displayed output: If there are any warnings displayed by cargo, I only see the warnings and not the tests running, even though the tests do still run. Pressing Ctrl-R to get the raw output makes no difference here. Without warnings, I see the full cargo test output showing all the test runs.

So, with no warnings:

 bacon   test   pass!  

   Compiling testdemo v0.1.0 (/tmp/bacon)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.09s
     Running unittests src/main.rs (target/debug/deps/testdemo-b777e890cf294a7b)

running 1 test
test does_it_work ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

But with a warning:

 bacon   test   pass!    1 warning   

 1  warning: unused variable: `x`
  --> src/main.rs:7:9
   |
 7 |     let x = 12;
   |         ^ help: if this is intentional, prefix it with an underscore: `_x`
   |
   = note: `#[warn(unused_variables)]` on by default
Canop commented 1 month ago

You mean you want the test summary even when all tests pass and there are warnings ?

Canop commented 1 month ago

Displaying the raw output works for me:

image

Can you try with another shortcut than ctrl-r or check with the log that it's correctly triggered (use BACON_LOG=debug bacon) ?

bruceg commented 1 month ago

You mean you want the test summary even when all tests pass and there are warnings ?

My expectation was that I would see in bacon the same as I would see in the terminal (modulo headers and footers, of course), so yes. I frequently run tests with --nocapture and use the console output from the tests to guide expected results.

Can you try with another shortcut than ctrl-r or check with the log that it's correctly triggered

I tried the same issue on a different computer and discovered that it does work. So, after comparing the two, I realized that I had never set up any keybindings on the failing computer, so C-R was not set up. That fixes the issue with getting the test output and is, at least, a sufficient workaround.