I’m trying to go through Stage #ND9 (Count rows in a table), but I hit a wall. The test suite looks at the CLI output, but the Gleam compiler messages cause the tests to fail. I need a way to silence those, but I have no idea how. Any pointers? Here’s what it dumps on the terminal.
Compiled in 0.03s
Running sqlite.main
=ERROR REPORT==== 8-Aug-2024::19:01:39.036822 ===
backend port not found: inotifywait
107
107 is the actual expected output. Anything before that is stuff that I want to silence.
Another way would be getting the test suite to ignore the compiler output, but I think that’s not how this platform works, right?
One interesting detail is that I have gone through a lot of challenge stages with the Gleam compiler already, and this never came up as a problem. Could there be something wrong with how this stage specifically expects the output to be?
Update
Just found out about the new codecrafters test --previous flag and ran a test on the previous stages. The compiler messages are there all the time, but the tests don’t complain at all, and pass. Only #ND9 seems to be affected.
Other stages pass ok with the same messages. Is the testing different for #ND9 ? I went through the tester repo but couldn’t figure out where exactly it asserts the output.
This is what I ended up with, unable to filter out that last newline. Is there a way to fix how the test evaluates the output?
[tester::#ND9] Running tests for Stage #ND9 (Count rows in a table)
[tester::#ND9] $ ./your_program.sh test.db "select count(*) from pistachio"
[your_program]
[your_program] 142
[tester::#ND9] Expected "142\n" as stdout, got: "\n142\n"
[tester::#ND9] Test failed (try setting 'debug: true' in your codecrafters.yml to see more details)
Use the following command in .codecrafters/run.sh and your_program.sh:
grep -vE "Compiled|Running|=ERROR REPORT=|backend port|^$"`
# The only change was from ^\r?\n to ^$
@edgerunner Could you give this a try, and please let me know how it goes?
I was also baffled by why the extra \n couldn’t be eliminated. Turns out that grep works on a line-by-line basis, meaning \n was already consumed by grep , leaving us just blank lines which can’t be matched by ^\r?\n.
Yes, it’s already in the nightly. The only question mark is how do I upgrade the gleam version without starting a fresh repo. (Which I’d rather not because I use commit messages as code comments, thanks to the git-lens feature in Zed)