Subject: bug#58984: 29.0.50; M-x compile misinterprets libcheck error message format

From: "Basil L. Contovounesios" <[email-masked]>
Date: Sun, 06 Nov 2022 14:10:56 +0200

Mattias Engdegård [2022-11-04 18:49 +0100] wrote:

> 4 nov. 2022 kl. 18.08 skrev Basil L. Contovounesios <[email-masked]>:
>> itree-tests.c:71:F:insert1:test_insert_1:0: Assertion 'N_50.red' failed
>
> This doesn't quite conform to GNU message standards, does it? For it to have the
>
>   [PROGRAM:]FILE:LINE: MESSAGE
>
> form, there should be a space before the message (that is, before the
> 'F'). Otherwise parsing these things become almost impossible with all the
> possible variations, file names containing spaces and colons and so
> on.

I imagined as much, which is why I pinged you for comment from the
outset ;).

> Currently, the machinery interprets "tree-tests.c" as the program name and
> "71:F:insert1:test_insert_1" as the file which is of course nonsense.
>
> Any hope the tool can have its output format adjusted?

The only alternative format I'm aware of is after compiling the test
runner in CK_SUBUNIT mode instead of CK_NORMAL or CK_ENV.  I.e. with the
following patch:

diff --git a/test/manual/noverlay/Makefile.in b/test/manual/noverlay/Makefile.in
index 3c8dba1ce1..c0fa705174 100644
--- a/test/manual/noverlay/Makefile.in
+++ b/test/manual/noverlay/Makefile.in
@@ -33,7 +33,7 @@ .PHONY:
 all: check
 
 check: $(PROGRAM)
-	./check-sanitize.sh ./$(PROGRAM)
+	./$(PROGRAM)
 
 itree-tests.o: emacs-compat.h $(top_srcdir)/src/itree.c $(top_srcdir)/src/itree.h
 
diff --git a/test/manual/noverlay/itree-tests.c b/test/manual/noverlay/itree-tests.c
index 278e65f9bf..a8c69c79be 100644
--- a/test/manual/noverlay/itree-tests.c
+++ b/test/manual/noverlay/itree-tests.c
@@ -68,8 +68,8 @@ START_TEST (test_insert_1)
    */
 
   interval_tree_insert (&tree, &N_50);
-  ck_assert (! N_50.red);
-  ck_assert_ptr_eq (&N_50, tree.root);
+  ck_assert (N_50.red);
+  ck_assert_ptr_ne (&N_50, tree.root);
 }
 END_TEST
 
@@ -88,7 +88,7 @@ START_TEST (test_insert_2)
   ck_assert_ptr_eq (&N_50, tree.root);
   ck_assert_ptr_eq (N_30.parent, &N_50);
   ck_assert_ptr_eq (N_50.left, &N_30);
-  ck_assert_ptr_null (N_50.right);
+  ck_assert_ptr_nonnull (N_50.right);
   ck_assert_ptr_null (N_30.left);
   ck_assert_ptr_null (N_30.right);
 }
@@ -737,7 +737,7 @@ START_TEST (test_remove_10)
       itree_remove (&tree, &nodes[index[i]]);
     }
   ck_assert_ptr_null (tree.root);
-  ck_assert_int_eq (tree.size, 0);
+  ck_assert_int_ne (tree.size, 0);
 }
 END_TEST
 
@@ -749,11 +749,11 @@ START_TEST (test_remove_10)
 START_TEST (test_generator_1)
 {
   struct itree_node node, *n;
-  struct itree_iterator *g;
+  struct itree_iterator *g = NULL;
   interval_tree_init (&tree);
 
   itree_insert (&tree, &node, 10, 20);
-  g = itree_iterator_start (&tree, 0, 30, ITREE_ASCENDING, NULL, 0);
+  /* g = itree_iterator_start (&tree, 0, 30, ITREE_ASCENDING, NULL, 0); */
   n = itree_iterator_next (g);
   ck_assert_ptr_eq (n, &node);
   ck_assert_int_eq (n->begin, 10);
@@ -1282,7 +1282,7 @@ main (void)
   SRunner *sr = srunner_create (s);
 
   init_itree ();
-  srunner_run_all (sr, CK_ENV);
+  srunner_run_all (sr, CK_SUBUNIT);
   int nfailed = srunner_ntests_failed (sr);
   srunner_free (sr);
   return (nfailed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;

I get the following output:

-*- mode: compilation; default-directory: "~/.local/src/emacs/test/manual/noverlay/" -*-
Compilation started at Sun Nov  6 14:08:38

make
gcc -O0 -g3 -pthread -I ../../../src  -c -o itree-tests.o itree-tests.c
gcc   itree-tests.o  -lcheck_pic -pthread -lrt -lm -lsubunit -lm -o itree-tests
./itree-tests
test: insert1:test_insert_1
failure: insert1:test_insert_1 [
itree-tests.c:71: Assertion 'N_50.red' failed
]
test: insert1:test_insert_2
failure: insert1:test_insert_2 [
itree-tests.c:91: Assertion 'N_50.right != NULL' failed: N_50.right == 0
]
test: insert1:test_insert_3
success: insert1:test_insert_3
test: insert1:test_insert_4
success: insert1:test_insert_4
test: insert1:test_insert_5
success: insert1:test_insert_5
test: insert1:test_insert_6
success: insert1:test_insert_6
test: insert2:test_insert_7
success: insert2:test_insert_7
test: insert2:test_insert_8
success: insert2:test_insert_8
test: insert2:test_insert_9
success: insert2:test_insert_9
test: insert2:test_insert_10
success: insert2:test_insert_10
test: insert2:test_insert_11
success: insert2:test_insert_11
test: insert2:test_insert_12
success: insert2:test_insert_12
test: insert3:test_insert_13
success: insert3:test_insert_13
test: insert3:test_insert_14
success: insert3:test_insert_14
test: remove1:test_remove_1
success: remove1:test_remove_1
test: remove1:test_remove_2
success: remove1:test_remove_2
test: remove1:test_remove_3
success: remove1:test_remove_3
test: remove1:test_remove_4
success: remove1:test_remove_4
test: remove2:test_remove_5
success: remove2:test_remove_5
test: remove2:test_remove_6
success: remove2:test_remove_6
test: remove2:test_remove_7
success: remove2:test_remove_7
test: remove2:test_remove_8
success: remove2:test_remove_8
test: remove3:test_remove_9
success: remove3:test_remove_9
test: remove3:test_remove_10
failure: remove3:test_remove_10 [
itree-tests.c:740: Assertion 'tree.size != 0' failed: tree.size == 0, 0 == 0
]
test: generator:test_generator_1
../../../src/itree.c:1370:eassert condition failed: g && g->running
error: generator:test_generator_1 [
itree-tests.c:749: (after this point) Early exit with return value 1
]
test: generator:test_generator_2
success: generator:test_generator_2
test: generator:test_generator_3
success: generator:test_generator_3
test: generator:test_generator_5
success: generator:test_generator_5
test: generator:test_generator_6
success: generator:test_generator_6
test: generator:test_generator_7
success: generator:test_generator_7
test: generator:test_generator_8
success: generator:test_generator_8
test: generator:test_generator_9
success: generator:test_generator_9
test: insert_gap:test_gap_insert_1
success: insert_gap:test_gap_insert_1
test: insert_gap:test_gap_insert_2
success: insert_gap:test_gap_insert_2
test: insert_gap:test_gap_insert_3
success: insert_gap:test_gap_insert_3
test: insert_gap:test_gap_insert_4
success: insert_gap:test_gap_insert_4
test: insert_gap:test_gap_insert_5
success: insert_gap:test_gap_insert_5
test: insert_gap:test_gap_insert_6
success: insert_gap:test_gap_insert_6
test: insert_gap:test_gap_insert_7
success: insert_gap:test_gap_insert_7
test: insert_gap:test_gap_insert_8
success: insert_gap:test_gap_insert_8
test: insert_gap:test_gap_insert_9
success: insert_gap:test_gap_insert_9
test: insert_gap:test_gap_insert_10
success: insert_gap:test_gap_insert_10
test: insert_gap:test_gap_insert_11
success: insert_gap:test_gap_insert_11
test: delete_gap:test_gap_delete_1
success: delete_gap:test_gap_delete_1
test: delete_gap:test_gap_delete_2
success: delete_gap:test_gap_delete_2
test: delete_gap:test_gap_delete_3
success: delete_gap:test_gap_delete_3
test: delete_gap:test_gap_delete_4
success: delete_gap:test_gap_delete_4
test: delete_gap:test_gap_delete_5
success: delete_gap:test_gap_delete_5
test: delete_gap:test_gap_delete_6
success: delete_gap:test_gap_delete_6
test: delete_gap:test_gap_delete_7
success: delete_gap:test_gap_delete_7
test: delete_gap:test_gap_delete_8
success: delete_gap:test_gap_delete_8

make: *** [Makefile:36: check] Error 1

Compilation exited abnormally with code 2 at Sun Nov  6 14:08:39

This is much more verbose, but the error messages are in a more readily
grokked format.  Not sure which is preferable between that and the
status quo (filtering through check-sanitize.sh).

In any case the feature request was to support Check's default output
(what we do with our small manual test suite is largely
inconsequential), so if that's too difficult and brittle for few gains,
we can close this as wontfix.

Thanks,

-- 
Basil