@@ -21,16 +21,20 @@ suite('Bundled LiquidJava extension', () => {
2121 const file = passing ? 'PassingRefinement.java' : 'FailingRefinement.java' ;
2222 const uri = vscode . Uri . joinPath ( workspace . uri , `src/main/java/${ file } ` ) ;
2323 const subscriptions : vscode . Disposable [ ] = [ ] ;
24- const nextFixtureDiagnostics = ( ) => new Promise < LJDiagnostic [ ] > ( ( resolve ) => {
25- const subscription = api . onDiagnostics ( ( diagnostics ) => {
26- const matches = passing ? diagnostics . length === 0
27- : diagnostics . some ( d => d . type === 'refinement-error' && vscode . Uri . file ( path . resolve ( d . file ) ) . fsPath === uri . fsPath ) ;
28- if ( matches ) {
29- subscription . dispose ( ) ;
30- resolve ( diagnostics ) ;
31- }
24+ const nextFixtureDiagnostics = ( ) => new Promise < LJDiagnostic [ ] > ( ( resolve , reject ) => {
25+ const dispose = ( ) => {
26+ diagnosticsSubscription . dispose ( ) ;
27+ failureSubscription . dispose ( ) ;
28+ } ;
29+ const diagnosticsSubscription = api . onDiagnostics ( ( diagnostics ) => {
30+ dispose ( ) ;
31+ resolve ( diagnostics ) ;
3232 } ) ;
33- subscriptions . push ( subscription ) ;
33+ const failureSubscription = api . onFailure ( ( ) => {
34+ dispose ( ) ;
35+ reject ( new Error ( `LiquidJava verifier crashed while checking ${ file } (status: ${ api . getState ( ) . status } )` ) ) ;
36+ } ) ;
37+ subscriptions . push ( diagnosticsSubscription , failureSubscription ) ;
3438 } ) ;
3539 try {
3640 // settle automatic verification before testing the manual command
@@ -47,7 +51,7 @@ suite('Bundled LiquidJava extension', () => {
4751 assert . equal ( api . getState ( ) . status , 'passed' ) ;
4852 } else {
4953 const error = diagnostics . find ( d => d . type === 'refinement-error' && vscode . Uri . file ( path . resolve ( d . file ) ) . fsPath === uri . fsPath ) ;
50- assert . ok ( error ) ;
54+ assert . ok ( error , `expected a refinement error for ${ file } ; received ${ JSON . stringify ( diagnostics ) } ` ) ;
5155 assert . equal ( error . category , 'error' ) ;
5256 assert . equal ( error . title , 'Refinement Error' ) ;
5357 assert . ok ( error . position , 'the diagnostic must identify the invalid assignment' ) ;
0 commit comments