2
2
// This verifies that the server-side stuff still works.
3
3
4
4
var common = require ( '../common-tap' )
5
- var test = require ( 'tap' ) . test
5
+ var t = require ( 'tap' )
6
6
7
7
var npmExec = require . resolve ( '../../bin/npm-cli.js' )
8
8
var path = require ( 'path' )
@@ -17,16 +17,15 @@ if (v[0] === 0 && v[1] < 10) {
17
17
process . versions . node
18
18
)
19
19
} else {
20
- which ( 'couchdb' , function ( er ) {
21
- if ( er ) {
22
- console . error ( 'WARNING: need couch to run test: ' + er . message )
23
- } else {
24
- runTests ( )
25
- }
26
- } )
20
+ try {
21
+ which . sync ( 'couchdb' )
22
+ t . test ( runTests )
23
+ } catch ( er ) {
24
+ console . error ( 'WARNING: need couch to run test: ' + er . message )
25
+ }
27
26
}
28
27
29
- function runTests ( ) {
28
+ function runTests ( t ) {
30
29
var env = Object . assign ( { TAP : 1 } , process . env )
31
30
env . npm = npmExec
32
31
// TODO: fix tap and / or nyc to handle nested invocations properly
@@ -39,10 +38,8 @@ function runTests () {
39
38
common . npm ( [ 'install' ] , opts , function ( err , code ) {
40
39
if ( err ) { throw err }
41
40
if ( code ) {
42
- return test ( 'need install to work' , function ( t ) {
43
- t . fail ( 'install failed with: ' + code )
44
- t . end ( )
45
- } )
41
+ t . fail ( 'install failed with: ' + code )
42
+ return t . end ( )
46
43
} else {
47
44
opts = {
48
45
cwd : ca ,
@@ -52,19 +49,18 @@ function runTests () {
52
49
common . npm ( [ 'test' , '--' , '-Rtap' , '--no-coverage' ] , opts , function ( err , code ) {
53
50
if ( err ) { throw err }
54
51
if ( code ) {
55
- return test ( 'need test to work' , function ( t ) {
56
- t . fail ( 'test failed with: ' + code )
57
- t . end ( )
58
- } )
52
+ t . fail ( 'test failed with: ' + code )
53
+ return t . end ( )
59
54
}
60
55
opts = {
61
56
cwd : ca ,
62
57
env : env ,
63
58
stdio : 'inherit'
64
59
}
65
60
common . npm ( [ 'prune' , '--production' ] , opts , function ( err , code ) {
66
- if ( err ) { throw err }
67
- process . exit ( code || 0 )
61
+ t . ifError ( err )
62
+ t . equal ( code , 0 )
63
+ return t . end ( )
68
64
} )
69
65
} )
70
66
}
0 commit comments