This repository was archived by the owner on Dec 10, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +61
-3
lines changed Expand file tree Collapse file tree 4 files changed +61
-3
lines changed Original file line number Diff line number Diff line change 3535 - uses : actions/checkout@v2
3636 - run : npm install
3737 - run : npm run test:browser
38+ test-cli :
39+ runs-on : ubuntu-latest
40+ steps :
41+ - uses : actions/setup-node@v1
42+ with :
43+ node-version : 12.x
44+ - uses : actions/checkout@v2
45+ - run : npm install
46+ - run : npm run test:cli
Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ module.exports = function (config) {
44
55 files : [ 'test/**/*.ts' , 'lib/**/*.ts' ] ,
66
7+ exclude : [ 'test/integration/**/*.ts' , 'test/cli/**/*.ts' ] ,
8+
79 preprocessors : {
810 '**/*.ts' : [ 'karma-typescript' ]
911 } ,
Original file line number Diff line number Diff line change 1717 "build:node" : " tsc -p ./tsconfig.prod.json" ,
1818 "build:browser" : " tsc -p ./tsconfig.browser.json && npm run bundle && rm -rf dist.browser" ,
1919 "bundle" : " webpack" ,
20- "client:start" : " tsc -p tsconfig.prod.json && node dist/ bin/cli.js " ,
20+ "client:start" : " ts- node bin/cli.ts " ,
2121 "coverage" : " nyc npm run coverage:test && nyc report --reporter=lcov" ,
22- "coverage:test" : " tape -r ts-node/register 'test/!(integration)/**/*.ts' 'test/integration/**/*.ts'" ,
22+ "coverage:test" : " npm run tape -- 'test/!(integration|cli )/**/*.ts' 'test/integration/**/*.ts'" ,
2323 "docs:build" : " typedoc --tsconfig tsconfig.prod.json" ,
2424 "lint" : " ethereumjs-config-lint" ,
2525 "lint:fix" : " ethereumjs-config-lint-fix" ,
2626 "tape" : " tape -r ts-node/register" ,
2727 "test" : " npm run test:unit && npm run test:integration" ,
28- "test:unit" : " npm run tape -- 'test/!(integration)/**/*.ts'" ,
28+ "test:unit" : " npm run tape -- 'test/!(integration|cli )/**/*.ts'" ,
2929 "test:integration" : " npm run tape -- 'test/integration/**/*.ts'" ,
30+ "test:cli" : " npm run build:node && npm run tape -- 'test/cli/*.ts'" ,
3031 "test:browser" : " karma start karma.conf.js"
3132 },
3233 "husky" : {
Original file line number Diff line number Diff line change 1+ import tape from 'tape'
2+ import { spawn } from 'child_process'
3+
4+ tape ( '[CLI]' , ( t ) => {
5+ t . test ( 'should start and begin downloading blocks' , { timeout : 160000 } , ( t ) => {
6+ t . plan ( 1 )
7+ const file = require . resolve ( '../../dist/bin/cli.js' )
8+ const child = spawn ( process . execPath , [ file ] )
9+
10+ const timeout = setTimeout ( ( ) => {
11+ child . kill ( 'SIGINT' )
12+ } , 120000 )
13+
14+ const end = ( ) => {
15+ clearTimeout ( timeout )
16+ child . kill ( 'SIGINT' )
17+ t . end ( )
18+ }
19+
20+ child . stdout . on ( 'data' , ( data ) => {
21+ const message = data . toString ( )
22+ if ( message . toLowerCase ( ) . includes ( 'error' ) ) {
23+ t . fail ( message )
24+ end ( )
25+ }
26+ if ( message . includes ( 'Imported blocks' ) ) {
27+ t . pass ( 'successfully imported blocks' )
28+ end ( )
29+ }
30+ console . log ( message ) // eslint-disable-line no-console
31+ } )
32+
33+ child . stderr . on ( 'data' , ( data ) => {
34+ const message = data . toString ( )
35+ t . fail ( message )
36+ end ( )
37+ } )
38+
39+ child . on ( 'close' , ( code ) => {
40+ if ( code !== 0 ) {
41+ t . fail ( `child process exited with code ${ code } ` )
42+ end ( )
43+ }
44+ } )
45+ } )
46+ } )
You can’t perform that action at this time.
0 commit comments