test: Put fs write test files in tmp
authorisaacs <i@izs.me>
Fri, 1 Mar 2013 16:54:49 +0000 (08:54 -0800)
committerisaacs <i@izs.me>
Fri, 1 Mar 2013 16:55:05 +0000 (08:55 -0800)
This prevents fixture litter when these tests fail.

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

index 5e1158f..4e95c67 100644 (file)
@@ -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);
index 34be240..ad32508 100644 (file)
@@ -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);
index 7a487bb..00704ed 100644 (file)
@@ -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) {