Skip to content

Commit 322dedd

Browse files
committed
test: create temp files in a separate folder
No change to logic. This updates the tests to switch into the `test_data/` folder for creating temp files. This allows for more reliable temp file cleanup.
1 parent 1baf550 commit 322dedd

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ node_modules/
22
coverage/
33
.nyc_output/
44

5+
test_data/
6+
57
*~
68
*.swp
79
.DS_Store

test/test.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* globals describe, it, before, afterEach */
1+
/* globals describe, it, before, beforeEach, afterEach */
22
const origShell = require('shelljs');
33
const assert = require('assert');
44
const fs = require('fs');
@@ -31,8 +31,14 @@ describe('proxy', function describeproxy() {
3131
shell.config.silent = true;
3232
});
3333

34+
beforeEach(() => {
35+
shell.mkdir('-p', 'test_data');
36+
shell.cd('test_data');
37+
});
38+
3439
afterEach(() => {
35-
shell.rm('-f', '*.txt');
40+
shell.cd('..');
41+
shell.rm('-rf', 'test_data');
3642
});
3743

3844
it('appropriately handles inspect() and valueOf()', () => {
@@ -222,10 +228,10 @@ describe('proxy', function describeproxy() {
222228
});
223229

224230
it('can use subcommands with options', (done) => {
225-
fs.existsSync('package.json').should.equal(true);
231+
fs.existsSync('../package.json').should.equal(true);
226232

227233
// dont' actually remove this file, but do a dry run
228-
const ret = shell.git.rm('-qrnf', 'package.json');
234+
const ret = shell.git.rm('-qrnf', '../package.json');
229235
ret.code.should.equal(0);
230236
ret.stdout.should.equal('');
231237
ret.stderr.should.equal('');

0 commit comments

Comments
 (0)