Skip to content

Commit

Permalink
Merge branch 'mr/jicquel/#59.fix-assert-colors' into 'master'
Browse files Browse the repository at this point in the history
Fix assert traces in case of success

See merge request eng/toolchain/gnatcoll-core!103
  • Loading branch information
Jicquel committed May 23, 2024
2 parents 89d21e6 + ef1268f commit 344a30e
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 25 deletions.
6 changes: 5 additions & 1 deletion src/gnatcoll-traces.adb
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,11 @@ package body GNATCOLL.Traces is
end if;

elsif Message_If_Success'Length /= 0 then
Trace (Handle, Message_If_Success, Location, Entity);
Trace
(Handle => Handle,
Message => Message_If_Success,
Location => Location,
Entity => Entity);
end if;
end if;
end Assert;
Expand Down
2 changes: 2 additions & 0 deletions testsuite/tests/traces/debug_config_parsing/.gnatdebug_colors
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PKG=yes
DEBUG.COLORS=yes

This file was deleted.

This file was deleted.

16 changes: 16 additions & 0 deletions testsuite/tests/traces/debug_config_parsing/test.adb
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,20 @@ procedure Test is
begin
Parse_Config_File (Ada.Command_Line.Argument (1));
Foo (3);

Log.all.Assert
(
Condition => True,
Error_Message => "[Test error msg]",
Message_If_Success => "[Test success msg]",
Raise_Exception => False
);

Log.all.Assert
(
Condition => False,
Error_Message => "[Test error msg]",
Message_If_Success => "[Test success msg]",
Raise_Exception => False
);
end Test;
19 changes: 7 additions & 12 deletions testsuite/tests/traces/debug_config_parsing/test.out
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,8 @@
[PKG] Leaving Test.Foo:test.adb:13 (loc:test.adb:13)
[PKG] Leaving Test.Foo:test.adb:13 (loc:test.adb:13)
[PKG] Leaving Test.Foo:test.adb:13 (loc:test.adb:13)

== DEBUG.LOCATION=no
[PKG] Entering Test.Foo:test.adb:13
[PKG] A = 3
[PKG] Entering Test.Foo:test.adb:13
[PKG] A = 2
[PKG] Entering Test.Foo:test.adb:13
[PKG] A = 1
[PKG] Leaving Test.Foo:test.adb:13
[PKG] Leaving Test.Foo:test.adb:13
[PKG] Leaving Test.Foo:test.adb:13
[PKG] [Test success msg] (loc:test.adb:25)
[PKG.EXCEPTIONS] [Test error msg] (loc:test.adb:33)

== DEBUG.ENCLOSING_ENTITY=yes
[PKG] Entering Test.Foo:test.adb:13 (entity:Test.Foo)
Expand All @@ -30,8 +21,10 @@
[PKG] Leaving Test.Foo:test.adb:13 (entity:Test.Foo)
[PKG] Leaving Test.Foo:test.adb:13 (entity:Test.Foo)
[PKG] Leaving Test.Foo:test.adb:13 (entity:Test.Foo)
[PKG] [Test success msg] (entity:Test)
[PKG.EXCEPTIONS] [Test error msg] (entity:Test)

== DEBUG.ENCLOSING_ENTITY=no
== DEBUG.COLORS=yes
[PKG] Entering Test.Foo:test.adb:13
[PKG] A = 3
[PKG] Entering Test.Foo:test.adb:13
Expand All @@ -41,3 +34,5 @@
[PKG] Leaving Test.Foo:test.adb:13
[PKG] Leaving Test.Foo:test.adb:13
[PKG] Leaving Test.Foo:test.adb:13
[PKG] [Test success msg]
[PKG.EXCEPTIONS] [Test error msg]
12 changes: 4 additions & 8 deletions testsuite/tests/traces/debug_config_parsing/test.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
echo "== DEBUG.LOCATION=yes"
./test .gnatdebug_location_yes

echo ""
echo "== DEBUG.LOCATION=no"
./test .gnatdebug_location_no
./test .gnatdebug_location

echo ""
echo "== DEBUG.ENCLOSING_ENTITY=yes"
./test .gnatdebug_enclosing_entity_yes
./test .gnatdebug_enclosing_entity

echo ""
echo "== DEBUG.ENCLOSING_ENTITY=no"
./test .gnatdebug_enclosing_entity_no
echo "== DEBUG.COLORS=yes"
./test .gnatdebug_colors

0 comments on commit 344a30e

Please sign in to comment.