From a27345461b4902c3ce8eaf38a4ece27f2804a160 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Fri, 15 Aug 2014 20:06:35 +1000 Subject: [PATCH] altering the timings on some tests to make them slightly less flaky (maybe) --- test/categoryFilter-test.js | 20 ++++++++++---------- test/logLevelFilter-test.js | 12 ++++++------ test/smtpAppender-test.js | 18 ++++++++---------- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/test/categoryFilter-test.js b/test/categoryFilter-test.js index bd40198..15a7b90 100644 --- a/test/categoryFilter-test.js +++ b/test/categoryFilter-test.js @@ -16,24 +16,24 @@ function remove(filename) { vows.describe('log4js categoryFilter').addBatch({ 'appender': { topic: function() { - + var log4js = require('../lib/log4js'), logEvents = [], webLogger, appLogger; log4js.clearAppenders(); var appender = require('../lib/appenders/categoryFilter') .appender( - ['app'], + ['app'], function(evt) { logEvents.push(evt); } ); log4js.addAppender(appender, ["app","web"]); - + webLogger = log4js.getLogger("web"); appLogger = log4js.getLogger("app"); - + webLogger.debug('This should get logged'); appLogger.debug('This should not'); webLogger.debug('Hello again'); log4js.getLogger('db').debug('This shouldn\'t be included by the appender anyway'); - + return logEvents; }, 'should only pass matching category' : function(logEvents) { @@ -42,25 +42,25 @@ vows.describe('log4js categoryFilter').addBatch({ assert.equal(logEvents[1].data[0], 'Hello again'); } }, - + 'configure': { topic: function() { var log4js = require('../lib/log4js') , logger, weblogger; - + remove(__dirname + '/categoryFilter-web.log'); remove(__dirname + '/categoryFilter-noweb.log'); - + log4js.configure('test/with-categoryFilter.json'); logger = log4js.getLogger("app"); weblogger = log4js.getLogger("web"); - + logger.info('Loading app'); logger.debug('Initialising indexes'); weblogger.info('00:00:00 GET / 200'); weblogger.warn('00:00:00 GET / 500'); //wait for the file system to catch up - setTimeout(this.callback, 100); + setTimeout(this.callback, 500); }, 'tmp-tests.log': { topic: function() { diff --git a/test/logLevelFilter-test.js b/test/logLevelFilter-test.js index c74e488..2280a96 100644 --- a/test/logLevelFilter-test.js +++ b/test/logLevelFilter-test.js @@ -21,12 +21,12 @@ vows.describe('log4js logLevelFilter').addBatch({ log4js.addAppender( require('../lib/appenders/logLevelFilter') .appender( - 'ERROR', + 'ERROR', function(evt) { logEvents.push(evt); } - ), + ), "logLevelTest" ); - + logger = log4js.getLogger("logLevelTest"); logger.debug('this should not trigger an event'); logger.warn('neither should this'); @@ -45,10 +45,10 @@ vows.describe('log4js logLevelFilter').addBatch({ topic: function() { var log4js = require('../lib/log4js') , logger; - + remove(__dirname + '/logLevelFilter.log'); remove(__dirname + '/logLevelFilter-warnings.log'); - + log4js.configure('test/with-logLevelFilter.json'); logger = log4js.getLogger("tests"); logger.info('main'); @@ -56,7 +56,7 @@ vows.describe('log4js logLevelFilter').addBatch({ logger.warn('both'); logger.debug('main'); //wait for the file system to catch up - setTimeout(this.callback, 100); + setTimeout(this.callback, 500); }, 'tmp-tests.log': { topic: function() { diff --git a/test/smtpAppender-test.js b/test/smtpAppender-test.js index 27cc179..ab38d93 100644 --- a/test/smtpAppender-test.js +++ b/test/smtpAppender-test.js @@ -7,7 +7,7 @@ var vows = require('vows') function setupLogging(category, options) { var msgs = []; - + var fakeMailer = { createTransport: function (name, options) { return { @@ -49,7 +49,7 @@ function setupLogging(category, options) { }); log4js.addAppender(smtpModule.configure(options), category); - + return { logger: log4js.getLogger(category), mailer: fakeMailer, @@ -150,10 +150,10 @@ vows.describe('log4js smtpAppender').addBatch({ }, 500); setTimeout(function () { setup.logger.info('Log event #3'); - }, 1050); + }, 1100); setTimeout(function () { self.callback(null, setup); - }, 2100); + }, 3000); }, 'there should be three messages': function (result) { assert.equal(result.results.length, 3); @@ -181,13 +181,13 @@ vows.describe('log4js smtpAppender').addBatch({ }, 0); setTimeout(function () { setup.logger.info('Log event #2'); - }, 500); + }, 100); setTimeout(function () { setup.logger.info('Log event #3'); - }, 1050); + }, 1500); setTimeout(function () { self.callback(null, setup); - }, 2100); + }, 3000); }, 'there should be two messages': function (result) { assert.equal(result.results.length, 2); @@ -218,7 +218,7 @@ vows.describe('log4js smtpAppender').addBatch({ close: function() { } }; }; - + setup.logger.info("This will break"); return setup.console; }, @@ -228,6 +228,4 @@ vows.describe('log4js smtpAppender').addBatch({ assert.equal(cons.errors[0].value.message, 'oh noes'); } } - }).export(module); -