Tests fail after switching to raw mode for Builtin completion #QP2

After switching to raw mode (using the crossterm - Rust crate) in order to handle TAB completions, I am facing test failures for certain test cases (although trying the same thing locally doesn’t seem to run into the same issue).

Codecrafters CLI test logs:

❯ codecrafters test --previous
Initiating test run...

⏳ Turbo test runners busy. You are in queue.

Upgrade to skip the wait: https://codecrafters.io/turbo

Running tests on your code. Logs should appear shortly...

[compile]    Compiling codecrafters-shell v0.1.0 (/app)
[compile]     Finished `release` profile [optimized] target(s) in 1.85s
[compile] Moved ./.codecrafters/run.sh → ./your_program.sh
[compile] Compilation successful.

Debug = true

[tester::#OO8] Running tests for Stage #OO8 (Print a prompt)
[tester::#OO8] Running ./your_program.sh
[your-program] $
[tester::#OO8] ✓ Received prompt
[tester::#OO8] Test passed.

[tester::#CZ2] Running tests for Stage #CZ2 (Handle invalid commands)
[tester::#CZ2] Running ./your_program.sh
[your-program] $ invalid_mango_command
[tester::#CZ2] ^ Line does not match expected value.
[tester::#CZ2] Expected: "$ invalid_mango_command"
[tester::#CZ2] Received: "$ invalid_mango_commandError: Custom { kind: Other, error: "The cursor position could not be read within a normal durati"
[your-program] on" }
[your-program]
[tester::#CZ2] Assertion failed.
[tester::#CZ2] Test failed

View our article on debugging test failures: https://codecrafters.io/debug

Logs of when I run a similar command locally:

❯ cargo run
   Compiling codecrafters-shell v0.1.0 (REDACTED)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.26s
     Running `target/debug/codecrafters-shell`
$ some_invalid_command
some_invalid_command: command not found
$ exit

I found the piece of code where the error occurs in crossterm, it is this function. It appears that crossterm isn’t able to access the stdout handle within the designated time, presumably because it is locked by another thread?

I’ve created a repository where you can see/test my code.

Hey @Mirko-A, is the cursor position query strictly necessary? Removing it should resolve the issue.

You can re-run previous tests using our CLI to make sure the earlier stages pass first:

codecrafters test --previous

Closing this thread due to inactivity. If you still need assistance, feel free to reopen or start a new discussion!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.