This repository was archived by the owner on Dec 10, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +58
-3
lines changed Expand file tree Collapse file tree 3 files changed +58
-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 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' , ( t ) => {
6+ const file = require . resolve ( '../../dist/bin/cli.js' )
7+ const child = spawn ( process . execPath , [ file ] )
8+
9+ const timeout = setTimeout ( ( ) => {
10+ child . kill ( 'SIGINT' )
11+ } , 120000 )
12+
13+ const end = ( ) => {
14+ clearTimeout ( timeout )
15+ child . kill ( 'SIGINT' )
16+ t . end ( )
17+ }
18+
19+ child . stdout . on ( 'data' , ( data ) => {
20+ const message = data . toString ( )
21+ if ( message . toLowerCase ( ) . includes ( 'error' ) ) {
22+ t . fail ( message )
23+ end ( )
24+ }
25+ if ( message . includes ( 'Imported blocks' ) ) {
26+ t . pass ( )
27+ end ( )
28+ }
29+ console . log ( message ) // eslint-disable-line no-console
30+ } )
31+
32+ child . stderr . on ( 'data' , ( data ) => {
33+ const message = data . toString ( )
34+ t . fail ( message )
35+ end ( )
36+ } )
37+
38+ child . on ( 'close' , ( code ) => {
39+ if ( code !== 0 ) {
40+ t . fail ( `child process exited with code ${ code } ` )
41+ end ( )
42+ }
43+ } )
44+ } )
45+ } )
You can’t perform that action at this time.
0 commit comments