Since the "test-tool read-cache" was originally added back in 1ecb5ff141 (read-cache: add simple performance test, 2013-06-09) it's been growing all sorts of bells and whistles that aren't very conducive to performance testing the index, e.g. it learned how to read config. Let's split what remains of the "test-tool read-cache" into the two narrow use-cases it's used for. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> --- Makefile | 3 ++- t/helper/test-read-cache-again.c | 31 +++++++++++++++++++++++++ t/helper/test-read-cache-perf.c | 21 +++++++++++++++++ t/helper/test-read-cache.c | 39 -------------------------------- t/helper/test-tool.c | 3 ++- t/helper/test-tool.h | 3 ++- t/perf/p0002-read-cache.sh | 2 +- t/t7519-status-fsmonitor.sh | 2 +- 8 files changed, 60 insertions(+), 44 deletions(-) create mode 100644 t/helper/test-read-cache-again.c create mode 100644 t/helper/test-read-cache-perf.c delete mode 100644 t/helper/test-read-cache.c diff --git a/Makefile b/Makefile index 89b1d53741..a1bbb818d9 100644 --- a/Makefile +++ b/Makefile @@ -724,7 +724,8 @@ TEST_BUILTINS_OBJS += test-prio-queue.o TEST_BUILTINS_OBJS += test-proc-receive.o TEST_BUILTINS_OBJS += test-progress.o TEST_BUILTINS_OBJS += test-reach.o -TEST_BUILTINS_OBJS += test-read-cache.o +TEST_BUILTINS_OBJS += test-read-cache-again.o +TEST_BUILTINS_OBJS += test-read-cache-perf.o TEST_BUILTINS_OBJS += test-read-graph.o TEST_BUILTINS_OBJS += test-read-midx.o TEST_BUILTINS_OBJS += test-ref-store.o diff --git a/t/helper/test-read-cache-again.c b/t/helper/test-read-cache-again.c new file mode 100644 index 0000000000..5e20ca1c8f --- /dev/null +++ b/t/helper/test-read-cache-again.c @@ -0,0 +1,31 @@ +#include "test-tool.h" +#include "cache.h" + +int cmd__read_cache_again(int argc, const char **argv) +{ + struct repository *r = the_repository; + int cnt; + const char *name; + + if (argc != 2) + die("usage: test-tool read-cache-again <count> <file>"); + + cnt = strtol(argv[0], NULL, 0); + name = argv[2]; + + setup_git_directory(); + while (cnt--) { + int pos; + repo_read_index(r); + refresh_index(r->index, REFRESH_QUIET, + NULL, NULL, NULL); + pos = index_name_pos(r->index, name, strlen(name)); + if (pos < 0) + die("%s not in index", name); + printf("%s is%s up to date\n", name, + ce_uptodate(r->index->cache[pos]) ? "" : " not"); + write_file(name, "%d\n", cnt); + discard_index(r->index); + } + return 0; +} diff --git a/t/helper/test-read-cache-perf.c b/t/helper/test-read-cache-perf.c new file mode 100644 index 0000000000..ac9c297efa --- /dev/null +++ b/t/helper/test-read-cache-perf.c @@ -0,0 +1,21 @@ +#include "test-tool.h" +#include "cache.h" + +int cmd__read_cache_perf(int argc, const char **argv) +{ + struct repository *r = the_repository; + int cnt = 1000; + + if (argc == 1) + cnt = strtol(argv[0], NULL, 0); + else if (argc) + die("usage: test-tool read-cache-perf [<count>]"); + + setup_git_directory(); + while (cnt--) { + repo_read_index(r); + discard_index(r->index); + } + + return 0; +} diff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c deleted file mode 100644 index 2499999af3..0000000000 --- a/t/helper/test-read-cache.c +++ /dev/null @@ -1,39 +0,0 @@ -#include "test-tool.h" -#include "cache.h" -#include "config.h" - -int cmd__read_cache(int argc, const char **argv) -{ - struct repository *r = the_repository; - int i, cnt = 1; - const char *name = NULL; - - for (++argv, --argc; *argv && starts_with(*argv, "--"); ++argv, --argc) { - if (skip_prefix(*argv, "--print-and-refresh=", &name)) - continue; - } - - if (argc == 1) - cnt = strtol(argv[0], NULL, 0); - setup_git_directory(); - git_config(git_default_config, NULL); - - for (i = 0; i < cnt; i++) { - repo_read_index(r); - - if (name) { - int pos; - - refresh_index(r->index, REFRESH_QUIET, - NULL, NULL, NULL); - pos = index_name_pos(r->index, name, strlen(name)); - if (pos < 0) - die("%s not in index", name); - printf("%s is%s up to date\n", name, - ce_uptodate(r->index->cache[pos]) ? "" : " not"); - write_file(name, "%d\n", i); - } - discard_index(r->index); - } - return 0; -} diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c index f97cd9f48a..1334fa25ba 100644 --- a/t/helper/test-tool.c +++ b/t/helper/test-tool.c @@ -52,7 +52,8 @@ static struct test_cmd cmds[] = { { "proc-receive", cmd__proc_receive}, { "progress", cmd__progress }, { "reach", cmd__reach }, - { "read-cache", cmd__read_cache }, + { "read-cache-again", cmd__read_cache_again }, + { "read-cache-perf", cmd__read_cache_perf }, { "read-graph", cmd__read_graph }, { "read-midx", cmd__read_midx }, { "ref-store", cmd__ref_store }, diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h index 28072c0ad5..d70cde8574 100644 --- a/t/helper/test-tool.h +++ b/t/helper/test-tool.h @@ -41,7 +41,8 @@ int cmd__prio_queue(int argc, const char **argv); int cmd__proc_receive(int argc, const char **argv); int cmd__progress(int argc, const char **argv); int cmd__reach(int argc, const char **argv); -int cmd__read_cache(int argc, const char **argv); +int cmd__read_cache_again(int argc, const char **argv); +int cmd__read_cache_perf(int argc, const char **argv); int cmd__read_graph(int argc, const char **argv); int cmd__read_midx(int argc, const char **argv); int cmd__ref_store(int argc, const char **argv); diff --git a/t/perf/p0002-read-cache.sh b/t/perf/p0002-read-cache.sh index cdd105a594..d0ba5173fb 100755 --- a/t/perf/p0002-read-cache.sh +++ b/t/perf/p0002-read-cache.sh @@ -8,7 +8,7 @@ test_perf_default_repo count=1000 test_perf "read_cache/discard_cache $count times" " - test-tool read-cache $count + test-tool read-cache-perf $count " test_done diff --git a/t/t7519-status-fsmonitor.sh b/t/t7519-status-fsmonitor.sh index 45d025f960..3761a8781d 100755 --- a/t/t7519-status-fsmonitor.sh +++ b/t/t7519-status-fsmonitor.sh @@ -359,7 +359,7 @@ test_expect_success UNTRACKED_CACHE 'ignore .git changes when invalidating UNTR' test_expect_success 'discard_index() also discards fsmonitor info' ' test_config core.fsmonitor "$TEST_DIRECTORY/t7519/fsmonitor-all" && test_might_fail git update-index --refresh && - test-tool read-cache --print-and-refresh=tracked 2 >actual && + test-tool read-cache-again 2 tracked >actual && printf "tracked is%s up to date\n" "" " not" >expect && test_cmp expect actual ' -- 2.31.0.260.g719c683c1d