diff options
author | Michaƫl Zasso <targos@protonmail.com> | 2019-04-04 17:31:14 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-04-06 23:04:49 +0200 |
commit | 58aaf58406ab52599d51d4e91249776b260487cc (patch) | |
tree | d8c2f718ba160349974ada2085e75ef0dc5a427f /test | |
parent | 3d8532f851f2f7a2f8380e717281eaa08b02fb35 (diff) | |
download | android-node-v8-58aaf58406ab52599d51d4e91249776b260487cc.tar.gz android-node-v8-58aaf58406ab52599d51d4e91249776b260487cc.tar.bz2 android-node-v8-58aaf58406ab52599d51d4e91249776b260487cc.zip |
test: fix test-repl-require-after-write
Currently, the test creates a file in the cwd and doesn't clean it up.
Use a temporary directory instead.
PR-URL: https://github.com/nodejs/node/pull/27088
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-repl-require-after-write.js | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/test/parallel/test-repl-require-after-write.js b/test/parallel/test-repl-require-after-write.js index e4d9b2f5a0..ed0a7076c1 100644 --- a/test/parallel/test-repl-require-after-write.js +++ b/test/parallel/test-repl-require-after-write.js @@ -1,16 +1,22 @@ 'use strict'; const common = require('../common'); +const tmpdir = require('../common/tmpdir'); const assert = require('assert'); - const spawn = require('child_process').spawn; +const path = require('path'); + +tmpdir.refresh(); + +const requirePath = JSON.stringify(path.join(tmpdir.path, 'non-existent.json')); + // Use -i to force node into interactive mode, despite stdout not being a TTY const child = spawn(process.execPath, ['-i']); let out = ''; -const input = "try { require('./non-existent.json'); } catch {} " + - "require('fs').writeFileSync('./non-existent.json', '1');" + - "require('./non-existent.json');"; +const input = `try { require(${requirePath}); } catch {} ` + + `require('fs').writeFileSync(${requirePath}, '1');` + + `require(${requirePath});`; child.stderr.on('data', common.mustNotCall()); |