From b43f0c724b6bb0371b0dd0755ea8b65736414a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gilbert=20R=C3=B6hrbein?= Date: Fri, 2 Feb 2018 16:51:29 +0100 Subject: [PATCH] test: add env undefined regression test --- ...t-child-process-exec-node-env-undefined.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/parallel/test-child-process-exec-node-env-undefined.js diff --git a/test/parallel/test-child-process-exec-node-env-undefined.js b/test/parallel/test-child-process-exec-node-env-undefined.js new file mode 100644 index 00000000000000..74337fa713b068 --- /dev/null +++ b/test/parallel/test-child-process-exec-node-env-undefined.js @@ -0,0 +1,31 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var exec = require('child_process').exec +var readFileSync = require('fs').readFileSync + +process.env.test = '' +try { readFileSync('file-does-not-exist') } catch (e) {} + +exec(process.execPath + ' -p "process.env.test === \'undefined\' ? \'BUG\' : \'OK\'"', function (err, stdout) { + if (err) throw err + if (stdout.indexOf('BUG') != -1) throw new Error('BUG') +}) \ No newline at end of file