all repos — tint2 @ c41d75e54e946078eb840043180d9d81d8f7c9c6

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

Integrate unit tests in ci script
o9000 mrovi9000@gmail.com
commit

c41d75e54e946078eb840043180d9d81d8f7c9c6

parent

8e0bdcaeddb1aac50946f5249721c8b3a66f9c07

5 files changed, 52 insertions(+), 4 deletions(-)

jump to
M src/init.csrc/init.c

@@ -50,7 +50,10 @@ } else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) {

fprintf(stdout, "tint2 version %s\n", VERSION_STRING); exit(0); } else if (strcmp(argv[i], "--test") == 0) { - run_all_tests(); + run_all_tests(false); + exit(0); + } else if (strcmp(argv[i], "--test-verbose") == 0) { + run_all_tests(true); exit(0); } else if (strcmp(argv[i], "-c") == 0) { if (i + 1 < argc) {
M src/util/test.csrc/util/test.c

@@ -123,7 +123,7 @@ run_test_child(item);

return run_test_parent(item, pid); } -void run_all_tests() +void run_all_tests(bool verbose) { fprintf(stdout, BLUE "tint2: Running %d tests..." RESET "\n", g_list_length(all_tests)); size_t count = 0, succeeded = 0, failed = 0;

@@ -138,6 +138,19 @@ succeeded++;

} else { fprintf(stdout, RED "failed" RESET "\n"); failed++; + if (verbose) { + char *log_name = test_log_name_from_test_name(item->name); + FILE *log = fopen(log_name, "rt"); + if (log) { + char buffer[4096]; + size_t num_read; + while ((num_read = fread(buffer, 1, sizeof(buffer), log)) > 0) { + fwrite(buffer, 1, num_read, stdout); + } + fclose(log); + } + free(log_name); + } } } if (failed == 0)
M src/util/test.hsrc/util/test.h

@@ -16,7 +16,7 @@ register_test_(test_##name, #name); \

} \ void test_##name(Status *test_result_) -void run_all_tests(); +void run_all_tests(bool verbose); #define FAIL_TEST_ \ *test_result_ = FAILURE; \
M src/util/timer.csrc/util/timer.c

@@ -1665,7 +1665,7 @@ int triggered = 0;

set_mock_time_ms(origin + 0); timeout *t1 = add_timeout(100, 0, trigger_callback, &triggered, NULL); - timeout *t2 = add_timeout(200, 50, trigger_callback, &triggered, NULL); + add_timeout(200, 50, trigger_callback, &triggered, NULL); handle_expired_timers(); ASSERT_EQUAL(triggered, 0); ASSERT_EQUAL(timeval_to_ms(get_next_timeout()), 100);
M test/regression.pytest/regression.py

@@ -222,6 +222,37 @@ print("```\n" + out.strip() + "\n```")

stop_xvfb() +def run_unit_tests(tint2path, use_asan): + print("# Unit tests", "(ASAN on)" if use_asan else "") + start_xvfb() + sleep(1) + start_xsettings() + start_wm() + sleep(1) + compton = start_compositor() + sleep(1) + os.environ["DEBUG_FPS"] = "1" + os.environ["ASAN_OPTIONS"] = "detect_leaks=1:exitcode=0" + tint2 = run([tint2path, "--test-verbose"], True) + if tint2.poll() != None: + raise RuntimeError("tint2 failed to start") + stop(tint2) + out, _ = tint2.communicate() + exitcode = tint2.returncode + if exitcode != 0 and exitcode != 23: + print("tint2 crashed with exit code {0}!".format(exitcode)) + print("Output:") + print("```\n" + out.strip() + "\n```") + return + if "tests succeeded" in out: + num_tests = [line for line in out.split("\n") if "tint2: Running" in line][0] + print "All {0} tests succeeded.".format(num_tests) + return + if "tests failed" in out: + print out + stop_xvfb() + + def show_timestamp(): utc_datetime = datetime.datetime.utcnow() print("Last updated:", utc_datetime.strftime("%Y-%m-%d %H:%M UTC"))

@@ -377,6 +408,7 @@ compile_remotely_and_report("FreeBSD")

compile_remotely_and_report("OpenBSD") for use_asan in [True, False]: compile_and_report(args.src_dir, use_asan) + run_unit_tests("./build/tint2", use_asan) run_tests(use_asan)