Tests for Stage #UN3 (Redirection - Append stderr)

I’m stuck on Stage #(UN3).

My tests pass in terms of current stage, but it fails on Redirection - Append stderr.
It doesn’t looks it should.

I test locally and everything works expected. I can’t understand the reason of fail.
If we run with 2>> then file should not be empty. Am I missing something?

Here are my logs:

Initiating test run...

⚡ This is a turbo test run. https://codecrafters.io/turbo

Running tests. Logs should appear shortly...

[compile] Moved ./.codecrafters/run.sh → ./your_program.sh
[compile] Compilation successful.

Debug = true

[tester::#QP2] Running tests for Stage #QP2 (Autocompletion - Builtin completion)
[tester::#QP2] Running ./your_program.sh
[tester::#QP2] ✓ Received prompt ($ )
[tester::#QP2] Typed "ech"
[tester::#QP2] ✓ Prompt line matches "$ ech"
[tester::#QP2] Pressed "<TAB>" (expecting autocomplete to "echo")
[tester::#QP2] ✓ Prompt line matches "echo"
[your-program] $ echo 
[tester::#QP2] Tearing down shell
[tester::#QP2] Running ./your_program.sh
[tester::#QP2] ✓ Received prompt ($ )
[tester::#QP2] Typed "exi"
[tester::#QP2] ✓ Prompt line matches "$ exi"
[tester::#QP2] Pressed "<TAB>" (expecting autocomplete to "exit")
[tester::#QP2] ✓ Prompt line matches "exit"
[your-program] $ exit 
[tester::#QP2] Tearing down shell
[tester::#QP2] Test passed.

[tester::#UN3] Running tests for Stage #UN3 (Redirection - Append stderr)
[tester::#UN3] [setup] export PATH=/tmp/strawberry/grape/pear:$PATH
[tester::#UN3] Running ./your_program.sh
[your-program] $ ls -1 nonexistent >> /tmp/qux/baz.md
[your-program] ls: nonexistent: No such file or directory
[tester::#UN3] ✓ Received error message
[tester::#UN3] ✓ File: /tmp/qux/baz.md is empty
[your-program] $ ls -1 nonexistent 2>> /tmp/qux/foo.md
[tester::#UN3] Expected file content ("") but received "ls: nonexistent: No such file or directory\n"
[your-program] ls: nonexistent: No such file or directory
[your-program] $ ls -1 nonexistent 2>> /tmp/qux/foo.md
[your-program] $ cat /tmp/qux/foo.md
[your-program] $ 
[tester::#UN3] Assertion failed.
[tester::#UN3] Test failed

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

And here’s my github repo:

Hey @steal9pro, I tried running your code locally and noticed that a couple of things aren’t working as expected:

  • 2.txt should contain something, but it appears to be empty.
  • 1.txt should be empty, but it contains something.

If we run with 2>> then file should not be empty. Am I missing something?

I know it’s hard to tell, but our tester tries to assert that 1.txt (or /tmp/qux/baz.md in your example) stays empty.

Let me know if you’d like further clarification!

1 Like

I see, found a bug.
It’s a tricky one, thank you

1 Like

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