Commit b7f70bc25d62bf2bb9af2c050b3be9186aa289e3

Edward Thomson 2019-11-27T12:36:17

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.

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);