From 9655f2c1564e82a16d1a9329ecd913f9defc8f03 Mon Sep 17 00:00:00 2001 From: bynect <68197565+bynect@users.noreply.github.com> Date: Tue, 3 Sep 2024 11:04:32 +0200 Subject: [PATCH] Use TESTDIR env var --- Makefile | 6 +++--- test/test.c | 12 ++---------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index f0d4a6f8d..f78e27a0b 100644 --- a/Makefile +++ b/Makefile @@ -94,17 +94,17 @@ endif test: test/test clean-coverage-run # Make sure an error code is returned when the test fails /usr/bin/env bash -c 'set -euo pipefail;\ - ./test/test ./test | ./test/greenest.awk ' + TESTDIR=./test ./test/test -v | ./test/greenest.awk ' test-valgrind: test/test - ${VALGRIND} \ + TESTDIR=./test ${VALGRIND} \ --suppressions=.valgrind.suppressions \ --leak-check=full \ --show-leak-kinds=definite \ --errors-for-leak-kinds=definite \ --num-callers=40 \ --error-exitcode=123 \ - ./test/test ./test + ./test/test -v test-coverage: CFLAGS += -fprofile-arcs -ftest-coverage -O0 test-coverage: test diff --git a/test/test.c b/test/test.c index ab3927e27..b5fce1985 100644 --- a/test/test.c +++ b/test/test.c @@ -33,16 +33,8 @@ SUITE_EXTERN(suite_input); GREATEST_MAIN_DEFS(); int main(int argc, char *argv[]) { - if (argc != 2) { - fprintf(stderr, "Usage: %s testdatadir", argv[0]); - exit(1); - } - - base = realpath(argv[1], NULL); - if (!base) { - fprintf(stderr, "Cannot determine actual path of test executable: %s\n", strerror(errno)); - exit(1); - } + base = getenv("TESTDIR"); + base = realpath(base ? base : "./test", NULL); /* By default do not print out warning messages, when executing tests. * But allow, if DUNST_TEST_LOG=1 is set in environment. */