From b23b6a48213051fa65aae194046786e721a209d8 Mon Sep 17 00:00:00 2001 From: Aivo Paas Date: Tue, 6 Nov 2018 15:52:09 +0000 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/24168 Reviewed-By: Bryan English Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater --- test/parallel/test-bash-completion.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/parallel/test-bash-completion.js diff --git a/test/parallel/test-bash-completion.js b/test/parallel/test-bash-completion.js new file mode 100644 index 00000000000000..50378a7b0f8028 --- /dev/null +++ b/test/parallel/test-bash-completion.js @@ -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`));