diff --git a/test/tap/dateFileAppender-test.js b/test/tap/dateFileAppender-test.js index 3f6ca213..a14f1abf 100644 --- a/test/tap/dateFileAppender-test.js +++ b/test/tap/dateFileAppender-test.js @@ -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) => { diff --git a/test/tap/file-descriptor-leak-test.js b/test/tap/file-descriptor-leak-test.js index 2a1b9373..8e97aeaa 100644 --- a/test/tap/file-descriptor-leak-test.js +++ b/test/tap/file-descriptor-leak-test.js @@ -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); } ); diff --git a/test/tap/file-sighup-test.js b/test/tap/file-sighup-test.js index aa1d2627..8f6a5f5b 100644 --- a/test/tap/file-sighup-test.js +++ b/test/tap/file-sighup-test.js @@ -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) => { diff --git a/test/tap/fileAppender-test.js b/test/tap/fileAppender-test.js index b9d03ec9..10626f4b 100644 --- a/test/tap/fileAppender-test.js +++ b/test/tap/fileAppender-test.js @@ -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, diff --git a/test/tap/logLevelFilter-test.js b/test/tap/logLevelFilter-test.js index aebf8b4a..0b19519e 100644 --- a/test/tap/logLevelFilter-test.js +++ b/test/tap/logLevelFilter-test.js @@ -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(); diff --git a/test/tap/multi-file-appender-test.js b/test/tap/multi-file-appender-test.js index 42f5959c..34fa2922 100644 --- a/test/tap/multi-file-appender-test.js +++ b/test/tap/multi-file-appender-test.js @@ -226,7 +226,7 @@ test('multiFile appender', (batch) => { debug.enable(originalNamespace); }); - const timeoutMs = 100; + const timeoutMs = 200; log4js.configure({ appenders: { multi: {