File tree Expand file tree Collapse file tree 4 files changed +64
-2
lines changed
testsuite/tests/integrated_instrumentation/168-rts_error_msg Expand file tree Collapse file tree 4 files changed +64
-2
lines changed Original file line number Diff line number Diff line change 1+ INVALID PROJECT FILE FOR TEST PURPOSES
Original file line number Diff line number Diff line change 1+ int
2+ main ()
3+ {
4+ return 0 ;
5+ }
Original file line number Diff line number Diff line change 1+ """
2+ Test that the error message emitted by the "gnatcov setup-integration" command
3+ is helpful when failing to load the coverage runtime project.
4+ """
5+
6+ import os
7+
8+ from SUITE .cutils import Wdir
9+ from SUITE .tutils import contents_of , thistest , xcov
10+
11+ # Point gnatcov towards our invalid GNATcov_RTS project
12+ env = os .environ
13+ env ["GPR_PROJECT_PATH" ] = os .getcwd ()
14+
15+ tmp = Wdir ("tmp_" )
16+
17+ # Try to setup for a simple main file
18+ integration_log = "setup-integration.log"
19+ p = xcov (
20+ [
21+ "setup-integration" ,
22+ "-cstmt+mcdc" ,
23+ "--output-dir=." ,
24+ "--files=../main.c" ,
25+ ],
26+ env = env ,
27+ out = integration_log ,
28+ register_failure = False
29+ )
30+
31+ thistest .fail_if (p .status == 0 , "gnatcov exit status shouldn't be success" )
32+
33+ # Check that the error message correctly reports an issue with the coverage
34+ # runtime.
35+ thistest .fail_if_no_match (
36+ what = "gnatcov error message" ,
37+ regexp = r".*gnatcov(\.exe)?: Failed locating or loading gnatcov_rts\.gpr"
38+ r"(\n|.)*Is the project available on the GPR_PROJECT_PATH\?"
39+ r"(\n|.)*gprls output was:"
40+ r"(\n|.)*" ,
41+ actual = contents_of (integration_log ),
42+ )
43+
44+ thistest .result ()
Original file line number Diff line number Diff line change @@ -136,16 +136,28 @@ package body Instrument.Setup_Config is
136136 Output_Filename : constant String :=
137137 Output_Dir / " gprls_output" ;
138138 Output_File : File_Type;
139+ GPRLS_Success : Boolean;
139140 begin
140141 Args.Append (+" -P" );
141142 Args.Append (+" gnatcov_rts" );
142143 Args.Append (+" -vP1" );
143- Run_Command
144+ GPRLS_Success := Run_Command
144145 (Command => " gprls" ,
145146 Arguments => Args,
146147 Origin_Command_Name => " gnatcov setup-integration" ,
147- Output_File => Output_Filename);
148+ Output_File => Output_Filename,
149+ Ignore_Error => True);
148150 Open (Output_File, In_File, Output_Filename);
151+ if not GPRLS_Success then
152+ Outputs.Error (" Failed locating or loading gnatcov_rts.gpr" );
153+ Warning_Or_Error (" Is the project available on the"
154+ & " GPR_PROJECT_PATH?" );
155+ Warning_Or_Error (" gprls output was:" );
156+ while not End_Of_File (Output_File) loop
157+ Warning_Or_Error (Get_Line (Output_File));
158+ end loop ;
159+ raise Xcov_Exit_Exc;
160+ end if ;
149161 while not End_Of_File (Output_File) loop
150162 declare
151163 Line : constant String := Get_Line (Output_File);
You can’t perform that action at this time.
0 commit comments