Skip to content

Commit

Permalink
chore: improve cov
Browse files Browse the repository at this point in the history
  • Loading branch information
atian25 committed Aug 30, 2017
1 parent 4114186 commit 37c9964
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 14 deletions.
11 changes: 9 additions & 2 deletions lib/cmd/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,21 @@ class DebugCommand extends Command {
// set default to empty so `--inspect` will always pass to fork
inspect: {
description: 'V8 Inspector port',
default: newDebugger ? '' : undefined,
default() {
/* istanbul ignore next */
return newDebugger ? '' : undefined;
},
},
'inspect-brk': {
description: 'whether break at start',
},

debug: {
description: 'legacy debugger',
default: newDebugger ? undefined : '',
default() {
/* istanbul ignore next */
return newDebugger ? undefined : '';
},
},
};
process.env.EGG_DEBUG = 'true';
Expand Down
1 change: 0 additions & 1 deletion lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class Command extends BaseCommand {

// remove unuse args
argv.$0 = undefined;
argv.v = undefined;

return context;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"autod": "^2.9.0",
"change-case": "^3.0.1",
"co-mocha": "^1.2.0",
"common-bin": "^2.6.0",
"common-bin": "^2.6.1",
"debug": "^3.0.1",
"detect-port": "^1.2.1",
"egg-utils": "^2.2.0",
Expand Down
13 changes: 11 additions & 2 deletions test/lib/cmd/autod.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,19 @@ const coffee = require('coffee');
const eggBin = require.resolve('../../../bin/egg-bin.js');

describe('test/lib/cmd/autod.test.js', () => {
it('should autod modify', function* () {
const cwd = path.join(__dirname, '../../fixtures/autod-missing');
yield coffee.fork(eggBin, [ 'autod' ], { cwd })
// .debug()
.expect('stdout', /"urllib": "\d+.\d+.\d+/)
.expect('code', 0)
.end();
});

it('should autod check fail', function* () {
const cwd = path.join(__dirname, '../../fixtures/autod-missing');
yield coffee.fork(eggBin, [ 'autod', '--check' ], { cwd })
.debug()
// .debug()
.expect('code', 1)
.expect('stderr', /\[ERROR\] Missing dependencies: \["urllib"\]/)
.end();
Expand All @@ -18,7 +27,7 @@ describe('test/lib/cmd/autod.test.js', () => {
it('should autod check pass', function* () {
const cwd = path.join(__dirname, '../../fixtures/autod-exists');
yield coffee.fork(eggBin, [ 'autod', '--check' ], { cwd })
.debug()
// .debug()
.expect('code', 0)
.end();
});
Expand Down
11 changes: 4 additions & 7 deletions test/lib/cmd/cov.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('test/lib/cmd/cov.test.js', () => {
mm(process.env, 'TESTS', 'test/**/*.test.js');
mm(process.env, 'NYC_CWD', cwd);
const child = coffee.fork(eggBin, [ 'cov' ], { cwd })
.debug()
// .debug()
.beforeScript(path.join(__dirname, 'mock-win32.js'))
.expect('stdout', /should success/)
.expect('stdout', /a\.test\.js/)
Expand Down Expand Up @@ -79,8 +79,7 @@ describe('test/lib/cmd/cov.test.js', () => {
child.expect('stdout', /Statements {3}: 75% \( 3[\/|\\]4 \)/);
}

yield child.expect('code', 0)
.end();
yield child.expect('code', 0).end();
assert(fs.existsSync(path.join(cwd, 'coverage/coverage-final.json')));
assert(fs.existsSync(path.join(cwd, 'coverage/lcov-report/index.html')));
assert(fs.existsSync(path.join(cwd, 'coverage/lcov.info')));
Expand All @@ -101,8 +100,7 @@ describe('test/lib/cmd/cov.test.js', () => {
child.expect('stdout', /Statements {3}: 75% \( 3[\/|\\]4 \)/);
}

yield child.expect('code', 0)
.end();
yield child.expect('code', 0).end();
assert(fs.existsSync(path.join(cwd, 'coverage/coverage-final.json')));
assert(fs.existsSync(path.join(cwd, 'coverage/lcov-report/index.html')));
assert(fs.existsSync(path.join(cwd, 'coverage/lcov.info')));
Expand All @@ -123,8 +121,7 @@ describe('test/lib/cmd/cov.test.js', () => {
child.expect('stdout', /Statements {3}: 75% \( 3[\/|\\]4 \)/);
}

yield child.expect('code', 0)
.end();
yield child.expect('code', 0).end();
assert(fs.existsSync(path.join(cwd, 'coverage/coverage-final.json')));
assert(fs.existsSync(path.join(cwd, 'coverage/lcov-report/index.html')));
assert(fs.existsSync(path.join(cwd, 'coverage/lcov.info')));
Expand Down
2 changes: 1 addition & 1 deletion test/lib/cmd/debug.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('test/lib/cmd/debug.test.js', () => {
it('should debug with $NODE_DEBUG_OPTION', () => {
const env = Object.assign({}, process.env, { NODE_DEBUG_OPTION: '--inspect=5555' });
return coffee.fork(eggBin, [ 'debug' ], { cwd, env })
.debug()
// .debug()
.expect('stderr', /Debugger listening.*5555/)
.expect('stdout', /"workers":1/)
.expect('code', 0)
Expand Down

0 comments on commit 37c9964

Please sign in to comment.