I’m stuck on Stage #NA5.
Every previous test succeeded so far and the test I am failing on is not even checking for the auto.
Here are my logs:
[tester::#NA5] Running tests for Stage #NA5 (Highlighting - Implement the auto color option)
[tester::#NA5] $ echo -ne "apple" | ./your_program.sh --color=always -E '\w+' | cat
[your_program] apple
[tester::#NA5] ✓ Received exit code 0.
[tester::#NA5] ✓ Found line "apple"
[tester::#NA5] ✓ All matches in the line "apple" are highlighted
[tester::#NA5] $ echo -ne "monkey in the wild\ngiraffe in the air" | ./your_program.sh --color=always -E '(monkey|giraffe)'
[your_program] monkey in the wild
[your_program] monkey in the wild
[your_program] giraffe in the air
[your_program] giraffe in the air
[tester::#NA5] timed out, test exceeded 10 seconds
[tester::#NA5] Test failed
This is the first time that I am getting a timed and I have no idea why. The only thing that’s different with this particular test is the absence of | cat at the end.
Also this is the only test where my program prints twice, once without color and once with color.
Could be a flushing issue perhaps? Possible hypothesis: echo -ne does not emit a final newline. When | cat is there your shell’s stdout is piped to cat and cat pulls immediately and then outputs. When your shell is last in the pipeline your stdout is to the line-buffered terminal. But since no newline is sent you are still waiting for the end of the line?
Yes that’s what I thought but I don’t know how to verify that hypothesis.
I tried some local tests but they do not mimic the codecrafters test suite 1 to 1.
Any ideas on how to verify that hypothesis ?
Have you tried without the n option or whether it works with cat at the end? And conversely whether the working example with “apple” stops working if try without cat?
Are you using readline library? Maybe it toggles behavior based on the STDIN source. Try simply ./your_program.sh --color=always -E '(monkey|giraffe)' without echo’ing the input, but typing it yourself.
No I am using the default C# console readline.
I will try your suggestions, thank you.
I ran the command locally and I didn’t get a timeout when using echo.
But when I type the input myself, the console read stays open until I exit the app with Ctrl + C.