Skip to content

Commit d9558a7

Browse files
author
Viviane Garèse
committed
Simplify missing source cov levels on cmd line warning
Instead of listing all possible source coverage combinations, express them as a regular expression.
1 parent 2029eec commit d9558a7

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

tools/gnatcov/command_line.ads

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ package Command_Line is
699699
& " " & Object_Level_Options (Separator => ", ")
700700
& " (object coverage)"
701701
& ASCII.LF
702-
& " " & Source_Level_Options (Separator => ", ")
702+
& " " & Source_Level_Options
703703
& " (source coverage)"
704704
& ASCII.LF
705705
& "For the ""instrument"" command, "

tools/gnatcov/coverage_options.adb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,19 @@ package body Coverage_Options is
119119
-- Source_Level_Options --
120120
--------------------------
121121

122-
function Source_Level_Options (Separator : String) return String is
122+
function Source_Level_Options return String is
123+
function Level_Str (L : Source_Coverage_Level) return String;
124+
-- Return the lowercase string representation of L
125+
126+
function Level_Str (L : Source_Coverage_Level) return String
127+
is (To_Lower (L'Img));
123128
begin
124-
return Level_Options (Source_Levels_Option_Map, Separator);
129+
return Level_Str (Stmt)
130+
& "(+" & Level_Str (Decision) & "|"
131+
& "+" & Level_Str (MCDC) & "|"
132+
& "+" & Level_Str (UC_MCDC) & ")?"
133+
& "(+" & Level_Str (ATC) & "|"
134+
& "+" & Level_Str (ATCC) & ")?";
125135
end Source_Level_Options;
126136

127137
-------------------------------------

tools/gnatcov/coverage_options.ads

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ package Coverage_Options is
6969
function Coverage_Option_Value (L : Levels_Type) return String;
7070
-- Return the coverage option value corresponding to L
7171

72-
function Source_Level_Options (Separator : String) return String;
73-
-- Return a string expression listing the valid --level alternatives
74-
-- for source coverage, separated by Separator.
72+
function Source_Level_Options return String;
73+
-- Return a regular expression string describing the valid --level
74+
-- combinations of source coverage levels.
7575

7676
function Object_Level_Options (Separator : String) return String;
7777
-- Return a string expression describing valid --level alternatives

tools/gnatcov/gnatcov_bits_specific.adb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,12 +1067,12 @@ procedure GNATcov_Bits_Specific is
10671067
Fatal_Error
10681068
("Instrumentation requires a source coverage level"
10691069
& ASCII.LF
1070-
& " (--level=" & Source_Level_Options ("|") & ")");
1070+
& " (--level=" & Source_Level_Options & ")");
10711071
elsif not Source_Coverage_Enabled then
10721072
Warn
10731073
("Coverage level not specified on the command"
10741074
& " line or in the project file (--level="
1075-
& Source_Level_Options ("|") & "), defaulting to ""stmt"".");
1075+
& Source_Level_Options & "), defaulting to ""stmt"".");
10761076
Set_Coverage_Levels ("stmt");
10771077
end if;
10781078

@@ -1774,7 +1774,7 @@ begin
17741774
if not (Source_Coverage_Enabled or else Object_Coverage_Enabled)
17751775
then
17761776
Warn ("Coverage level not specified on the command line or in the"
1777-
& " project file (--level=" & Source_Level_Options ("|")
1777+
& " project file (--level=" & Source_Level_Options
17781778
& "|" & Object_Level_Options ("|") & "), defaulting to"
17791779
& " ""stmt"".");
17801780
Set_Coverage_Levels ("stmt");
@@ -1789,7 +1789,7 @@ begin
17891789
("""report"" output format (from --annotate) is"
17901790
& " only for source coverage criteria"
17911791
& ASCII.LF
1792-
& " (--level=" & Source_Level_Options ("|")
1792+
& " (--level=" & Source_Level_Options
17931793
& ", not --level="
17941794
& Coverage_Option_Value (Current_Levels) & ")");
17951795

0 commit comments

Comments
 (0)