marckhouzam / cobra-completion-testing

A set of completion tests for Cobra
MIT License
4 stars 4 forks source link

Avoid using newline as a completion separator #17

Closed marckhouzam closed 2 years ago

marckhouzam commented 2 years ago

When calling the _completionTests_complete function in a sub-shell, the trailing newlines are removed by the shell. Therefore, if the script we are testing mistakenly includes an empty completion at the end, we would not detect that bug. See https://github.com/spf13/cobra/pull/1691

With this commit, we use a space to separate the completions, so an empty one will be detected (extra space).

With this change we can see the tests failing before https://github.com/spf13/cobra/pull/1691 and start to pass again when https://github.com/spf13/cobra/pull/1691 is applied

/cc @scop