22// This verifies that the server-side stuff still works.
33
44var common = require ( '../common-tap' )
5- var test = require ( 'tap' ) . test
5+ var t = require ( 'tap' )
66
77var npmExec = require . resolve ( '../../bin/npm-cli.js' )
88var path = require ( 'path' )
@@ -17,16 +17,15 @@ if (v[0] === 0 && v[1] < 10) {
1717process . versions . node
1818)
1919} 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+ }
2726}
2827
29- function runTests ( ) {
28+ function runTests ( t ) {
3029var env = Object . assign ( { TAP : 1 } , process . env )
3130env . npm = npmExec
3231// TODO: fix tap and / or nyc to handle nested invocations properly
@@ -39,10 +38,8 @@ function runTests () {
3938common . npm ( [ 'install' ] , opts , function ( err , code ) {
4039if ( err ) { throw err }
4140if ( 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 ( )
4643} else {
4744opts = {
4845cwd : ca ,
@@ -52,19 +49,18 @@ function runTests () {
5249common . npm ( [ 'test' , '--' , '-Rtap' , '--no-coverage' ] , opts , function ( err , code ) {
5350if ( err ) { throw err }
5451if ( 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 ( )
5954}
6055opts = {
6156cwd : ca ,
6257env : env ,
6358stdio : 'inherit'
6459}
6560common . 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 ( )
6864} )
6965} )
7066}
0 commit comments