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 all commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ test/fixtures/ts/node_modules/aliyun-egg/
!test/fixtures/test-files-stack/node_modules/
!test/fixtures/example/node_modules/
!test/fixtures/example-ts-cluster/node_modules/
!test/fixtures/egg-revert/node_modules/
!test/fixtures/example-ts-error-stack/node_modules/
!test/fixtures/egg-require/node_modules/
test/fixtures/example-ts-ets/typings/
Expand Down
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
15 changes: 15 additions & 0 deletions test/fixtures/egg-revert/node_modules/aliyun-egg/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions test/fixtures/egg-revert/node_modules/aliyun-egg/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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();
});
});
2 changes: 1 addition & 1 deletion test/lib/cmd/dev.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ describe('test/lib/cmd/dev.test.js', () => {
return coffee.fork(eggBin, [ 'dev' ], {
cwd: path.join(__dirname, '../../fixtures/egg-revert'),
})
// .debug()
.debug()
.expect('stdout', /SECURITY WARNING: Reverting CVE-2023-46809: Marvin attack on PKCS#1 padding/)
.expect('code', 0)
.end();
Expand Down
Loading