This repository was archived by the owner on Dec 10, 2020. It is now read-only.
File tree 4 files changed +61
-3
lines changed
4 files changed +61
-3
lines changed Original file line number Diff line number Diff line change 35
35
- uses : actions/checkout@v2
36
36
- run : npm install
37
37
- 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) {
4
4
5
5
files : [ 'test/**/*.ts' , 'lib/**/*.ts' ] ,
6
6
7
+ exclude : [ 'test/integration/**/*.ts' , 'test/cli/**/*.ts' ] ,
8
+
7
9
preprocessors : {
8
10
'**/*.ts' : [ 'karma-typescript' ]
9
11
} ,
Original file line number Diff line number Diff line change 17
17
"build:node" : " tsc -p ./tsconfig.prod.json" ,
18
18
"build:browser" : " tsc -p ./tsconfig.browser.json && npm run bundle && rm -rf dist.browser" ,
19
19
"bundle" : " webpack" ,
20
- "client:start" : " tsc -p tsconfig.prod.json && node dist/ bin/cli.js " ,
20
+ "client:start" : " ts- node bin/cli.ts " ,
21
21
"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'" ,
23
23
"docs:build" : " typedoc --tsconfig tsconfig.prod.json" ,
24
24
"lint" : " ethereumjs-config-lint" ,
25
25
"lint:fix" : " ethereumjs-config-lint-fix" ,
26
26
"tape" : " tape -r ts-node/register" ,
27
27
"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'" ,
29
29
"test:integration" : " npm run tape -- 'test/integration/**/*.ts'" ,
30
+ "test:cli" : " npm run build:node && npm run tape -- 'test/cli/*.ts'" ,
30
31
"test:browser" : " karma start karma.conf.js"
31
32
},
32
33
"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