Make some test windows friendly.

cdb
Pavel Sysolyatin 10 years ago
parent eaa77b0454
commit 3c4c98bb0b

@ -2,7 +2,8 @@
var vows = require('vows')
, fs = require('fs')
, assert = require('assert');
, assert = require('assert')
, EOL = require('os').EOL || '\n';
function remove(filename) {
try {
@ -66,7 +67,7 @@ vows.describe('log4js categoryFilter').addBatch({
fs.readFile(__dirname + '/categoryFilter-noweb.log', 'utf8', this.callback);
},
'should contain all log messages': function(contents) {
var messages = contents.trim().split('\n');
var messages = contents.trim().split(EOL);
assert.deepEqual(messages, ['Loading app','Initialising indexes']);
}
},
@ -75,7 +76,7 @@ vows.describe('log4js categoryFilter').addBatch({
fs.readFile(__dirname + '/categoryFilter-web.log','utf8',this.callback);
},
'should contain only error and warning log messages': function(contents) {
var messages = contents.trim().split('\n');
var messages = contents.trim().split(EOL);
assert.deepEqual(messages, ['00:00:00 GET / 200','00:00:00 GET / 500']);
}
}

@ -186,7 +186,7 @@ vows.describe('../lib/appenders/dateFile').addBatch({
}
},
'with cwd option': {
topic: function() {
topic: function () {
var fileOpened,
appender = sandbox.require(
'../lib/appenders/dateFile',
@ -213,8 +213,9 @@ vows.describe('../lib/appenders/dateFile').addBatch({
);
return fileOpened;
},
'should prepend options.cwd to config.filename': function(fileOpened) {
assert.equal(fileOpened, "/absolute/path/to/whatever.log");
'should prepend options.cwd to config.filename': function (fileOpened) {
var expected = path.sep + path.join("absolute", "path", "to", "whatever.log");
assert.equal(fileOpened, expected);
}
}

@ -4,7 +4,8 @@ var vows = require('vows')
, path = require('path')
, sandbox = require('sandboxed-module')
, log4js = require('../lib/log4js')
, assert = require('assert');
, assert = require('assert')
, EOL = require('os').EOL || '\n';
log4js.clearAppenders();
@ -93,8 +94,8 @@ vows.describe('log4js fileAppender').addBatch({
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");
'should write log messages to the file': function (err, fileContents) {
assert.include(fileContents, "This should be in the file." + EOL);
},
'log messages should be in the basic layout format': function(err, fileContents) {
assert.match(
@ -125,7 +126,7 @@ vows.describe('log4js fileAppender').addBatch({
}, 100);
},
'log file should only contain the second message': function(err, fileContents) {
assert.include(fileContents, "This is the second log message.\n");
assert.include(fileContents, "This is the second log message.");
assert.equal(fileContents.indexOf("This is the first log message."), -1);
},
'the number of files': {
@ -229,8 +230,8 @@ vows.describe('log4js fileAppender').addBatch({
fs.readFile('tmp-tests.log', 'utf8', this.callback);
},
'should load appender configuration from a json file': function(err, contents) {
assert.include(contents, 'this should be written to the file\n');
'should load appender configuration from a json file': function (err, contents) {
assert.include(contents, 'this should be written to the file' + EOL);
assert.equal(contents.indexOf('this should not be written to the file'), -1);
}
}

@ -4,7 +4,8 @@ var vows = require('vows')
, path = require('path')
, sandbox = require('sandboxed-module')
, log4js = require('../lib/log4js')
, assert = require('assert');
, assert = require('assert')
, EOL = require('os').EOL || '\n';
log4js.clearAppenders();
@ -31,8 +32,8 @@ vows.describe('log4js fileSyncAppender').addBatch({
fs.readFile(testFile, "utf8", that.callback);
},
'should write log messages to the file': function(err, fileContents) {
assert.include(fileContents, "This should be in the file.\n");
'should write log messages to the file': function (err, fileContents) {
assert.include(fileContents, "This should be in the file." + EOL);
},
'log messages should be in the basic layout format': function(err, fileContents) {
assert.match(
@ -60,8 +61,8 @@ vows.describe('log4js fileSyncAppender').addBatch({
fs.readFile(testFile, "utf8", that.callback);
},
'log file should only contain the second message': function(err, fileContents) {
assert.include(fileContents, "This is the second log message.\n");
'log file should only contain the second message': function (err, fileContents) {
assert.include(fileContents, "This is the second log message." + EOL);
assert.equal(fileContents.indexOf("This is the first log message."), -1);
},
'the number of files': {
@ -173,7 +174,7 @@ vows.describe('log4js fileSyncAppender').addBatch({
fs.readFile('tmp-sync-tests.log', 'utf8', this.callback);
},
'should load appender configuration from a json file': function(err, contents) {
assert.include(contents, 'this should be written to the file\n');
assert.include(contents, 'this should be written to the file' + EOL);
assert.equal(contents.indexOf('this should not be written to the file'), -1);
}
}

@ -1,6 +1,8 @@
"use strict";
var vows = require('vows')
, assert = require('assert');
, assert = require('assert')
, os = require('os')
, EOL = os.EOL || '\n';
//used for patternLayout tests.
function test(args, pattern, value) {
@ -195,7 +197,7 @@ vows.describe('log4js layouts').addBatch({
},
'should default to "time logLevel loggerName - message"': function(args) {
test(args, null, "14:18:30 DEBUG multiple.levels.of.tests - this is a test\n");
test(args, null, "14:18:30 DEBUG multiple.levels.of.tests - this is a test" + EOL);
},
'%r should output time only': function(args) {
test(args, '%r', '14:18:30');
@ -210,10 +212,10 @@ vows.describe('log4js layouts').addBatch({
test(args, '%m', 'this is a test');
},
'%n should output a new line': function(args) {
test(args, '%n', '\n');
test(args, '%n', EOL);
},
'%h should output hostname' : function(args) {
test(args, '%h', require('os').hostname().toString());
test(args, '%h', os.hostname().toString());
},
'%c should handle category names like java-style package names': function(args) {
test(args, '%c{1}', 'tests');
@ -247,7 +249,7 @@ vows.describe('log4js layouts').addBatch({
'should handle complicated patterns': function(args) {
test(args,
'%m%n %c{2} at %d{ABSOLUTE} cheese %p%n',
'this is a test\n of.tests at 14:18:30.045 cheese DEBUG\n'
'this is a test'+ EOL +' of.tests at 14:18:30.045 cheese DEBUG' + EOL
);
},
'should truncate fields if specified': function(args) {

@ -1,6 +1,7 @@
"use strict";
var vows = require('vows')
, assert = require('assert')
, path = require('path')
, sandbox = require('sandboxed-module');
vows.describe('log4js-abspath').addBatch({
@ -69,7 +70,8 @@ vows.describe('log4js-abspath').addBatch({
return fileOpened;
},
'should prepend options.cwd to config.filename': function(fileOpened) {
assert.equal(fileOpened, "/absolute/path/to/whatever.log");
var expected = path.sep + path.join("absolute", "path", "to", "whatever.log");
assert.equal(fileOpened, expected);
}
},
}).export(module);

@ -1,7 +1,9 @@
"use strict";
var vows = require('vows')
, fs = require('fs')
, assert = require('assert');
, assert = require('assert')
, os = require('os')
, EOL = require('os').EOL || '\n';
function remove(filename) {
try {
@ -60,8 +62,8 @@ vows.describe('log4js logLevelFilter').addBatch({
topic: function() {
fs.readFile(__dirname + '/logLevelFilter.log', 'utf8', this.callback);
},
'should contain all log messages': function(contents) {
var messages = contents.trim().split('\n');
'should contain all log messages': function (contents) {
var messages = contents.trim().split(EOL);
assert.deepEqual(messages, ['main','both','both','main']);
}
},
@ -70,7 +72,7 @@ vows.describe('log4js logLevelFilter').addBatch({
fs.readFile(__dirname + '/logLevelFilter-warnings.log','utf8',this.callback);
},
'should contain only error and warning log messages': function(contents) {
var messages = contents.trim().split('\n');
var messages = contents.trim().split(EOL);
assert.deepEqual(messages, ['both','both']);
}
}

Loading…
Cancel
Save