From b152618dbcf935cc0c533f00b612697f0e8d4132 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Tue, 20 Dec 2011 09:59:02 +1100 Subject: [PATCH] made the file tests more robust --- test/fileAppender.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/fileAppender.js b/test/fileAppender.js index 72d6e6b..567ff82 100644 --- a/test/fileAppender.js +++ b/test/fileAppender.js @@ -17,14 +17,16 @@ vows.describe('log4js fileAppender').addBatch({ 'with default fileAppender settings': { topic: function() { - var testFile = __dirname + '/fa-default-test.log' + var that = this, testFile = __dirname + '/fa-default-test.log' , logger = log4js.getLogger('default-settings'); remove(testFile); log4js.addAppender(log4js.fileAppender(testFile), 'default-settings'); logger.info("This should be in the file."); - fs.readFile(testFile, "utf8", this.callback); + setTimeout(function() { + fs.readFile(testFile, "utf8", that.callback); + }, 100); }, 'should write log messages to the file': function(err, fileContents) { assert.include(fileContents, "This should be in the file.\n"); @@ -94,7 +96,7 @@ vows.describe('log4js fileAppender').addBatch({ assert.equal(files.length, 3); }, 'should be named in sequence': function (files) { - assert.deepEqual(files, ['fa-maxFileSize-with-backups-test.log', 'fa-maxFileSize-with-backups-test.log.1', 'fa-maxFileSize-with-backups-test.log.2']); + assert.deepEqual(files.sort(), ['fa-maxFileSize-with-backups-test.log', 'fa-maxFileSize-with-backups-test.log.1', 'fa-maxFileSize-with-backups-test.log.2']); }, 'and the contents of the first file': { topic: function(logFiles) {