Skip to content

Commit

Permalink
Fix intermittently failing atime/mtime tests
Browse files Browse the repository at this point in the history
  • Loading branch information
erikkemperman committed Jan 17, 2016
1 parent 7d0001a commit b70bed0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions test/dest.js
Original file line number Diff line number Diff line change
Expand Up @@ -618,8 +618,7 @@ describe('dest stream', function() {
var inputBase = path.join(__dirname, './fixtures/');
var expectedPath = path.join(__dirname, './out-fixtures/test.coffee');
var expectedContents = fs.readFileSync(inputPath);
var expectedAtime = new Date();
var expectedMtime = new Date();
var earlier = Date.now() - 1000;

var expectedFile = new File({
base: inputBase,
Expand All @@ -635,8 +634,8 @@ describe('dest stream', function() {
buffered.length.should.equal(1);
buffered[0].should.equal(expectedFile);
fs.existsSync(expectedPath).should.equal(true);
fs.lstatSync(expectedPath).atime.setMilliseconds(0).should.equal(expectedAtime.setMilliseconds(0));
fs.lstatSync(expectedPath).mtime.setMilliseconds(0).should.equal(expectedMtime.setMilliseconds(0));
fs.lstatSync(expectedPath).atime.getTime().should.be.above(earlier);
fs.lstatSync(expectedPath).mtime.getTime().should.be.above(earlier);
expectedFile.stat.should.not.have.property('mtime');
expectedFile.stat.should.have.property('atime');
done();
Expand Down Expand Up @@ -695,16 +694,16 @@ describe('dest stream', function() {
var inputBase = path.join(__dirname, './fixtures/');
var expectedPath = path.join(__dirname, './out-fixtures/test.coffee');
var expectedContents = fs.readFileSync(inputPath);
var expectedMtime = new Date();
var invalidMtime = new Date(undefined);
var earlier = Date.now() - 1000;

var expectedFile = new File({
base: inputBase,
cwd: __dirname,
path: inputPath,
contents: expectedContents,
stat: {
mtime: invalidMtime,
atime: new Date(earlier),
mtime: new Date(undefined),
},
});

Expand All @@ -714,7 +713,8 @@ describe('dest stream', function() {
buffered.length.should.equal(1);
buffered[0].should.equal(expectedFile);
fs.existsSync(expectedPath).should.equal(true);
fs.lstatSync(expectedPath).mtime.setMilliseconds(0).should.equal(expectedMtime.setMilliseconds(0));
fs.lstatSync(expectedPath).atime.getTime().should.be.above(earlier);
fs.lstatSync(expectedPath).mtime.getTime().should.be.above(earlier);
done();
};

Expand Down

0 comments on commit b70bed0

Please sign in to comment.