altering the timings on some tests to make them slightly less flaky (maybe)
This commit is contained in:
parent
fb9948145c
commit
a27345461b
@ -16,24 +16,24 @@ function remove(filename) {
|
|||||||
vows.describe('log4js categoryFilter').addBatch({
|
vows.describe('log4js categoryFilter').addBatch({
|
||||||
'appender': {
|
'appender': {
|
||||||
topic: function() {
|
topic: function() {
|
||||||
|
|
||||||
var log4js = require('../lib/log4js'), logEvents = [], webLogger, appLogger;
|
var log4js = require('../lib/log4js'), logEvents = [], webLogger, appLogger;
|
||||||
log4js.clearAppenders();
|
log4js.clearAppenders();
|
||||||
var appender = require('../lib/appenders/categoryFilter')
|
var appender = require('../lib/appenders/categoryFilter')
|
||||||
.appender(
|
.appender(
|
||||||
['app'],
|
['app'],
|
||||||
function(evt) { logEvents.push(evt); }
|
function(evt) { logEvents.push(evt); }
|
||||||
);
|
);
|
||||||
log4js.addAppender(appender, ["app","web"]);
|
log4js.addAppender(appender, ["app","web"]);
|
||||||
|
|
||||||
webLogger = log4js.getLogger("web");
|
webLogger = log4js.getLogger("web");
|
||||||
appLogger = log4js.getLogger("app");
|
appLogger = log4js.getLogger("app");
|
||||||
|
|
||||||
webLogger.debug('This should get logged');
|
webLogger.debug('This should get logged');
|
||||||
appLogger.debug('This should not');
|
appLogger.debug('This should not');
|
||||||
webLogger.debug('Hello again');
|
webLogger.debug('Hello again');
|
||||||
log4js.getLogger('db').debug('This shouldn\'t be included by the appender anyway');
|
log4js.getLogger('db').debug('This shouldn\'t be included by the appender anyway');
|
||||||
|
|
||||||
return logEvents;
|
return logEvents;
|
||||||
},
|
},
|
||||||
'should only pass matching category' : function(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');
|
assert.equal(logEvents[1].data[0], 'Hello again');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
'configure': {
|
'configure': {
|
||||||
topic: function() {
|
topic: function() {
|
||||||
var log4js = require('../lib/log4js')
|
var log4js = require('../lib/log4js')
|
||||||
, logger, weblogger;
|
, logger, weblogger;
|
||||||
|
|
||||||
remove(__dirname + '/categoryFilter-web.log');
|
remove(__dirname + '/categoryFilter-web.log');
|
||||||
remove(__dirname + '/categoryFilter-noweb.log');
|
remove(__dirname + '/categoryFilter-noweb.log');
|
||||||
|
|
||||||
log4js.configure('test/with-categoryFilter.json');
|
log4js.configure('test/with-categoryFilter.json');
|
||||||
logger = log4js.getLogger("app");
|
logger = log4js.getLogger("app");
|
||||||
weblogger = log4js.getLogger("web");
|
weblogger = log4js.getLogger("web");
|
||||||
|
|
||||||
logger.info('Loading app');
|
logger.info('Loading app');
|
||||||
logger.debug('Initialising indexes');
|
logger.debug('Initialising indexes');
|
||||||
weblogger.info('00:00:00 GET / 200');
|
weblogger.info('00:00:00 GET / 200');
|
||||||
weblogger.warn('00:00:00 GET / 500');
|
weblogger.warn('00:00:00 GET / 500');
|
||||||
//wait for the file system to catch up
|
//wait for the file system to catch up
|
||||||
setTimeout(this.callback, 100);
|
setTimeout(this.callback, 500);
|
||||||
},
|
},
|
||||||
'tmp-tests.log': {
|
'tmp-tests.log': {
|
||||||
topic: function() {
|
topic: function() {
|
||||||
|
@ -21,12 +21,12 @@ vows.describe('log4js logLevelFilter').addBatch({
|
|||||||
log4js.addAppender(
|
log4js.addAppender(
|
||||||
require('../lib/appenders/logLevelFilter')
|
require('../lib/appenders/logLevelFilter')
|
||||||
.appender(
|
.appender(
|
||||||
'ERROR',
|
'ERROR',
|
||||||
function(evt) { logEvents.push(evt); }
|
function(evt) { logEvents.push(evt); }
|
||||||
),
|
),
|
||||||
"logLevelTest"
|
"logLevelTest"
|
||||||
);
|
);
|
||||||
|
|
||||||
logger = log4js.getLogger("logLevelTest");
|
logger = log4js.getLogger("logLevelTest");
|
||||||
logger.debug('this should not trigger an event');
|
logger.debug('this should not trigger an event');
|
||||||
logger.warn('neither should this');
|
logger.warn('neither should this');
|
||||||
@ -45,10 +45,10 @@ vows.describe('log4js logLevelFilter').addBatch({
|
|||||||
topic: function() {
|
topic: function() {
|
||||||
var log4js = require('../lib/log4js')
|
var log4js = require('../lib/log4js')
|
||||||
, logger;
|
, logger;
|
||||||
|
|
||||||
remove(__dirname + '/logLevelFilter.log');
|
remove(__dirname + '/logLevelFilter.log');
|
||||||
remove(__dirname + '/logLevelFilter-warnings.log');
|
remove(__dirname + '/logLevelFilter-warnings.log');
|
||||||
|
|
||||||
log4js.configure('test/with-logLevelFilter.json');
|
log4js.configure('test/with-logLevelFilter.json');
|
||||||
logger = log4js.getLogger("tests");
|
logger = log4js.getLogger("tests");
|
||||||
logger.info('main');
|
logger.info('main');
|
||||||
@ -56,7 +56,7 @@ vows.describe('log4js logLevelFilter').addBatch({
|
|||||||
logger.warn('both');
|
logger.warn('both');
|
||||||
logger.debug('main');
|
logger.debug('main');
|
||||||
//wait for the file system to catch up
|
//wait for the file system to catch up
|
||||||
setTimeout(this.callback, 100);
|
setTimeout(this.callback, 500);
|
||||||
},
|
},
|
||||||
'tmp-tests.log': {
|
'tmp-tests.log': {
|
||||||
topic: function() {
|
topic: function() {
|
||||||
|
@ -7,7 +7,7 @@ var vows = require('vows')
|
|||||||
|
|
||||||
function setupLogging(category, options) {
|
function setupLogging(category, options) {
|
||||||
var msgs = [];
|
var msgs = [];
|
||||||
|
|
||||||
var fakeMailer = {
|
var fakeMailer = {
|
||||||
createTransport: function (name, options) {
|
createTransport: function (name, options) {
|
||||||
return {
|
return {
|
||||||
@ -49,7 +49,7 @@ function setupLogging(category, options) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
log4js.addAppender(smtpModule.configure(options), category);
|
log4js.addAppender(smtpModule.configure(options), category);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
logger: log4js.getLogger(category),
|
logger: log4js.getLogger(category),
|
||||||
mailer: fakeMailer,
|
mailer: fakeMailer,
|
||||||
@ -150,10 +150,10 @@ vows.describe('log4js smtpAppender').addBatch({
|
|||||||
}, 500);
|
}, 500);
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
setup.logger.info('Log event #3');
|
setup.logger.info('Log event #3');
|
||||||
}, 1050);
|
}, 1100);
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
self.callback(null, setup);
|
self.callback(null, setup);
|
||||||
}, 2100);
|
}, 3000);
|
||||||
},
|
},
|
||||||
'there should be three messages': function (result) {
|
'there should be three messages': function (result) {
|
||||||
assert.equal(result.results.length, 3);
|
assert.equal(result.results.length, 3);
|
||||||
@ -181,13 +181,13 @@ vows.describe('log4js smtpAppender').addBatch({
|
|||||||
}, 0);
|
}, 0);
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
setup.logger.info('Log event #2');
|
setup.logger.info('Log event #2');
|
||||||
}, 500);
|
}, 100);
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
setup.logger.info('Log event #3');
|
setup.logger.info('Log event #3');
|
||||||
}, 1050);
|
}, 1500);
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
self.callback(null, setup);
|
self.callback(null, setup);
|
||||||
}, 2100);
|
}, 3000);
|
||||||
},
|
},
|
||||||
'there should be two messages': function (result) {
|
'there should be two messages': function (result) {
|
||||||
assert.equal(result.results.length, 2);
|
assert.equal(result.results.length, 2);
|
||||||
@ -218,7 +218,7 @@ vows.describe('log4js smtpAppender').addBatch({
|
|||||||
close: function() { }
|
close: function() { }
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
setup.logger.info("This will break");
|
setup.logger.info("This will break");
|
||||||
return setup.console;
|
return setup.console;
|
||||||
},
|
},
|
||||||
@ -228,6 +228,4 @@ vows.describe('log4js smtpAppender').addBatch({
|
|||||||
assert.equal(cons.errors[0].value.message, 'oh noes');
|
assert.equal(cons.errors[0].value.message, 'oh noes');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}).export(module);
|
}).export(module);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user