Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix execArgv not work in cov #254

Merged
merged 3 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
});
});
Loading