"Read tree" stage tests are flaky
rohitpaulk opened this issue · 2 comments
rohitpaulk commented
the tests are flaky - they fail and if i run it again with no changes, they pass
[stage-4] Running ./your_git.sh ls-tree --name-only 8eeb4ae8872e3393d1530df8f536f56255b69000
[your_program] doo
[your_program] dumpty
[your_program] Traceback (most recent call last):
[your_program] File "<frozen runpy>", line 198, in _run_module_as_main
[your_program] File "<frozen runpy>", line 88, in _run_code
[your_program] File "/app/app/main.py", line 105, in <module>
[your_program] main()
[your_program] File "/app/app/main.py", line 83, in main
[your_program] mode, path = entry.split(b" ")
[your_program] ^^^^^^^^^^
[your_program] ValueError: too many values to unpack (expected 2)
[stage-4] Expected "doo\ndumpty\nhumpty\n" as stdout, got: "doo\ndumpty\n"
[stage-4] Test failed
[stage-4] Running tests for Stage #4: Read a tree object
[stage-4] Running ./your_git.sh init
[your_program] Initialized git directory
[stage-4] Writing a tree to git storage..
[stage-4] Running ./your_git.sh ls-tree --name-only 0e0e083fd1cd81bb3df04d53e726e2a6a763e6d0
[your_program] doo
[your_program] dumpty
[your_program] yikes
[your_program] Traceback (most recent call last):
[your_program] File "<frozen runpy>", line 198, in _run_module_as_main
[your_program] File "<frozen runpy>", line 88, in _run_code
[your_program] File "/app/app/main.py", line 105, in <module>
[your_program] main()
[your_program] File "/app/app/main.py", line 83, in main
[your_program] mode, path = entry.split(b" ")
[your_program] ^^^^^^^^^^
[your_program] ValueError: not enough values to unpack (expected 2, got 1)
[stage-4] Test passed.
Looks like we aren't testing the exit code?
rohitpaulk commented
Thanks to @siraj-samsudeen for highlighting this!
rohitpaulk commented
Let's fix this + add a test similar to https://github.com/codecrafters-io/git-tester/tree/605053c117d7cc599ebadc218d6c89194a40797d/internal/test_helpers/stages/read_tree that prints the correct content to stdout but exits with a non-zero exit code.