Skip to content

Commit 0e71084

Browse files
committed
Fixed Failing Test, and Reverted Usage Behavior Regression
Test was failing due to grep string being invalid, and usage text being split across multiple lines. The stdout is now joined onto one line so that grep can find the expected output. Change-Id: Ied975353c3f511b28bd175c326839eba9dfe2a3e
1 parent 9da57b1 commit 0e71084

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

src/gnatcoll-opt_parse.adb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -853,14 +853,16 @@ package body GNATCOLL.Opt_Parse is
853853
overriding function Usage
854854
(Self : Option_Parser) return String
855855
is
856+
Usage_Name : constant String :=
857+
(if Name /= "" then Name else To_Upper (+Self.Name));
856858
begin
857859
if Usage_Text = "" then
858860
if Long /= "" and Short /= "" then
859-
return "[" & Long & "|" & Short & " " & (+Self.Name) & "]";
861+
return "[" & Long & "|" & Short & " " & Usage_Name & "]";
860862
elsif Long /= "" then
861-
return "[" & Long & " " & (+Self.Name) & "]";
863+
return "[" & Long & " " & Usage_Name & "]";
862864
end if;
863-
return "[" & Short & " " & (+Self.Name) & "]";
865+
return "[" & Short & " " & Usage_Name & "]";
864866
end if;
865867
return Usage_Text;
866868
end Usage;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import re
2+
with open("stdout.log", "r") as f:
3+
s = " ".join(map(lambda x: x.strip(), f.readlines()))
4+
with open("stdout.log", "w") as f:
5+
f.write(s)

testsuite/tests/opt_parse/usage/test.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,33 @@ STDOUT=stdout.log
22

33
./test > $STDOUT
44

5+
# The usage text is split across multiple lines making the greps unreliable.
6+
# This joins together the output onto one line, with correct spaceage in the
7+
# usage text so that the greps can find the expected text.
8+
python3 parse_output.py
9+
510
# Check that the help text contains updated usage information
6-
if grep -q "[--charset|-C <charset name>]" $STDOUT; then
11+
if grep -P -q "\[--charset\|-C <charset name>\]" $STDOUT; then
712
echo "stdout contained new usage text for option"
813
fi
914

10-
if grep -q "[--day|-D <three letter day of week>]" $STDOUT; then
15+
if grep -P -q "\[--day\|-D <three letter day of week>\]" $STDOUT; then
1116
echo "stdout contained new usage text for enum option"
1217
fi
1318

14-
if grep -q "[--files|-F <list of filepaths to parse>]" $STDOUT; then
19+
if grep -P -q "\[--files\|-F <list of filepaths to parse>\]" $STDOUT; then
1520
echo "stdout contained new usage text for option list"
1621
fi
1722

1823
# Check that the help text contains default usage information
19-
if grep -q "[--charset2|-C2 CHARSET2]" $STDOUT; then
24+
if grep -P -q "\[--charset2\|-C2 CHARSET2\]" $STDOUT; then
2025
echo "stdout contained default usage text for option"
2126
fi
2227

23-
if grep -q "[--day2|-D2 DAY2]" $STDOUT; then
28+
if grep -P -q "\[--day2\|-D2 DAY2\]" $STDOUT; then
2429
echo "stdout contained default usage text for enum option"
2530
fi
2631

27-
if grep -q "[--files2|-F2 FILES2[FILES2...]]" $STDOUT; then
32+
if grep -P -q "\[--files2\|-F2 FILES2 \[FILES2...\]\]" $STDOUT; then
2833
echo "stdout contained default usage text for option list"
2934
fi

0 commit comments

Comments
 (0)