@@ -9,7 +9,13 @@ async function main() {
9
9
const args = yargs
10
10
. env ( 'CDK_TEST' )
11
11
. usage ( 'Usage: cdk-test' )
12
- . option ( 'force' , { type : 'boolean' , alias : 'f' , desc : 'Force a rebuild' } )
12
+ . option ( 'quick' , { type : 'boolean' , alias : 'q' , desc : `Skip slow tests` , default : false } )
13
+ . option ( 'jsii-diff' , {
14
+ type : 'string' ,
15
+ desc : 'Specify a different jsii-diff executable' ,
16
+ default : require . resolve ( 'jsii-diff/bin/jsii-diff' ) ,
17
+ defaultDescription : 'jsii-diff provided by node dependencies'
18
+ } )
13
19
. option ( 'jest' , {
14
20
type : 'string' ,
15
21
desc : 'Specify a different jest executable' ,
@@ -33,7 +39,7 @@ async function main() {
33
39
const options = cdkBuildOptions ( ) ;
34
40
35
41
if ( options . test ) {
36
- await shell ( options . test , timers ) ;
42
+ await shell ( options . test , { timers } ) ;
37
43
}
38
44
39
45
const testFiles = await unitTestFiles ( ) ;
@@ -43,7 +49,7 @@ async function main() {
43
49
if ( testFiles . length > 0 ) {
44
50
throw new Error ( `Jest is enabled, but ${ testFiles . length } nodeunit tests were found!` ) ;
45
51
}
46
- await shell ( [ args . jest , '--testEnvironment=node' , '--coverage' ] , timers ) ;
52
+ await shell ( [ args . jest , '--testEnvironment=node' , '--coverage' ] , { timers } ) ;
47
53
} else if ( testFiles . length > 0 ) {
48
54
const testCommand : string [ ] = [ ] ;
49
55
@@ -67,12 +73,24 @@ async function main() {
67
73
testCommand . push ( args . nodeunit ) ;
68
74
testCommand . push ( ...testFiles . map ( f => f . path ) ) ;
69
75
70
- await shell ( testCommand , timers ) ;
76
+ await shell ( testCommand , { timers } ) ;
71
77
}
72
78
73
79
// Run integration test if the package has integ test files
74
80
if ( await hasIntegTests ( ) ) {
75
- await shell ( [ 'cdk-integ-assert' ] , timers ) ;
81
+ await shell ( [ 'cdk-integ-assert' ] , { timers } ) ;
82
+ }
83
+
84
+ // Run compatibility check if not disabled (against the latest
85
+ // published version)
86
+ if ( ! args . quick ) {
87
+ try {
88
+ await shell ( [ args [ "jsii-diff" ] , 'npm:' ] , { timers } ) ;
89
+ } catch ( e ) {
90
+ // If there was an exception running jsii-diff, swallow it
91
+ process . stderr . write ( `The package seems to have undergone breaking API changes. Please revise and try to avoid.\n` ) ;
92
+ process . stderr . write ( `(This is just a warning for now but will soon become a build failure.)\n` ) ;
93
+ }
76
94
}
77
95
}
78
96
0 commit comments