tests: optionally show test execution tracing Only show test trace execution when the CLAR_TRACE_TESTS environment variable is set. This reduces the noise during tracing.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
diff --git a/tests/clar_libgit2_trace.c b/tests/clar_libgit2_trace.c
index eb2fbbd..83c83b9 100644
--- a/tests/clar_libgit2_trace.c
+++ b/tests/clar_libgit2_trace.c
@@ -71,7 +71,7 @@ static struct method s_methods[] = {
static int s_trace_loaded = 0;
static int s_trace_level = GIT_TRACE_NONE;
static struct method *s_trace_method = NULL;
-
+static int s_trace_tests = 0;
static int set_method(const char *name)
{
@@ -117,6 +117,7 @@ static void _load_trace_params(void)
{
char *sz_level;
char *sz_method;
+ char *sz_tests;
s_trace_loaded = 1;
@@ -133,6 +134,10 @@ static void _load_trace_params(void)
sz_method = cl_getenv("CLAR_TRACE_METHOD");
if (set_method(sz_method) < 0)
set_method(NULL);
+
+ sz_tests = cl_getenv("CLAR_TRACE_TESTS");
+ if (sz_tests != NULL)
+ s_trace_tests = 1;
}
#define HR "================================================================"
@@ -155,6 +160,9 @@ void _cl_trace_cb__event_handler(
{
GIT_UNUSED(payload);
+ if (!s_trace_tests)
+ return;
+
switch (ev) {
case CL_TRACE__SUITE_BEGIN:
git_trace(GIT_TRACE_TRACE, "\n\n%s\n%s: Begin Suite", HR, suite_name);