Skip to content

Commit

Permalink
test: fix the unstable for windows (#5195)
Browse files Browse the repository at this point in the history
After investigation for a while for windows, it seems we should delay
for about 1 sec before the "assert" can find the actual error logged
into the file.
  • Loading branch information
Wai-Dung committed May 31, 2023
1 parent b40777a commit 36e0989
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions test/lib/core/logger.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ describe('test/lib/core/logger.test.js', () => {
mm.env('local');
app = utils.cluster('apps/logger');
app
// .debug()
// .debug()
.coverage(false)
.expect('stdout', /agent info/)
.expect('stdout', /app info/)
Expand All @@ -171,20 +171,16 @@ describe('test/lib/core/logger.test.js', () => {
});

it('agent and app error should output to common-error.log', done => {
// unstable on Windows, skip it
// https://github.com/eggjs/egg/runs/7977866117?check_suite_focus=true
if (process.platform === 'win32') {
return done();
}
const baseDir = utils.getFilepath('apps/logger');
mm.env('default');
mm(process.env, 'EGG_LOG', 'none');
mm(process.env, 'EGG_HOME', baseDir);
app = utils.cluster('apps/logger');
app
// .debug()
// .debug()
.coverage(false)
.end(err => {
.end(async err => {
await utils.sleep(1000);
assert(!err);
const content = fs.readFileSync(path.join(baseDir, 'logs/logger/common-error.log'), 'utf8');
assert(content.includes('nodejs.Error: agent error'));
Expand Down

0 comments on commit 36e0989

Please sign in to comment.