test: vary the colors in the test output a bit

Instead of everything bright red, let's vary the colors so it's easier
to spot the different assertions we add.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1157>
This commit is contained in:
Peter Hutterer 2025-03-12 10:38:12 +10:00 committed by Marge Bot
parent aaad75ec19
commit bfbecc5ef3
2 changed files with 10 additions and 5 deletions

View file

@ -145,6 +145,7 @@ LIBINPUT_ATTRIBUTE_PRINTF(4, 5)
void
_litest_checkpoint(const char *func,
int line,
const char *color,
const char *format,
...)
{
@ -158,7 +159,7 @@ _litest_checkpoint(const char *func,
"%s%s():%d - %s%s%s\n",
use_colors ? ANSI_BRIGHT_BLUE : "",
func, line,
use_colors ? ANSI_BRIGHT_RED : "",
use_colors ? color : "",
buf,
use_colors ? ANSI_NORMAL : "");
}
@ -631,14 +632,14 @@ _litest_dispatch(struct libinput *li,
++dispatch_counter;
_litest_checkpoint(func, line,
_litest_checkpoint(func, line, ANSI_MAGENTA,
"┌──────────────────── dispatch %3d ────────────────────┐",
dispatch_counter);
int rc = libinput_dispatch(li);
enum libinput_event_type type = libinput_next_event_type(li);
const char *evtype = type == LIBINPUT_EVENT_NONE ? "NONE" : litest_event_type_str(type);
_litest_checkpoint(func, line,
_litest_checkpoint(func, line, ANSI_MAGENTA,
"└──────────────────── /dispatch %3d ────────────────────┘ pending %s",
dispatch_counter,
evtype);
@ -3850,7 +3851,7 @@ _litest_assert_empty_queue(struct libinput *li,
bool empty_queue = true;
struct libinput_event *event;
_litest_checkpoint(func, line, "asserting empty queue");
_litest_checkpoint(func, line, ANSI_BRIGHT_CYAN, "asserting empty queue");
libinput_dispatch(li);
while ((event = libinput_get_event(li))) {
@ -4129,6 +4130,7 @@ _litest_assert_button_event(struct libinput *li, unsigned int button,
_litest_checkpoint(func,
line,
ANSI_CYAN,
"asserting button event %s (%d) state %d",
libevdev_event_code_get_name(EV_KEY, button),
button,
@ -4220,6 +4222,7 @@ _litest_assert_gesture_event(struct libinput *li,
_litest_checkpoint(func,
line,
ANSI_CYAN,
"asserting gesture event %s %dfg",
litest_event_type_str(type),
nfingers);
@ -4639,6 +4642,7 @@ _litest_assert_only_typed_events(struct libinput *li,
_litest_checkpoint(func,
line,
ANSI_CYAN,
"asserting only typed events %s",
litest_event_type_str(type));

View file

@ -90,10 +90,11 @@ struct test_collection {
__attribute__ ((format (printf, 3, 0)))
void _litest_checkpoint(const char *func,
int line,
const char *color,
const char *format,
...);
#define litest_checkpoint(...) \
_litest_checkpoint(__func__, __LINE__, __VA_ARGS__)
_litest_checkpoint(__func__, __LINE__, ANSI_GREEN, __VA_ARGS__)
/**
* litest itself needs the user_data to store some test-suite-specific