Skip to content

Commit

Permalink
test: add test case for completion bash flag
Browse files Browse the repository at this point in the history
This test case verifies that starting Node.js with the completion
bash flag prints out the expected result and ends right after.

PR-URL: #24168
Reviewed-By: Bryan English <bryan@bryanenglish.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
Aivo Paas authored and MylesBorins committed Dec 26, 2018
1 parent dd67f39 commit 63dc221
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/parallel/test-bash-completion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';
require('../common');
const assert = require('assert');
const child_process = require('child_process');

const p = child_process.spawnSync(
process.execPath, [ '--completion-bash' ]);
assert.ifError(p.error);
assert.ok(p.stdout.toString().includes(
`_node_complete() {
local cur_word options
cur_word="\${COMP_WORDS[COMP_CWORD]}"
if [[ "\${cur_word}" == -* ]] ; then
COMPREPLY=( $(compgen -W '`));
assert.ok(p.stdout.toString().includes(
`' -- "\${cur_word}") )
return 0
else
COMPREPLY=( $(compgen -f "\${cur_word}") )
return 0
fi
}
complete -F _node_complete node node_g`));

0 comments on commit 63dc221

Please sign in to comment.