From 55aa973bee095d5bd01922cad0bd05305fb5fbad Mon Sep 17 00:00:00 2001 From: isaacs Date: Fri, 1 Mar 2013 08:54:49 -0800 Subject: [PATCH] test: Put fs write test files in tmp This prevents fixture litter when these tests fail. --- test/simple/test-fs-append-file-sync.js | 9 +++++---- test/simple/test-fs-append-file.js | 8 ++++---- test/simple/test-fs-write-file.js | 6 +++--- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/test/simple/test-fs-append-file-sync.js b/test/simple/test-fs-append-file-sync.js index 5e1158fcebc..4e95c678f3e 100644 --- a/test/simple/test-fs-append-file-sync.js +++ b/test/simple/test-fs-append-file-sync.js @@ -36,17 +36,18 @@ var data = '南越国是前203年至前111年存在于岭南地区的一个国 '它的建立保证了秦末乱世岭南地区社会秩序的稳定,有效的改善了岭南地区落后的政治、##济现状。\n'; // test that empty file will be created and have content added -var filename = join(common.fixturesDir, 'append-sync.txt'); +var filename = join(common.tmpDir, 'append-sync.txt'); common.error('appending to ' + filename); fs.appendFileSync(filename, data); var fileData = fs.readFileSync(filename); +console.error('filedata is a ' + typeof fileData); assert.equal(Buffer.byteLength(data), fileData.length); // test that appends data to a non empty file -var filename2 = join(common.fixturesDir, 'append-sync2.txt'); +var filename2 = join(common.tmpDir, 'append-sync2.txt'); fs.writeFileSync(filename2, currentFileData); common.error('appending to ' + filename2); @@ -58,7 +59,7 @@ assert.equal(Buffer.byteLength(data) + currentFileData.length, fileData2.length); // test that appendFileSync accepts buffers -var filename3 = join(common.fixturesDir, 'append-sync3.txt'); +var filename3 = join(common.tmpDir, 'append-sync3.txt'); fs.writeFileSync(filename3, currentFileData); common.error('appending to ' + filename3); @@ -71,7 +72,7 @@ var fileData3 = fs.readFileSync(filename3); assert.equal(buf.length + currentFileData.length, fileData3.length); // test that appendFile accepts numbers. -var filename4 = join(common.fixturesDir, 'append-sync4.txt'); +var filename4 = join(common.tmpDir, 'append-sync4.txt'); fs.writeFileSync(filename4, currentFileData); common.error('appending to ' + filename4); diff --git a/test/simple/test-fs-append-file.js b/test/simple/test-fs-append-file.js index 34be240029c..ad325087af6 100644 --- a/test/simple/test-fs-append-file.js +++ b/test/simple/test-fs-append-file.js @@ -24,7 +24,7 @@ var assert = require('assert'); var fs = require('fs'); var join = require('path').join; -var filename = join(common.fixturesDir, 'append.txt'); +var filename = join(common.tmpDir, 'append.txt'); common.error('appending to ' + filename); @@ -57,7 +57,7 @@ fs.appendFile(filename, s, function(e) { }); // test that appends data to a non empty file -var filename2 = join(common.fixturesDir, 'append2.txt'); +var filename2 = join(common.tmpDir, 'append2.txt'); fs.writeFileSync(filename2, currentFileData); fs.appendFile(filename2, s, function(e) { @@ -75,7 +75,7 @@ fs.appendFile(filename2, s, function(e) { }); // test that appendFile accepts buffers -var filename3 = join(common.fixturesDir, 'append3.txt'); +var filename3 = join(common.tmpDir, 'append3.txt'); fs.writeFileSync(filename3, currentFileData); var buf = new Buffer(s, 'utf8'); @@ -96,7 +96,7 @@ fs.appendFile(filename3, buf, function(e) { }); // test that appendFile accepts numbers. -var filename4 = join(common.fixturesDir, 'append4.txt'); +var filename4 = join(common.tmpDir, 'append4.txt'); fs.writeFileSync(filename4, currentFileData); common.error('appending to ' + filename4); diff --git a/test/simple/test-fs-write-file.js b/test/simple/test-fs-write-file.js index 7a487bbd51f..00704ed029c 100644 --- a/test/simple/test-fs-write-file.js +++ b/test/simple/test-fs-write-file.js @@ -24,7 +24,7 @@ var assert = require('assert'); var fs = require('fs'); var join = require('path').join; -var filename = join(common.fixturesDir, 'test.txt'); +var filename = join(common.tmpDir, 'test.txt'); common.error('writing to ' + filename); @@ -54,7 +54,7 @@ fs.writeFile(filename, s, function(e) { }); // test that writeFile accepts buffers -var filename2 = join(common.fixturesDir, 'test2.txt'); +var filename2 = join(common.tmpDir, 'test2.txt'); var buf = new Buffer(s, 'utf8'); common.error('writing to ' + filename2); @@ -73,7 +73,7 @@ fs.writeFile(filename2, buf, function(e) { }); // test that writeFile accepts numbers. -var filename3 = join(common.fixturesDir, 'test3.txt'); +var filename3 = join(common.tmpDir, 'test3.txt'); common.error('writing to ' + filename3); fs.writeFile(filename3, n, function(e) {