mirror of
https://github.com/log4js-node/log4js-node.git
synced 2025-12-08 19:26:01 +00:00
Merge pull request #1306 from log4js-node/update-test
test: extended timeout interval for OS operations
This commit is contained in:
commit
ea60ad0fd8
@ -8,6 +8,8 @@ const format = require('date-format');
|
||||
const sandbox = require('@log4js-node/sandboxed-module');
|
||||
const log4js = require('../../lib/log4js');
|
||||
|
||||
const osDelay = process.platform === 'win32' ? 400 : 200;
|
||||
|
||||
function removeFile(filename) {
|
||||
try {
|
||||
fs.unlinkSync(path.join(__dirname, filename));
|
||||
@ -40,7 +42,7 @@ test('../../lib/appenders/dateFile', (batch) => {
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
}, 100);
|
||||
}, osDelay);
|
||||
});
|
||||
|
||||
batch.test('configure with dateFileAppender', (t) => {
|
||||
|
||||
@ -3,6 +3,8 @@ const fs = require('fs');
|
||||
const path = require('path');
|
||||
const log4js = require('../../lib/log4js');
|
||||
|
||||
const osDelay = process.platform === 'win32' ? 400 : 200;
|
||||
|
||||
const removeFiles = async (filenames) => {
|
||||
if (!Array.isArray(filenames)) filenames = [filenames];
|
||||
const promises = filenames.map((filename) => fs.promises.unlink(filename));
|
||||
@ -46,7 +48,7 @@ if (process.platform !== 'win32') {
|
||||
`file descriptor count should increase by ${numOfAppenders} after 1st configure() call`
|
||||
);
|
||||
t.end();
|
||||
}, 250);
|
||||
}, osDelay);
|
||||
}
|
||||
);
|
||||
|
||||
@ -65,7 +67,7 @@ if (process.platform !== 'win32') {
|
||||
`file descriptor count should be identical after repeated configure() calls`
|
||||
);
|
||||
t.end();
|
||||
}, 250);
|
||||
}, osDelay);
|
||||
}
|
||||
);
|
||||
|
||||
@ -82,7 +84,7 @@ if (process.platform !== 'win32') {
|
||||
`file descriptor count should be back to initial`
|
||||
);
|
||||
t.end();
|
||||
}, 250);
|
||||
}, osDelay);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@ -3,6 +3,8 @@ const path = require('path');
|
||||
const fs = require('fs');
|
||||
const sandbox = require('@log4js-node/sandboxed-module');
|
||||
|
||||
const osDelay = process.platform === 'win32' ? 400 : 200;
|
||||
|
||||
const removeFiles = async (filenames) => {
|
||||
if (!Array.isArray(filenames)) filenames = [filenames];
|
||||
const promises = filenames.map((filename) => fs.promises.unlink(filename));
|
||||
@ -129,7 +131,7 @@ test('file appender SIGHUP', (t) => {
|
||||
t.equal(openCalled, 2, 'open should be called twice');
|
||||
t.equal(closeCalled, 1, 'close should be called once');
|
||||
t.end();
|
||||
}, 100);
|
||||
}, osDelay);
|
||||
});
|
||||
|
||||
test('file appender SIGHUP handler leak', (t) => {
|
||||
|
||||
@ -7,6 +7,8 @@ const sandbox = require('@log4js-node/sandboxed-module');
|
||||
const zlib = require('zlib');
|
||||
const util = require('util');
|
||||
|
||||
const osDelay = process.platform === 'win32' ? 400 : 200;
|
||||
|
||||
const sleep = util.promisify(setTimeout);
|
||||
const gunzip = util.promisify(zlib.gunzip);
|
||||
const EOL = require('os').EOL || '\n';
|
||||
@ -40,7 +42,7 @@ test('log4js fileAppender', (batch) => {
|
||||
|
||||
logger.info('This should be in the file.');
|
||||
|
||||
await sleep(250);
|
||||
await sleep(osDelay);
|
||||
const fileContents = await fs.readFile(testFile, 'utf8');
|
||||
t.match(fileContents, `This should be in the file.${EOL}`);
|
||||
t.match(
|
||||
@ -151,7 +153,7 @@ test('log4js fileAppender', (batch) => {
|
||||
logger.info('This is an intermediate log message.');
|
||||
logger.info('This is the second log message.');
|
||||
// wait for the file system to catch up
|
||||
await sleep(250);
|
||||
await sleep(osDelay * 2);
|
||||
const fileContents = await fs.readFile(testFile, 'utf8');
|
||||
t.match(fileContents, 'This is the second log message.');
|
||||
t.equal(fileContents.indexOf('This is the first log message.'), -1);
|
||||
@ -219,7 +221,7 @@ test('log4js fileAppender', (batch) => {
|
||||
logger.info('This is the second log message.');
|
||||
|
||||
// wait for the file system to catch up
|
||||
await sleep(250);
|
||||
await sleep(osDelay);
|
||||
const fileContents = await fs.readFile(testFile, 'utf8');
|
||||
t.match(fileContents, 'This is the second log message.');
|
||||
t.notMatch(fileContents, 'These are the log messages for the first file.');
|
||||
@ -272,7 +274,7 @@ test('log4js fileAppender', (batch) => {
|
||||
logger.info('This is the third log message.');
|
||||
logger.info('This is the fourth log message.');
|
||||
// give the system a chance to open the stream
|
||||
await sleep(250);
|
||||
await sleep(osDelay);
|
||||
const files = await fs.readdir(__dirname);
|
||||
const logFiles = files
|
||||
.sort()
|
||||
@ -334,7 +336,7 @@ test('log4js fileAppender', (batch) => {
|
||||
logger.info('This is the third log message.');
|
||||
logger.info('This is the fourth log message.');
|
||||
// give the system a chance to open the stream
|
||||
await sleep(250);
|
||||
await sleep(osDelay);
|
||||
const files = await fs.readdir(__dirname);
|
||||
const logFiles = files
|
||||
.sort()
|
||||
@ -503,7 +505,7 @@ test('log4js fileAppender', (batch) => {
|
||||
[]
|
||||
);
|
||||
|
||||
await sleep(250);
|
||||
await sleep(osDelay);
|
||||
let fileContents = await fs.readFile(testFilePlain, 'utf8');
|
||||
t.match(
|
||||
fileContents,
|
||||
|
||||
@ -4,6 +4,8 @@ const os = require('os');
|
||||
|
||||
const EOL = os.EOL || '\n';
|
||||
|
||||
const osDelay = process.platform === 'win32' ? 400 : 200;
|
||||
|
||||
function remove(filename) {
|
||||
try {
|
||||
fs.unlinkSync(filename);
|
||||
@ -155,7 +157,7 @@ test('log4js logLevelFilter', (batch) => {
|
||||
}
|
||||
);
|
||||
t.end();
|
||||
}, 500);
|
||||
}, osDelay);
|
||||
});
|
||||
|
||||
batch.end();
|
||||
|
||||
@ -226,7 +226,7 @@ test('multiFile appender', (batch) => {
|
||||
debug.enable(originalNamespace);
|
||||
});
|
||||
|
||||
const timeoutMs = 100;
|
||||
const timeoutMs = 200;
|
||||
log4js.configure({
|
||||
appenders: {
|
||||
multi: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user