aboutsummaryrefslogtreecommitdiffstats
path: root/t/unit-tests/clar/test/main.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-09-29 11:40:33 -0700
committerJunio C Hamano <gitster@pobox.com>2025-09-29 11:40:33 -0700
commit347af012dba8794d003e4ae061131e3b7acdd558 (patch)
treef8f0df3271d2bca9c0d98af150e114e75cca35a1 /t/unit-tests/clar/test/main.c
parentbb69721404348ea2db0a081c41ab6ebfe75bdec8 (diff)
parent93dbb6b3c572fc8877b56233730b5d12b327a7a4 (diff)
downloadgit-347af012dba8794d003e4ae061131e3b7acdd558.tar.gz
Merge branch 'ps/clar-updates'
Import a newer version of the clar unit testing framework. * ps/clar-updates: t/unit-tests: update to 10e96bc t/unit-tests: update clar to fcbed04
Diffstat (limited to 't/unit-tests/clar/test/main.c')
-rw-r--r--t/unit-tests/clar/test/main.c41
1 files changed, 13 insertions, 28 deletions
diff --git a/t/unit-tests/clar/test/main.c b/t/unit-tests/clar/test/main.c
index 59e56ad255..94af440643 100644
--- a/t/unit-tests/clar/test/main.c
+++ b/t/unit-tests/clar/test/main.c
@@ -1,23 +1,9 @@
-/*
- * Copyright (c) Vicent Marti. All rights reserved.
- *
- * This file is part of clar, distributed under the ISC license.
- * For full terms see the included COPYING file.
- */
+#include <stdio.h>
+#include <string.h>
-#include "clar_test.h"
+#include "selftest.h"
-/*
- * Sample main() for clar tests.
- *
- * You should write your own main routine for clar tests that does specific
- * setup and teardown as necessary for your application. The only required
- * line is the call to `clar_test(argc, argv)`, which will execute the test
- * suite. If you want to check the return value of the test application,
- * your main() should return the same value returned by clar_test().
- */
-
-int global_test_counter = 0;
+const char *selftest_suite_directory;
#ifdef _WIN32
int __cdecl main(int argc, char *argv[])
@@ -25,16 +11,15 @@ int __cdecl main(int argc, char *argv[])
int main(int argc, char *argv[])
#endif
{
- int ret;
-
- /* Your custom initialization here */
- global_test_counter = 0;
-
- /* Run the test suite */
- ret = clar_test(argc, argv);
+ if (argc < 2) {
+ fprintf(stderr, "usage: %s <selftest-suite-directory> <options>\n",
+ argv[0]);
+ exit(1);
+ }
- /* Your custom cleanup here */
- cl_assert_equal_i(8, global_test_counter);
+ selftest_suite_directory = argv[1];
+ memmove(argv + 1, argv + 2, argc - 1);
+ argc -= 1;
- return ret;
+ return clar_test(argc, argv);
}