From 6747f318f50760d7a3a773e894df3d3ed449e5d7 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Thu, 7 Nov 2024 00:02:27 +0300 Subject: test suite: fixed failure detection in the commandline-editing test cases * The program exit code will usually not signal failures since they are caught earlier. * Therefore, we always have to capture and check stderr. --- src/main.c | 4 ++++ tests/atlocal.in | 2 ++ tests/testsuite.at | 14 +++++++++++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index d561d33..892f15c 100644 --- a/src/main.c +++ b/src/main.c @@ -457,6 +457,10 @@ main(int argc, char **argv) teco_machine_main_init(&teco_cmdline.machine, &local_qregs, TRUE); if (G_UNLIKELY(teco_fake_cmdline != NULL)) { + /* + * NOTE: Most errors are already catched at a higher level, + * so you cannot rely on the exit code to detect them. + */ if (!teco_cmdline_keypress(teco_fake_cmdline, strlen(teco_fake_cmdline), &error) && !g_error_matches(error, TECO_ERROR, TECO_ERROR_QUIT)) { teco_error_add_frame_toplevel(); diff --git a/tests/atlocal.in b/tests/atlocal.in index 3c533a6..2c76ab0 100644 --- a/tests/atlocal.in +++ b/tests/atlocal.in @@ -17,6 +17,8 @@ SCITECO_CMDLINE="$SCITECO --no-profile --fake-cmdline" # is used. SCITECOPATH="@abs_top_srcdir@/lib" +GREP="@GREP@" + # Glib debug options G_SLICE=debug-blocks G_ENABLE_DIAGNOSTIC=1 diff --git a/tests/testsuite.at b/tests/testsuite.at index 30ae985..4bd4cfe 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -227,19 +227,27 @@ AT_SETUP([Jump to beginning of macro]) AT_CHECK([$SCITECO -e "%a-2\"< F< ' Qa-2\"N(0/0)'"], 0, ignore, ignore) AT_CLEANUP +# +# Command-line editing bugs. +# # NOTE: It would generally be possible to use control codes like ^H (8) # and ^W (23) for rubout as well, but this is tricky to write in a portable manner. # Therefore we usally use the push/pop command-line commands { and }. +# NOTE: Most errors are not reported in exit codes - you must check stderr. +# AT_SETUP([Rub out string append]) -AT_CHECK([$SCITECO_CMDLINE "@I/XXX/ H:Xa{-4D} :Qa-0\"N(0/0)'"], 0, ignore, ignore) +AT_CHECK([$SCITECO_CMDLINE "@I/XXX/ H:Xa{-4D} :Qa-0\"N(0/0)'"], 0, ignore, stderr) +AT_FAIL_IF([$GREP "^Error:" stderr]) AT_CLEANUP AT_SETUP([Rub out of empty forward kill]) -AT_CHECK([$SCITECO_CMDLINE "@I/F/ J @I/X/ @FK/F/{-6D} Z-2\"N(0/0)'"], 0, ignore, ignore) +AT_CHECK([$SCITECO_CMDLINE "@I/F/ J @I/X/ @FK/F/{-6D} Z-2\"N(0/0)'"], 0, ignore, stderr) +AT_FAIL_IF([$GREP "^Error:" stderr]) AT_CLEANUP AT_SETUP([Searches from macro calls]) -AT_CHECK([$SCITECO_CMDLINE "@^Um{:@S/XXX/} :Mm\"S(0/0)' Mm\"S(0/0)'"], 0, ignore, ignore) +AT_CHECK([$SCITECO_CMDLINE "@^Um{:@S/XXX/} :Mm\"S(0/0)' Mm\"S(0/0)'"], 0, ignore, stderr) +AT_FAIL_IF([$GREP "^Error:" stderr]) AT_CLEANUP AT_BANNER([Known Bugs]) -- cgit v1.2.3