Skip to content

Commit 762bb94

Browse files
Aivo PaasBridgeAR
Aivo Paas
authored andcommitted
test: add test case for completion bash flag
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>
1 parent afcfdec commit 762bb94

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/parallel/test-bash-completion.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
require('../common');
3+
const assert = require('assert');
4+
const child_process = require('child_process');
5+
6+
const p = child_process.spawnSync(
7+
process.execPath, [ '--completion-bash' ]);
8+
assert.ifError(p.error);
9+
assert.ok(p.stdout.toString().includes(
10+
`_node_complete() {
11+
local cur_word options
12+
cur_word="\${COMP_WORDS[COMP_CWORD]}"
13+
if [[ "\${cur_word}" == -* ]] ; then
14+
COMPREPLY=( $(compgen -W '`));
15+
assert.ok(p.stdout.toString().includes(
16+
`' -- "\${cur_word}") )
17+
return 0
18+
else
19+
COMPREPLY=( $(compgen -f "\${cur_word}") )
20+
return 0
21+
fi
22+
}
23+
complete -F _node_complete node node_g`));

0 commit comments

Comments
 (0)