diff options
| author | Russell Belfer <rb@github.com> | 2014-04-29 15:05:58 -0700 |
|---|---|---|
| committer | Russell Belfer <rb@github.com> | 2014-05-02 09:21:33 -0700 |
| commit | 9c8ed4999740e921ecc2966bbcd0dbcfc725f59a (patch) | |
| tree | cf801e2026c9fca6b4e28bfc2c35e981d9ccea6e /tests/status/worktree.c | |
| parent | 7a2e56a3f6115c3a145e4f73d0aa8bea6dded899 (diff) | |
| download | libgit2-9c8ed4999740e921ecc2966bbcd0dbcfc725f59a.tar.gz | |
Remove trace / add git_diff_perfdata struct + api
Diffstat (limited to 'tests/status/worktree.c')
| -rw-r--r-- | tests/status/worktree.c | 75 |
1 files changed, 36 insertions, 39 deletions
diff --git a/tests/status/worktree.c b/tests/status/worktree.c index 06864ad59..ca9068aba 100644 --- a/tests/status/worktree.c +++ b/tests/status/worktree.c @@ -6,19 +6,7 @@ #include "util.h" #include "path.h" #include "../diff/diff_helpers.h" - -#ifdef GIT_TRACE -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_PERF, diff_perf_track_stats, &g_diff_perf)); -#endif -} +#include "git2/sys/diff.h" /** * Cleanup @@ -29,9 +17,6 @@ void test_status_worktree__initialize(void) void test_status_worktree__cleanup(void) { cl_git_sandbox_cleanup(); -#ifdef GIT_TRACE - cl_git_pass(git_trace_set(GIT_TRACE_NONE, NULL, NULL)); -#endif } /** @@ -903,38 +888,50 @@ void test_status_worktree__long_filenames(void) * while reducing the amount of work that needs to be done */ +static void check_status0(git_status_list *status) +{ + size_t i, max_i = git_status_list_entrycount(status); + cl_assert_equal_sz(entry_count0, max_i); + for (i = 0; i < max_i; ++i) { + const git_status_entry *entry = git_status_byindex(status, i); + cl_assert_equal_i(entry_statuses0[i], entry->status); + } +} + void test_status_worktree__update_stat_cache_0(void) { git_repository *repo = cl_git_sandbox_init("status"); + git_status_options opts = GIT_STATUS_OPTIONS_INIT; + git_status_list *status; + git_diff_perfdata perf = GIT_DIFF_PERFDATA_INIT; - assert_show(entry_count0, entry_paths0, entry_statuses0, - repo, GIT_STATUS_SHOW_INDEX_AND_WORKDIR, 0); + opts.flags = GIT_STATUS_OPT_DEFAULTS; -#ifdef GIT_TRACE - cl_assert_equal_sz(13 + 3, g_diff_perf.stat_calls); - cl_assert_equal_sz(5, g_diff_perf.oid_calcs); - cl_assert_equal_sz(1, g_diff_perf.submodule_lookups); + cl_git_pass(git_status_list_new(&status, repo, &opts)); + check_status0(status); + cl_git_pass(git_status_list_get_perfdata(&perf, status)); + cl_assert_equal_sz(13 + 3, perf.stat_calls); + cl_assert_equal_sz(5, perf.oid_calculations); - memset(&g_diff_perf, 0, sizeof(g_diff_perf)); -#endif + git_status_list_free(status); - assert_show(entry_count0, entry_paths0, entry_statuses0, - repo, GIT_STATUS_SHOW_INDEX_AND_WORKDIR, GIT_STATUS_OPT_UPDATE_INDEX); + opts.flags |= GIT_STATUS_OPT_UPDATE_INDEX; + + cl_git_pass(git_status_list_new(&status, repo, &opts)); + check_status0(status); + cl_git_pass(git_status_list_get_perfdata(&perf, status)); + cl_assert_equal_sz(13 + 3, perf.stat_calls); + cl_assert_equal_sz(5, perf.oid_calculations); -#ifdef GIT_TRACE - cl_assert_equal_sz(13 + 3, g_diff_perf.stat_calls); - cl_assert_equal_sz(5, g_diff_perf.oid_calcs); - cl_assert_equal_sz(1, g_diff_perf.submodule_lookups); + git_status_list_free(status); - memset(&g_diff_perf, 0, sizeof(g_diff_perf)); -#endif + opts.flags &= ~GIT_STATUS_OPT_UPDATE_INDEX; - assert_show(entry_count0, entry_paths0, entry_statuses0, - repo, GIT_STATUS_SHOW_INDEX_AND_WORKDIR, 0); + cl_git_pass(git_status_list_new(&status, repo, &opts)); + check_status0(status); + cl_git_pass(git_status_list_get_perfdata(&perf, status)); + cl_assert_equal_sz(13 + 3, perf.stat_calls); + cl_assert_equal_sz(0, perf.oid_calculations); -#ifdef GIT_TRACE - 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); -#endif + git_status_list_free(status); } |
