Skip to content

Commit

Permalink
fix: fix execArgv not work in cov
Browse files Browse the repository at this point in the history
  • Loading branch information
killagu committed Feb 20, 2024
1 parent 25fb32c commit b54500f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/cmd/cov.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,20 @@ class CovCommand extends Command {
}
const testArgs = await this.formatTestArgs(context);
if (!testArgs) return;
covArgs.push(...this.getTestCommandAndArgs());
covArgs.push(...this.getTestCommandAndArgs(context));
covArgs = covArgs.concat(testArgs);
return covArgs;
}

getTestCommandAndArgs() {
getTestCommandAndArgs(context) {
const node = process.execPath;
const execArgv = context.execArgv;
const mochaFile = process.env.MOCHA_FILE || require.resolve('mocha/bin/_mocha');
return [ mochaFile ];
return [
node,
...execArgv,
mochaFile,
];
}
}

Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/egg-revert/test/index.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
const assert = require('assert');

describe('test/index.test.js', () => {
it('should test', () => {
// test
assert(process.execArgv.includes('--security-revert=CVE-2023-46809'));
});
});
14 changes: 14 additions & 0 deletions test/lib/cmd/cov.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const path = require('path');
const assert = require('assert');
const coffee = require('coffee');
const mm = require('mm');
const version = Number(process.version.substring(1, 3));

describe('test/lib/cmd/cov.test.js', () => {
const eggBin = require.resolve('../../../bin/egg-bin.js');
Expand Down Expand Up @@ -206,4 +207,17 @@ describe('test/lib/cmd/cov.test.js', () => {
.expect('code', 0)
.end();
});

it('should support egg.revert', () => {
if (version < 18) return;
mm(process.env, 'NODE_ENV', 'development');
return coffee.fork(eggBin, [ 'cov' ], {
cwd: path.join(__dirname, '../../fixtures/egg-revert'),
})
.debug()
.expect('stdout', /SECURITY WARNING: Reverting CVE-2023-46809: Marvin attack on PKCS#1 padding/)
.expect('stdout', /1 passing/)
.expect('code', 0)
.end();
});
});

0 comments on commit b54500f

Please sign in to comment.