tere: Integration test failures during Arch Linux build
Integration tests were added in the last release, more specifically: https://github.com/mgunyho/tere/commit/70d2686e3ad5bd950e6137dd755a0d7e59b42dc1
I’m getting the following test failures in a clean chroot build:
running 4 tests
test basic_run ... FAILED
test first_run_prompt_accept ... FAILED
test output_on_exit_without_cd ... FAILED
test first_run_prompt_cancel ... FAILED
failures:
---- basic_run stdout ----
thread 'basic_run' panicked at 'assertion failed: `(left == right)`
left: `"Error: Io(Os { code: 11, kind: WouldBlock, message: \"Resource temporarily unavailable\" })\r\n"`,
right: `"/tmp/.tmpmJWT4L\r\n"`', tests/cli.rs:61:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
---- first_run_prompt_accept stdout ----
thread 'first_run_prompt_accept' panicked at 'assertion failed: ptn.find(&output).is_some()', tests/cli.rs:126:5
---- output_on_exit_without_cd stdout ----
thread 'output_on_exit_without_cd' panicked at 'assertion failed: `(left == right)`
left: `"Error: Io(Os { code: 11, kind: WouldBlock, message: \"Resource temporarily unavailable\" })\r\n"`,
right: `"tere: Exited without changing folder\r\n"`', tests/cli.rs:76:5
---- first_run_prompt_cancel stdout ----
thread 'first_run_prompt_cancel' panicked at 'assertion failed: ptn.find(&output).is_some()', tests/cli.rs:96:5
failures:
basic_run
first_run_prompt_accept
first_run_prompt_cancel
output_on_exit_without_cd
test result: FAILED. 0 passed; 4 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.12s
error: test failed, to rerun pass `--test cli`
I couldn’t figure out why this is happening so I thought it’d better to report here.
As a workaround, I tried skipping the integration tests and using --lib
but got error: no library targets found in package tere
.
About this issue
- Original URL
- State: closed
- Created 10 months ago
- Comments: 30 (30 by maintainers)
Commits related to this issue
- Fix and improve case sensitive mode test Not sure why it was broken in the first place... See also discussion in Github issue #93 — committed to mgunyho/tere by mgunyho 6 months ago
With the help of @ProducerMatt’s nix environment in #100, I managed to track down the issue.
It’s the
terminal_size_usize
function, which calls this function from the crossterm library:The first part sets
fd
either to the file descriptor of/dev/tty
or stdout. Based on my testing in the Nix environment,File::open("/dev/tty")
givesErr(Os { code: 6, kind: Uncategorized, message: "No such device or address" })
, so it will fall back to stdout.After this, it calls
ioctl(fd, TIOCGWINSZ.into(), ...)
where I believe the not very descriptive “File not found” error comes from.So the problem is querying the “terminal size” inside the Nix environment / chroot. The next step would be to flood my search engine with queries like “nix environment tty” and similar.
Thanks for bearing with me on this!
Alright, cool! I’ll close this issue for now, let me know if anything else comes up. We can remove the
ncurses
dependency once thetput
fallback is removed from crossterm, although I guess it’s not much of a problem.Okay, I found a solution that doesn’t rely on
faketty
- seems like the integration test has a hidden dependency ontput
(provided byncurses
package on nix, not sure about Arch), see https://github.com/mgunyho/tere/pull/100#issuecomment-2029618331. Could you @orhun try again withoutscript
/faketty
and withtput
available in the chroot?I’m starting to think that it would be easiest to just skip the integration tests for now, this can be done by changing the test command to
cargo test --bins
.That is actually another failure that has been fixed on the
develop
branch, and prevents the integration tests from running. Could you please retry ondevelop
?BTW, based on the readme of
faketty
, it does something very similar toscript
so that could be a solution as well.@mgunyho yes in fact, Nix runs on other Linux and MacOS. I will submit a PR with a Nix dev environment and how to use it. 😃
I now fixed it in 8cadf56, this
app_state::tests::test_case_sensitive_mode_change
shouldn’t fail anymore. I’m not really sure what was going on there. I’m using a new computer and new distro compared to when I initially wrote it, so that might have something to do with it as well? But looking at the test, it did have a logic error. Hard to say. But thanks anyway for helping out!Thanks for testing this! I’ll look into it. One thing to note that
cat test-out-stderr.txt
will not show the control codes, since the output is like<control code to switch to alternate screen><a bunch of drawing commands><switch back to regular screen>Cancelled.
cat
will print to the terminal, which will obey the control codes, so you won’t see what was on the alt screen. So I would need to see the actual txt file contents (you can see the control codes by opening it in vim for example). But I think I can debug this based on the print in the dummy test.