summaryrefslogtreecommitdiff
path: root/tests/status
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-04-29 11:29:49 -0700
committerRussell Belfer <rb@github.com>2014-05-02 09:21:33 -0700
commitb23b112dfe8eceb39eaaea2d5e60d971c4371aa0 (patch)
tree56a6c981856e5f1bf830c3b647a8a58838b044f5 /tests/status
parent225aab5d6a611076b22f00ae5a28184d92b5259c (diff)
downloadlibgit2-b23b112dfe8eceb39eaaea2d5e60d971c4371aa0.tar.gz
Add payloads, bitmaps to trace API
This is a proposed adjustment to the trace APIs. This makes the trace levels into a bitmask so that they can be selectively enabled and adds a callback-level payload, plus a message-level payload. This makes it easier for me to a GIT_TRACE_PERF callbacks that are simply bypassed if the PERF level is not set.
Diffstat (limited to 'tests/status')
-rw-r--r--tests/status/worktree.c32
1 files changed, 5 insertions, 27 deletions
diff --git a/tests/status/worktree.c b/tests/status/worktree.c
index c1d6be982..06864ad59 100644
--- a/tests/status/worktree.c
+++ b/tests/status/worktree.c
@@ -5,38 +5,18 @@
#include "posix.h"
#include "util.h"
#include "path.h"
-#include <git2/trace.h>
+#include "../diff/diff_helpers.h"
#ifdef GIT_TRACE
-static struct {
- size_t stat_calls;
- size_t oid_calcs;
- size_t submodule_lookups;
-} g_diff_perf;
-
-static void add_stats(git_trace_level_t level, const char *msg)
-{
- const char *assign = strchr(msg, '=');
-
- GIT_UNUSED(level);
-
- if (!assign)
- return;
-
- if (!strncmp("stat", msg, (assign - msg)))
- g_diff_perf.stat_calls += atoi(assign + 1);
- else if (!strncmp("submodule_lookup", msg, (assign - msg)))
- g_diff_perf.submodule_lookups += atoi(assign + 1);
- else if (!strncmp("oid_calculation", msg, (assign - msg)))
- g_diff_perf.oid_calcs += atoi(assign + 1);
-}
+static diff_perf g_diff_perf;
#endif
void test_status_worktree__initialize(void)
{
#ifdef GIT_TRACE
memset(&g_diff_perf, 0, sizeof(g_diff_perf));
- cl_git_pass(git_trace_set(GIT_TRACE_TRACE, add_stats));
+ cl_git_pass(git_trace_set(
+ GIT_TRACE_PERF, diff_perf_track_stats, &g_diff_perf));
#endif
}
@@ -50,7 +30,7 @@ void test_status_worktree__cleanup(void)
{
cl_git_sandbox_cleanup();
#ifdef GIT_TRACE
- cl_git_pass(git_trace_set(0, NULL));
+ cl_git_pass(git_trace_set(GIT_TRACE_NONE, NULL, NULL));
#endif
}
@@ -956,7 +936,5 @@ void test_status_worktree__update_stat_cache_0(void)
cl_assert_equal_sz(13 + 3, g_diff_perf.stat_calls);
cl_assert_equal_sz(0, g_diff_perf.oid_calcs);
cl_assert_equal_sz(1, g_diff_perf.submodule_lookups);
-
- memset(&g_diff_perf, 0, sizeof(g_diff_perf));
#endif
}