Skip to content

Commit

Permalink
Address system dependence of sed in tests (#339)
Browse files Browse the repository at this point in the history
`sed` was being used in the `http-e2e.js` test with the `-i` flag
to perform changes in-place.  However, this option has a different
syntax on OS X vs Linux.  As a fix, `-i.bak` is now used to
explicitly specify a backup extension works on both OS X and
Linux.

PR-URL: #339
  • Loading branch information
DominicKramer committed Jan 5, 2017
1 parent 8aed09d commit 4e66703
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test/non-interference/http-e2e.js
Expand Up @@ -39,7 +39,9 @@ cp.execFileSync('git', ['clone', '--branch', process.version,
'https://github.com/nodejs/node.git', '--depth', '1', node_dir]);
fs.mkdirSync(path.join(node_dir, 'test', 'tmp'));
console.log('Turning off global checks');
cp.execFileSync('sed', ['-i', 's/exports.globalCheck = true/' +
// The use of the -i flag as '-i.bak' to specify a backup extension of '.bak'
// is needed to ensure that the command works on both Linux and OS X
cp.execFileSync('sed', ['-i.bak', 's/exports.globalCheck = true/' +
'exports.globalCheck = false/g', path.join(node_dir, 'test', 'common.js')]);
var test_glob = semver.satisfies(process.version, '0.12.x') ?
path.join(node_dir, 'test', 'simple', 'test-http*.js') :
Expand All @@ -66,7 +68,9 @@ glob(test_glob, function(err, files) {
console.log('Skipped: ' + files[testCount]);
continue;
}
cp.execFileSync('sed', ['-i', 's#\'use strict\';#' +
// The use of the -i flag as '-i.bak' to specify a backup extension of
// '.bak' is needed to ensure that the command works on both Linux and OS X
cp.execFileSync('sed', ['-i.bak', 's#\'use strict\';#' +
'\'use strict\';' + gcloud_require + '#g', files[testCount]]);
if (cp.spawnSync('grep', ['-q', gcloud_require, files[testCount]]).status) {
cp.execSync('echo "' + gcloud_require + '" | cat - ' + files[testCount] +
Expand Down

0 comments on commit 4e66703

Please sign in to comment.