@@ -274,16 +274,23 @@ ada: Run main - src/test.adb - .${path.sep}obj${path.sep}test${exe}
274274 }
275275 } ) ;
276276
277- test ( 'problemMatchers severities' , async ( ) => {
277+ /**
278+ * Helper function to test problem matchers with compiler messages
279+ */
280+ async function testProblemMatchersWithCompilerMessages (
281+ fileName : string ,
282+ expectedMessages : string ,
283+ ) {
278284 const prov = createAdaTaskProvider ( ) ;
279285 const isWindows = process . platform === 'win32' ;
286+
280287 /**
281- * Run a task that dumps some compiler messages contained in the 'compiler_messages.txt' file.
288+ * Run a task that dumps some compiler messages contained in the specified file.
282289 */
283290 const def : SimpleTaskDef = {
284291 type : 'ada' ,
285292 command : isWindows ? 'type' : 'cat' ,
286- args : [ 'main_with_problem' + path . sep + 'compiler_messages.txt' ] ,
293+ args : [ 'main_with_problem' + path . sep + fileName ] ,
287294 } ;
288295 const task = new vscode . Task (
289296 def ,
@@ -301,12 +308,23 @@ ada: Run main - src/test.adb - .${path.sep}obj${path.sep}test${exe}
301308 /**
302309 * Wait for the problemMatchers
303310 */
304- await new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) ) ;
311+ await new Promise ( ( resolve ) => setTimeout ( resolve , 2000 ) ) ;
305312 const alsDiagnostics : vscode . Diagnostic [ ] = vscode . languages
306313 . getDiagnostics ( )
307314 . flatMap ( ( [ , diagnostics ] ) => diagnostics )
308315 . filter ( ( diag ) => [ 'ada' ] . includes ( diag . source ?? '' ) ) ;
309316
317+ /**
318+ * Extract expected severities from the expected messages for Windows validation
319+ */
320+ const expectedSeverities = expectedMessages
321+ . split ( '\n' )
322+ . map ( ( line ) => {
323+ const match = line . match ( / ^ ( \d + ) : / ) ;
324+ return match ? parseInt ( match [ 1 ] , 10 ) : null ;
325+ } )
326+ . filter ( ( severity ) => severity !== null ) ;
327+
310328 /**
311329 * Check that we have the expected number of diagnostics, with the
312330 * expected severities.
@@ -316,12 +334,20 @@ ada: Run main - src/test.adb - .${path.sep}obj${path.sep}test${exe}
316334 if ( isWindows ) {
317335 assert . deepEqual (
318336 alsDiagnostics . map ( ( d ) => d . severity ) ,
319- [ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 2 , 2 ] ,
337+ expectedSeverities ,
320338 ) ;
321339 } else {
322340 assert . equal (
323341 alsDiagnostics . map ( ( d ) => `${ d . severity } : ${ d . message } ` ) . join ( '\n' ) ,
324- `
342+ expectedMessages ,
343+ ) ;
344+ }
345+ }
346+
347+ test ( 'problemMatchers severities' , async ( ) => {
348+ await testProblemMatchersWithCompilerMessages (
349+ 'compiler_messages.txt' ,
350+ `
3253511: procedure "Hello" is not referenced [-gnatwu]
3263521: bad casing of "Hello" declared at line 4 [-gnatyr]
3273531: bad casing of "Hello" declared at line 4 [-gnatyr]
@@ -334,8 +360,33 @@ ada: Run main - src/test.adb - .${path.sep}obj${path.sep}test${exe}
3343600: missing ";"
3353612: this is an extra message
3363622: hello world (trying: to confuse the regexp here)` . trim ( ) ,
337- ) ;
338- }
363+ ) ;
364+ } ) ;
365+
366+ test ( 'problemMatchers severities (warnings only)' , async ( ) => {
367+ await testProblemMatchersWithCompilerMessages (
368+ 'compiler_messages_warnings_only.txt' ,
369+ `
370+ 1: no entities of "Ada.Strings.Fixed" are referenced [-gnatwu]
371+ 1: use clause for package "Fixed" has no effect [-gnatwu]
372+ 1: no entities of "GNAT.Strings" are referenced [-gnatwu]
373+ 1: use clause for package "Strings" has no effect [-gnatwu]
374+ 1: no entities of "GNATCOLL.Utils" are referenced [-gnatwu]
375+ 1: use clause for package "Utils" has no effect [-gnatwu]
376+ 1: no entities of "GPS.Intl" are referenced [-gnatwu]
377+ 1: use clause for package "Intl" has no effect [-gnatwu]
378+ 1: no entities of "GPS.Kernel.Task_Manager" are referenced [-gnatwu]
379+ 1: use clause for package "Task_Manager" has no effect [-gnatwu]
380+ 1: no entities of "Commands" are referenced [-gnatwu]
381+ 1: use clause for package "Commands" has no effect [-gnatwu]
382+ 1: use clause for package "GUI_Utils" has no effect [-gnatwu]
383+ 1: no entities of "Language_Handlers" are referenced [-gnatwu]
384+ 1: use clause for package "Language_Handlers" has no effect [-gnatwu]
385+ 1: no entities of "String_Utils" are referenced [-gnatwu]
386+ 1: use clause for package "String_Utils" has no effect [-gnatwu]
387+ 1: use clause for package "Known" has no effect [-gnatwu]
388+ 1: function "Get_Or_Create_Manager" is not referenced [-gnatwu]` . trim ( ) ,
389+ ) ;
339390 } ) ;
340391} ) ;
341392
0 commit comments