From 435592cbc364404bfef4ec6c5dc2e655ca00310a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Thu, 4 Apr 2019 17:31:14 +0200 Subject: [PATCH 1/4] 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. --- test/parallel/test-repl-require-after-write.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-repl-require-after-write.js b/test/parallel/test-repl-require-after-write.js index e4d9b2f5a024dc..2717af2818bbce 100644 --- a/test/parallel/test-repl-require-after-write.js +++ b/test/parallel/test-repl-require-after-write.js @@ -1,16 +1,21 @@ 'use strict'; const common = require('../common'); +const tmpdir = require('../common/tmpdir'); const assert = require('assert'); - const spawn = require('child_process').spawn; + +tmpdir.refresh(); + +const requirePath = 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()); From 29d8dd3bfdcae0189a275af6a8d377758a121c84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Thu, 4 Apr 2019 18:15:16 +0200 Subject: [PATCH 2/4] Update test-repl-require-after-write.js --- test/parallel/test-repl-require-after-write.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-repl-require-after-write.js b/test/parallel/test-repl-require-after-write.js index 2717af2818bbce..7d442b978522aa 100644 --- a/test/parallel/test-repl-require-after-write.js +++ b/test/parallel/test-repl-require-after-write.js @@ -7,7 +7,7 @@ const spawn = require('child_process').spawn; tmpdir.refresh(); -const requirePath = tmpdir.path + 'non-existent.json'; +const requirePath = 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']); From 999b2607f20e34a6d31e7447afc0cef9ffb9744f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Fri, 5 Apr 2019 08:41:49 +0200 Subject: [PATCH 3/4] path.join --- test/parallel/test-repl-require-after-write.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-repl-require-after-write.js b/test/parallel/test-repl-require-after-write.js index 7d442b978522aa..62c1f7765b41bb 100644 --- a/test/parallel/test-repl-require-after-write.js +++ b/test/parallel/test-repl-require-after-write.js @@ -4,10 +4,11 @@ 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 = tmpdir.path + '/non-existent.json'; +const requirePath = 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']); From 2d5d3e34acf782d410a3728de7e18fa3fff53cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Sat, 6 Apr 2019 18:09:53 +0200 Subject: [PATCH 4/4] Update test-repl-require-after-write.js --- test/parallel/test-repl-require-after-write.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-repl-require-after-write.js b/test/parallel/test-repl-require-after-write.js index 62c1f7765b41bb..ed0a7076c183a0 100644 --- a/test/parallel/test-repl-require-after-write.js +++ b/test/parallel/test-repl-require-after-write.js @@ -8,15 +8,15 @@ const path = require('path'); tmpdir.refresh(); -const requirePath = path.join(tmpdir.path, 'non-existent.json'); +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('${requirePath}'); } catch {} ` + - `require('fs').writeFileSync('${requirePath}', '1');` + - `require('${requirePath}');`; +const input = `try { require(${requirePath}); } catch {} ` + + `require('fs').writeFileSync(${requirePath}, '1');` + + `require(${requirePath});`; child.stderr.on('data', common.mustNotCall());