dandavison / delta

A syntax-highlighting pager for git, diff, grep, and blame output
https://dandavison.github.io/delta/
MIT License
21.34k stars 359 forks source link

🐛 test env::tests::test_env_parsing_with_pager_set_to_bat ... FAILED #1660

Open vt-alt opened 3 months ago

vt-alt commented 3 months ago

When building a detla package for ALT from the tag 0.17.0 tests fail with:

[00:00:50] + cargo test -j32 --release --no-fail-fast
...
[00:01:08] failures:
[00:01:08] 
[00:01:08] ---- env::tests::test_env_parsing_with_pager_set_to_bat stdout ----
[00:01:08] thread 'env::tests::test_env_parsing_with_pager_set_to_bat' panicked at src/env.rs:79:9:
[00:01:08] assertion `left == right` failed: Expected env.pagers.1 == Some(bat) but was Some("less")
[00:01:08]   left: Some("less")
[00:01:08]  right: Some("bat")
[00:01:08] note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[00:01:08] 
[00:01:08] 
[00:01:08] failures:
[00:01:08]     env::tests::test_env_parsing_with_pager_set_to_bat
[00:01:08] 
[00:01:08] test result: FAILED. 377 passed; 1 failed; 8 ignored; 0 measured; 0 filtered out; finished in 0.42s
[00:01:08] 
[00:01:08] error: test failed, to rerun pass `--bin delta`
[00:01:08] error: 1 target failed:
[00:01:08]     `--bin delta`

Temporary build log: https://git.altlinux.org/tasks/342942/build/100/x86_64/log

Interestingly, when I try to reproduce this on other host with the same build env it does not fail:

21:23:11 test env::tests::test_env_parsing_with_pager_set_to_bat ... ok

Both envs do not have bat binary. If bat binary is installed the test fails anyway.

ps. It looks like the test fails probabilistically. But because we have 4 build architectures, it fails with a high probability when build for all of them. Stat from different build runs:

subtask  name   aarch64    i586  ppc64le  x86_64
   #100  delta     3:54  failed     4:17  failed

subtask  name   aarch64  i586  ppc64le  x86_64
   #100  delta     3:53  2:11   failed  failed

subtask  name   aarch64    i586  ppc64le  x86_64
   #100  delta     3:55  failed   failed  failed
dandavison commented 3 months ago

Hi, thanks for the issue. This is a flaky test that relies on setting environment variables (which in general does not work with Rust tests seeing as they are executed concurrently by default). It needs to be re-written, perhaps using something like https://github.com/vmx/temp-env

vt-alt commented 3 months ago

IC. Thanks for answer! I will run them with cargo test ... -- --test-threads=1 (already tested to work OK).

dandavison commented 3 months ago

Great! Sorry about that; we will fix it soon.

sashkab commented 3 months ago

same issue on armhf build for alpine. Will try @vt-alt's suggestion.