Skip to content

Commit 55aa973

Browse files
committed
test: Put fs write test files in tmp
This prevents fixture litter when these tests fail.
1 parent f0f87d8 commit 55aa973

3 files changed

Lines changed: 12 additions & 11 deletions

File tree

test/simple/test-fs-append-file-sync.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,18 @@ var data = '南越国是前203年至前111年存在于岭南地区的一个国
3636
'它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n';
3737

3838
// test that empty file will be created and have content added
39-
var filename = join(common.fixturesDir, 'append-sync.txt');
39+
var filename = join(common.tmpDir, 'append-sync.txt');
4040

4141
common.error('appending to ' + filename);
4242
fs.appendFileSync(filename, data);
4343

4444
var fileData = fs.readFileSync(filename);
45+
console.error('filedata is a ' + typeof fileData);
4546

4647
assert.equal(Buffer.byteLength(data), fileData.length);
4748

4849
// test that appends data to a non empty file
49-
var filename2 = join(common.fixturesDir, 'append-sync2.txt');
50+
var filename2 = join(common.tmpDir, 'append-sync2.txt');
5051
fs.writeFileSync(filename2, currentFileData);
5152

5253
common.error('appending to ' + filename2);
@@ -58,7 +59,7 @@ assert.equal(Buffer.byteLength(data) + currentFileData.length,
5859
fileData2.length);
5960

6061
// test that appendFileSync accepts buffers
61-
var filename3 = join(common.fixturesDir, 'append-sync3.txt');
62+
var filename3 = join(common.tmpDir, 'append-sync3.txt');
6263
fs.writeFileSync(filename3, currentFileData);
6364

6465
common.error('appending to ' + filename3);
@@ -71,7 +72,7 @@ var fileData3 = fs.readFileSync(filename3);
7172
assert.equal(buf.length + currentFileData.length, fileData3.length);
7273

7374
// test that appendFile accepts numbers.
74-
var filename4 = join(common.fixturesDir, 'append-sync4.txt');
75+
var filename4 = join(common.tmpDir, 'append-sync4.txt');
7576
fs.writeFileSync(filename4, currentFileData);
7677

7778
common.error('appending to ' + filename4);

test/simple/test-fs-append-file.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var assert = require('assert');
2424
var fs = require('fs');
2525
var join = require('path').join;
2626

27-
var filename = join(common.fixturesDir, 'append.txt');
27+
var filename = join(common.tmpDir, 'append.txt');
2828

2929
common.error('appending to ' + filename);
3030

@@ -57,7 +57,7 @@ fs.appendFile(filename, s, function(e) {
5757
});
5858

5959
// test that appends data to a non empty file
60-
var filename2 = join(common.fixturesDir, 'append2.txt');
60+
var filename2 = join(common.tmpDir, 'append2.txt');
6161
fs.writeFileSync(filename2, currentFileData);
6262

6363
fs.appendFile(filename2, s, function(e) {
@@ -75,7 +75,7 @@ fs.appendFile(filename2, s, function(e) {
7575
});
7676

7777
// test that appendFile accepts buffers
78-
var filename3 = join(common.fixturesDir, 'append3.txt');
78+
var filename3 = join(common.tmpDir, 'append3.txt');
7979
fs.writeFileSync(filename3, currentFileData);
8080

8181
var buf = new Buffer(s, 'utf8');
@@ -96,7 +96,7 @@ fs.appendFile(filename3, buf, function(e) {
9696
});
9797

9898
// test that appendFile accepts numbers.
99-
var filename4 = join(common.fixturesDir, 'append4.txt');
99+
var filename4 = join(common.tmpDir, 'append4.txt');
100100
fs.writeFileSync(filename4, currentFileData);
101101

102102
common.error('appending to ' + filename4);

test/simple/test-fs-write-file.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var assert = require('assert');
2424
var fs = require('fs');
2525
var join = require('path').join;
2626

27-
var filename = join(common.fixturesDir, 'test.txt');
27+
var filename = join(common.tmpDir, 'test.txt');
2828

2929
common.error('writing to ' + filename);
3030

@@ -54,7 +54,7 @@ fs.writeFile(filename, s, function(e) {
5454
});
5555

5656
// test that writeFile accepts buffers
57-
var filename2 = join(common.fixturesDir, 'test2.txt');
57+
var filename2 = join(common.tmpDir, 'test2.txt');
5858
var buf = new Buffer(s, 'utf8');
5959
common.error('writing to ' + filename2);
6060

@@ -73,7 +73,7 @@ fs.writeFile(filename2, buf, function(e) {
7373
});
7474

7575
// test that writeFile accepts numbers.
76-
var filename3 = join(common.fixturesDir, 'test3.txt');
76+
var filename3 = join(common.tmpDir, 'test3.txt');
7777
common.error('writing to ' + filename3);
7878

7979
fs.writeFile(filename3, n, function(e) {

0 commit comments

Comments
 (0)