[Shell] AutoCompletion -> Partial completions (fixed) #WT6

I’m stuck on Stage #WT6.

I’ve tried ..

much debugging. I’ve written a more extensive matcher to match the least common prefix for a set of given items. This works locally but does not pass on tests.

Git repo available here: GitHub - jgdovin/codecrafters-shell-javascript: progress for build your own shell from codecrafters.

Set up a similar test in my local environment:


codecrafters-shell-javascript (master) ✗ ./your_program.sh
$ xyz_
xyz_foo  xyz_foo_bar  xyz_foo_bar_baz
$ xyz_foo
xyz_foo_bar  xyz_foo_bar_baz
$ xyz_foo_bar

below is a gif of it seeming to work as I expect on my local.

demo

And here’s the logs of my tests:

Running tests. Logs should appear shortly...

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

[tester::#WT6] Running tests for Stage #WT6 (Autocompletion - Partial completions)
[tester::#WT6] [setup] export PATH=/tmp/qux:$PATH
[tester::#WT6] [setup] export PATH=/tmp/bar:$PATH
[tester::#WT6] [setup] export PATH=/tmp/baz:$PATH
[tester::#WT6] [setup] Available executables:
[tester::#WT6] [setup] - xyz_foo
[tester::#WT6] [setup] - xyz_foo_bar
[tester::#WT6] [setup] - xyz_foo_bar_quz
[tester::#WT6] Running ./your_program.sh
[tester::#WT6] ✓ Received prompt ($ )
[tester::#WT6] Typed "xyz_"
[tester::#WT6] ✓ Prompt line matches "$ xyz_"
[tester::#WT6] Pressed "<TAB>" (expecting autocomplete to "xyz_foo")
[your-program] $ xyz_
[tester::#WT6] ^ Line does not match expected value.
[tester::#WT6] Expected: "$ xyz_foo"
[tester::#WT6] Received: "$ xyz_"
[your-program] xyz_foo  xyz_foo_bar  xyz_foo_bar_quz
[your-program] $ xyz_foo
[tester::#WT6] Assertion failed.
[tester::#WT6] Test failed (try setting 'debug: true' in your codecrafters.yml to see more details)

Hey @jgdovin, looks like this deviates from how Bash handles partial completions:

Here’s what a successful run looks like:

Namely, no list should be printed at that point. You can verify this by trying it in a real shell.

Let me know if you’d like any further clarification!

1 Like

I see, let me take a look. I misunderstood the error I was receiving from the test. It looked like it was complaining about $ xyz_ which is the previous prompt. Thanks!

1 Like

ok fixed! Thanks for pointing me in the right direction!

1 Like

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