diff options
Diffstat (limited to 'tests/diff/workdir.c')
-rw-r--r-- | tests/diff/workdir.c | 60 |
1 files changed, 20 insertions, 40 deletions
diff --git a/tests/diff/workdir.c b/tests/diff/workdir.c index 952c9022b..a6d48abc6 100644 --- a/tests/diff/workdir.c +++ b/tests/diff/workdir.c @@ -1,28 +1,13 @@ #include "clar_libgit2.h" #include "diff_helpers.h" #include "repository.h" +#include "git2/sys/diff.h" static git_repository *g_repo = NULL; -#ifdef GIT_TRACE -static diff_perf g_diff_perf; -#endif - -void test_diff_workdir__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 -} - void test_diff_workdir__cleanup(void) { cl_git_sandbox_cleanup(); -#ifdef GIT_TRACE - cl_git_pass(git_trace_set(GIT_TRACE_NONE, NULL, NULL)); -#endif } void test_diff_workdir__to_index(void) @@ -70,13 +55,14 @@ void test_diff_workdir__to_index(void) cl_assert_equal_i(5, exp.line_ctxt); cl_assert_equal_i(4, exp.line_adds); cl_assert_equal_i(5, exp.line_dels); + } -#ifdef GIT_TRACE + { + git_diff_perfdata perf = GIT_DIFF_PERFDATA_INIT; + cl_git_pass(git_diff_get_perfdata(&perf, diff)); cl_assert_equal_sz( - 13 /* in root */ + 3 /* in subdir */, 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); -#endif + 13 /* in root */ + 3 /* in subdir */, perf.stat_calls); + cl_assert_equal_sz(5, perf.oid_calculations); } git_diff_free(diff); @@ -1532,10 +1518,6 @@ static void basic_diff_status(git_diff **out, const git_diff_options *opts) { diff_expects exp; -#ifdef GIT_TRACE - memset(&g_diff_perf, 0, sizeof(g_diff_perf)); -#endif - cl_git_pass(git_diff_index_to_workdir(out, g_repo, NULL, opts)); memset(&exp, 0, sizeof(exp)); @@ -1555,6 +1537,7 @@ void test_diff_workdir__can_update_index(void) { git_diff_options opts = GIT_DIFF_OPTIONS_INIT; git_diff *diff = NULL; + git_diff_perfdata perf = GIT_DIFF_PERFDATA_INIT; g_repo = cl_git_sandbox_init("status"); @@ -1569,11 +1552,10 @@ void test_diff_workdir__can_update_index(void) opts.flags |= GIT_DIFF_INCLUDE_IGNORED | GIT_DIFF_INCLUDE_UNTRACKED; basic_diff_status(&diff, &opts); -#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); -#endif + + cl_git_pass(git_diff_get_perfdata(&perf, diff)); + cl_assert_equal_sz(13 + 3, perf.stat_calls); + cl_assert_equal_sz(5, perf.oid_calculations); git_diff_free(diff); @@ -1581,22 +1563,20 @@ void test_diff_workdir__can_update_index(void) opts.flags |= GIT_DIFF_UPDATE_INDEX; basic_diff_status(&diff, &opts); -#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); -#endif + + cl_git_pass(git_diff_get_perfdata(&perf, diff)); + cl_assert_equal_sz(13 + 3, perf.stat_calls); + cl_assert_equal_sz(5, perf.oid_calculations); git_diff_free(diff); /* now if we do it again, we should see fewer OID calculations */ basic_diff_status(&diff, &opts); -#ifdef GIT_TRACE - cl_assert_equal_sz(13 + 3, g_diff_perf.stat_calls); - cl_assert_equal_sz(0, g_diff_perf.oid_calcs); /* Yay */ - cl_assert_equal_sz(1, g_diff_perf.submodule_lookups); -#endif + + cl_git_pass(git_diff_get_perfdata(&perf, diff)); + cl_assert_equal_sz(13 + 3, perf.stat_calls); + cl_assert_equal_sz(0, perf.oid_calculations); git_diff_free(diff); } |