]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t/helper: merge test-string-list into test-tool
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sat, 24 Mar 2018 07:45:00 +0000 (08:45 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 27 Mar 2018 15:45:47 +0000 (08:45 -0700)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile
t/helper/test-string-list.c
t/helper/test-tool.c
t/helper/test-tool.h
t/perf/p0071-sort.sh
t/t0063-string-list.sh

index 528a80b6a61e441ca85b2dcb4bebc09e3c2da62a..6819792c2b9d43618f0b22b69662504550fed9c5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -681,6 +681,7 @@ TEST_BUILTINS_OBJS += test-sha1-array.o
 TEST_BUILTINS_OBJS += test-sha1.o
 TEST_BUILTINS_OBJS += test-sigchain.o
 TEST_BUILTINS_OBJS += test-strcmp-offset.o
+TEST_BUILTINS_OBJS += test-string-list.o
 
 TEST_PROGRAMS_NEED_X += test-dump-fsmonitor
 TEST_PROGRAMS_NEED_X += test-dump-untracked-cache
@@ -688,7 +689,6 @@ TEST_PROGRAMS_NEED_X += test-fake-ssh
 TEST_PROGRAMS_NEED_X += test-line-buffer
 TEST_PROGRAMS_NEED_X += test-parse-options
 TEST_PROGRAMS_NEED_X += test-write-cache
-TEST_PROGRAMS_NEED_X += test-string-list
 TEST_PROGRAMS_NEED_X += test-submodule-config
 TEST_PROGRAMS_NEED_X += test-subprocess
 TEST_PROGRAMS_NEED_X += test-svn-fe
index 829ec3d7d2f58b9538bb3bbab47213eddb9e62ec..2123dda85bf10033dcbf0d801028b3705e73a507 100644 (file)
@@ -1,3 +1,4 @@
+#include "test-tool.h"
 #include "cache.h"
 #include "string-list.h"
 
@@ -41,7 +42,7 @@ static int prefix_cb(struct string_list_item *item, void *cb_data)
        return starts_with(item->string, prefix);
 }
 
-int cmd_main(int argc, const char **argv)
+int cmd__string_list(int argc, const char **argv)
 {
        if (argc == 5 && !strcmp(argv[1], "split")) {
                struct string_list list = STRING_LIST_INIT_DUP;
index 6acbf976d8bdf16221ac69d26150fc07005cadf2..c67307c28b8d92feb53d2fd82ae43928cdf0f55f 100644 (file)
@@ -36,6 +36,7 @@ static struct test_cmd cmds[] = {
        { "sha1", cmd__sha1 },
        { "sigchain", cmd__sigchain },
        { "strcmp-offset", cmd__strcmp_offset },
+       { "string-list", cmd__string_list },
 };
 
 int cmd_main(int argc, const char **argv)
index 035e82ec6ad20db3b5eb4917872e599f1978d1a8..19ad2b0df89dd7669b04ee59abfcabf5d6042f5b 100644 (file)
@@ -30,5 +30,6 @@ int cmd__sha1_array(int argc, const char **argv);
 int cmd__sha1(int argc, const char **argv);
 int cmd__sigchain(int argc, const char **argv);
 int cmd__strcmp_offset(int argc, const char **argv);
+int cmd__string_list(int argc, const char **argv);
 
 #endif
index 7c9a35a646a6406e5c284a65748863a93098c2af..6e924f5fa3f900b4b82a55f282e810572a62f20b 100755 (executable)
@@ -16,7 +16,7 @@ test_perf 'sort(1)' '
 '
 
 test_perf 'string_list_sort()' '
-       test-string-list sort <unsorted >actual
+       test-tool string-list sort <unsorted >actual
 '
 
 test_expect_success 'string_list_sort() sorts like sort(1)' '
index dbfc05ebdc3990bf4ea5b0163afb4c6a9e698fa7..c6ee9f66b11d55f312ee673106ddf295c39bb50d 100755 (executable)
@@ -10,9 +10,9 @@ test_description='Test string list functionality'
 test_split () {
        cat >expected &&
        test_expect_success "split $1 at $2, max $3" "
-               test-string-list split '$1' '$2' '$3' >actual &&
+               test-tool string-list split '$1' '$2' '$3' >actual &&
                test_cmp expected actual &&
-               test-string-list split_in_place '$1' '$2' '$3' >actual &&
+               test-tool string-list split_in_place '$1' '$2' '$3' >actual &&
                test_cmp expected actual
        "
 }
@@ -61,31 +61,31 @@ test_split ":" ":" "-1" <<EOF
 EOF
 
 test_expect_success "test filter_string_list" '
-       test "x-" = "x$(test-string-list filter - y)" &&
-       test "x-" = "x$(test-string-list filter no y)" &&
-       test yes = "$(test-string-list filter yes y)" &&
-       test yes = "$(test-string-list filter no:yes y)" &&
-       test yes = "$(test-string-list filter yes:no y)" &&
-       test y1:y2 = "$(test-string-list filter y1:y2 y)" &&
-       test y2:y1 = "$(test-string-list filter y2:y1 y)" &&
-       test "x-" = "x$(test-string-list filter x1:x2 y)"
+       test "x-" = "x$(test-tool string-list filter - y)" &&
+       test "x-" = "x$(test-tool string-list filter no y)" &&
+       test yes = "$(test-tool string-list filter yes y)" &&
+       test yes = "$(test-tool string-list filter no:yes y)" &&
+       test yes = "$(test-tool string-list filter yes:no y)" &&
+       test y1:y2 = "$(test-tool string-list filter y1:y2 y)" &&
+       test y2:y1 = "$(test-tool string-list filter y2:y1 y)" &&
+       test "x-" = "x$(test-tool string-list filter x1:x2 y)"
 '
 
 test_expect_success "test remove_duplicates" '
-       test "x-" = "x$(test-string-list remove_duplicates -)" &&
-       test "x" = "x$(test-string-list remove_duplicates "")" &&
-       test a = "$(test-string-list remove_duplicates a)" &&
-       test a = "$(test-string-list remove_duplicates a:a)" &&
-       test a = "$(test-string-list remove_duplicates a:a:a:a:a)" &&
-       test a:b = "$(test-string-list remove_duplicates a:b)" &&
-       test a:b = "$(test-string-list remove_duplicates a:a:b)" &&
-       test a:b = "$(test-string-list remove_duplicates a:b:b)" &&
-       test a:b:c = "$(test-string-list remove_duplicates a:b:c)" &&
-       test a:b:c = "$(test-string-list remove_duplicates a:a:b:c)" &&
-       test a:b:c = "$(test-string-list remove_duplicates a:b:b:c)" &&
-       test a:b:c = "$(test-string-list remove_duplicates a:b:c:c)" &&
-       test a:b:c = "$(test-string-list remove_duplicates a:a:b:b:c:c)" &&
-       test a:b:c = "$(test-string-list remove_duplicates a:a:a:b:b:b:c:c:c)"
+       test "x-" = "x$(test-tool string-list remove_duplicates -)" &&
+       test "x" = "x$(test-tool string-list remove_duplicates "")" &&
+       test a = "$(test-tool string-list remove_duplicates a)" &&
+       test a = "$(test-tool string-list remove_duplicates a:a)" &&
+       test a = "$(test-tool string-list remove_duplicates a:a:a:a:a)" &&
+       test a:b = "$(test-tool string-list remove_duplicates a:b)" &&
+       test a:b = "$(test-tool string-list remove_duplicates a:a:b)" &&
+       test a:b = "$(test-tool string-list remove_duplicates a:b:b)" &&
+       test a:b:c = "$(test-tool string-list remove_duplicates a:b:c)" &&
+       test a:b:c = "$(test-tool string-list remove_duplicates a:a:b:c)" &&
+       test a:b:c = "$(test-tool string-list remove_duplicates a:b:b:c)" &&
+       test a:b:c = "$(test-tool string-list remove_duplicates a:b:c:c)" &&
+       test a:b:c = "$(test-tool string-list remove_duplicates a:a:b:b:c:c)" &&
+       test a:b:c = "$(test-tool string-list remove_duplicates a:a:a:b:b:b:c:c:c)"
 '
 
 test_done