Skip to content

Commit

Permalink
test-tool: rename sha1-array to oid-array
Browse files Browse the repository at this point in the history
This matches the actual data structure name, as well as the source file
that contains the code we're testing. The test scripts need updating to
use the new name, as well.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
peff authored and gitster committed Mar 30, 2020
1 parent fe299ec commit ed4b804
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ TEST_BUILTINS_OBJS += test-run-command.o
TEST_BUILTINS_OBJS += test-scrap-cache-tree.o
TEST_BUILTINS_OBJS += test-serve-v2.o
TEST_BUILTINS_OBJS += test-sha1.o
TEST_BUILTINS_OBJS += test-sha1-array.o
TEST_BUILTINS_OBJS += test-oid-array.o
TEST_BUILTINS_OBJS += test-sha256.o
TEST_BUILTINS_OBJS += test-sigchain.o
TEST_BUILTINS_OBJS += test-strcmp-offset.o
Expand Down
6 changes: 3 additions & 3 deletions t/helper/test-sha1-array.c → t/helper/test-oid-array.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ static int print_oid(const struct object_id *oid, void *data)
return 0;
}

int cmd__sha1_array(int argc, const char **argv)
int cmd__oid_array(int argc, const char **argv)
{
struct oid_array array = OID_ARRAY_INIT;
struct strbuf line = STRBUF_INIT;
Expand All @@ -19,11 +19,11 @@ int cmd__sha1_array(int argc, const char **argv)

if (skip_prefix(line.buf, "append ", &arg)) {
if (get_oid_hex(arg, &oid))
die("not a hexadecimal SHA1: %s", arg);
die("not a hexadecimal oid: %s", arg);
oid_array_append(&array, &oid);
} else if (skip_prefix(line.buf, "lookup ", &arg)) {
if (get_oid_hex(arg, &oid))
die("not a hexadecimal SHA1: %s", arg);
die("not a hexadecimal oid: %s", arg);
printf("%d\n", oid_array_lookup(&array, &oid));
} else if (!strcmp(line.buf, "clear"))
oid_array_clear(&array);
Expand Down
2 changes: 1 addition & 1 deletion t/helper/test-tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ static struct test_cmd cmds[] = {
{ "match-trees", cmd__match_trees },
{ "mergesort", cmd__mergesort },
{ "mktemp", cmd__mktemp },
{ "oid-array", cmd__oid_array },
{ "oidmap", cmd__oidmap },
{ "online-cpus", cmd__online_cpus },
{ "parse-options", cmd__parse_options },
Expand All @@ -56,7 +57,6 @@ static struct test_cmd cmds[] = {
{ "scrap-cache-tree", cmd__scrap_cache_tree },
{ "serve-v2", cmd__serve_v2 },
{ "sha1", cmd__sha1 },
{ "sha1-array", cmd__sha1_array },
{ "sha256", cmd__sha256 },
{ "sigchain", cmd__sigchain },
{ "strcmp-offset", cmd__strcmp_offset },
Expand Down
2 changes: 1 addition & 1 deletion t/helper/test-tool.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int cmd__run_command(int argc, const char **argv);
int cmd__scrap_cache_tree(int argc, const char **argv);
int cmd__serve_v2(int argc, const char **argv);
int cmd__sha1(int argc, const char **argv);
int cmd__sha1_array(int argc, const char **argv);
int cmd__oid_array(int argc, const char **argv);
int cmd__sha256(int argc, const char **argv);
int cmd__sigchain(int argc, const char **argv);
int cmd__strcmp_offset(int argc, const char **argv);
Expand Down
16 changes: 8 additions & 8 deletions t/t0064-sha1-array.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test_expect_success 'ordered enumeration' '
{
echoid append 88 44 aa 55 &&
echo for_each_unique
} | test-tool sha1-array >actual &&
} | test-tool oid-array >actual &&
test_cmp expect actual
'

Expand All @@ -28,15 +28,15 @@ test_expect_success 'ordered enumeration with duplicate suppression' '
echoid append 88 44 aa 55 &&
echoid append 88 44 aa 55 &&
echo for_each_unique
} | test-tool sha1-array >actual &&
} | test-tool oid-array >actual &&
test_cmp expect actual
'

test_expect_success 'lookup' '
{
echoid append 88 44 aa 55 &&
echoid lookup 55
} | test-tool sha1-array >actual &&
} | test-tool oid-array >actual &&
n=$(cat actual) &&
test "$n" -eq 1
'
Expand All @@ -45,7 +45,7 @@ test_expect_success 'lookup non-existing entry' '
{
echoid append 88 44 aa 55 &&
echoid lookup 33
} | test-tool sha1-array >actual &&
} | test-tool oid-array >actual &&
n=$(cat actual) &&
test "$n" -lt 0
'
Expand All @@ -55,7 +55,7 @@ test_expect_success 'lookup with duplicates' '
echoid append 88 44 aa 55 &&
echoid append 88 44 aa 55 &&
echoid lookup 55
} | test-tool sha1-array >actual &&
} | test-tool oid-array >actual &&
n=$(cat actual) &&
test "$n" -ge 2 &&
test "$n" -le 3
Expand All @@ -66,7 +66,7 @@ test_expect_success 'lookup non-existing entry with duplicates' '
echoid append 88 44 aa 55 &&
echoid append 88 44 aa 55 &&
echoid lookup 66
} | test-tool sha1-array >actual &&
} | test-tool oid-array >actual &&
n=$(cat actual) &&
test "$n" -lt 0
'
Expand All @@ -81,7 +81,7 @@ test_expect_success 'lookup with almost duplicate values' '
echo "append $id1" &&
echo "append $id2" &&
echoid lookup 55
} | test-tool sha1-array >actual &&
} | test-tool oid-array >actual &&
n=$(cat actual) &&
test "$n" -eq 0
'
Expand All @@ -90,7 +90,7 @@ test_expect_success 'lookup with single duplicate value' '
{
echoid append 55 55 &&
echoid lookup 55
} | test-tool sha1-array >actual &&
} | test-tool oid-array >actual &&
n=$(cat actual) &&
test "$n" -ge 0 &&
test "$n" -le 1
Expand Down

0 comments on commit ed4b804

Please sign in to comment.