Skip to content

Commit

Permalink
Merge pull request #1373 from apprehensions/testdataarg
Browse files Browse the repository at this point in the history
test: use argument as test data directory
  • Loading branch information
bynect authored Aug 26, 2024
2 parents 844167a + b284582 commit d2faa87
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ 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 -v | ./test/greenest.awk '
./test/test ./test | ./test/greenest.awk '

test-valgrind: test/test
${VALGRIND} \
Expand All @@ -104,7 +104,7 @@ test-valgrind: test/test
--errors-for-leak-kinds=definite \
--num-callers=40 \
--error-exitcode=123 \
./test/test -v
./test/test ./test

test-coverage: CFLAGS += -fprofile-arcs -ftest-coverage -O0
test-coverage: test
Expand Down
12 changes: 7 additions & 5 deletions test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@ SUITE_EXTERN(suite_input);
GREATEST_MAIN_DEFS();

int main(int argc, char *argv[]) {
char *prog = realpath(argv[0], NULL);
if (!prog) {
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 = dirname(prog);

/* By default do not print out warning messages, when executing tests.
* But allow, if DUNST_TEST_LOG=1 is set in environment. */
Expand Down Expand Up @@ -71,9 +75,7 @@ int main(int argc, char *argv[]) {
RUN_SUITE(suite_rules);
RUN_SUITE(suite_input);

base = NULL;
g_strfreev(configs);
free(prog);

// this returns the error code
GREATEST_MAIN_END();
Expand Down

0 comments on commit d2faa87

Please sign in to comment.