Up arrow navigation test failing but it works on my machine

I’m stuck on Stage #RH7.

I’ve implemented the up arrow navigation feature by using the ReadLine nuget package. It works fine locally but it’s failing the tests.

Here are my logs:

[tester::#RH7] Running tests for Stage #RH7 (History - Up-arrow navigation)
[tester::#RH7] Running ./your_program.sh
[your-program] $ echo grape mango
[your-program] grape mango
[tester::#RH7] ✓ Command executed successfully
[your-program] $ echo banana mango
[your-program] banana mango
[tester::#RH7] ✓ Command executed successfully
[your-program] $ invalid_orange_command
[your-program] invalid_orange_command: not found
[tester::#RH7] ✓ Received command not found message
[your-program] $ echo grape apple
[your-program] grape apple
[tester::#RH7] ✓ Command executed successfully
[tester::#RH7] Pressed "<UP ARROW>" (expecting to recall "echo grape apple")
[tester::#RH7] ✓ Prompt line matches "echo grape apple"
[tester::#RH7] Pressed "<UP ARROW>" (expecting to recall "invalid_orange_command")
[your-program] $ echo grape apple
[tester::#RH7] ^ Line does not match expected value.
[tester::#RH7] Expected: "$ invalid_orange_command"
[tester::#RH7] Received: "$ echo grape apple"
[tester::#RH7] Assertion failed.
[tester::#RH7] Test failed (try setting 'debug: true' in your codecrafters.yml to see more details)

I’m using ReadLine to get the command:

string command = ReadLine.Read() ?? "";

and I’m adding every command to history afterward:

ReadLine.AddHistory(command);

Here it is running locally:

shell-challenge-up-navigation

1 Like

Hey @jm6271, could you upload your code to GitHub and share the link? It will be much easier to debug if I can run it directly.

I am facing the same issue. @andy1li

@jm6271 @sandipndev Looks like you’ve got past this stage. Do you happen to remember what was wrong? Would love to see if we can improve the tester / instructions.

@andy1li I’ve moved on to a different stage, but I still haven’t figured this one out.

I have the same issue:

test runner: note that right after the assertion you see it does correctly print $ invalid_pear_command

[tester::#RH7] Running tests for Stage #RH7 (History - Up-arrow navigation)

[tester::#RH7] Running ./your_program.sh

[your-program] $ echo apple blueberry

[your-program] apple blueberry

[tester::#RH7] ✓ Command executed successfully

[your-program] $ echo apple mango

[your-program] apple mango

[tester::#RH7] ✓ Command executed successfully

[your-program] $ invalid_pear_command

[your-program] invalid_pear_command: command not found

[tester::#RH7] ✓ Received command not found message

[your-program] $ echo mango strawberry

[your-program] mango strawberry

[tester::#RH7] ✓ Command executed successfully

[tester::#RH7] Pressed "<UP ARROW>" (expecting to recall "echo mango strawberry")

[tester::#RH7] ✓ Prompt line matches "echo mango strawberry"

[tester::#RH7] Pressed "<UP ARROW>" (expecting to recall "invalid_pear_command")

[your-program] $ echo mango strawberry

[tester::#RH7] ^ Line does not match expected value.

[tester::#RH7] Expected: "$ invalid_pear_command"

[tester::#RH7] Received: "$ echo mango strawberry"

[your-program] $ invalid_pear_command

[tester::#RH7] Assertion failed.

[tester::#RH7] Test failed

running locally:

╰─⠠⠵ ./your_program.sh
$ echo apple blueberry
apple blueberry
$ echo apple mango
apple mango
$ invalid_pear_command
invalid_pear_command: command not found
$ echo mango strawberry
mango strawberry
$ echo mango strawberry # NB: i had pressed 'UP' here
$ invalid_pear_command # NB: i had pressed 'UP' here
$ echo apple mango # NB: i had pressed 'UP' here

i’m not using readline and am hand-rolling the functionality with ANSI escape sequences. Its not clear what the exact input the test runner is sending which makes it difficult to repro/debug, especially considering i can’t add any debug logs as it immediately fails the test runner before getting to the interesting part that’s failing with the up arrow