From c932a5ff2880a23f3f28823768a58b17b675d276 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sat, 24 Mar 2018 08:45:00 +0100 Subject: [PATCH] t/helper: merge test-string-list into test-tool MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- Makefile | 2 +- t/helper/test-string-list.c | 3 +- t/helper/test-tool.c | 1 + t/helper/test-tool.h | 1 + t/perf/p0071-sort.sh | 2 +- t/t0063-string-list.sh | 182 ++++++++++++++++++++++---------------------- 6 files changed, 97 insertions(+), 94 deletions(-) rewrite t/t0063-string-list.sh (62%) diff --git a/Makefile b/Makefile index 528a80b6a6..6819792c2b 100644 --- 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 diff --git a/t/helper/test-string-list.c b/t/helper/test-string-list.c index 829ec3d7d2..2123dda85b 100644 --- a/t/helper/test-string-list.c +++ b/t/helper/test-string-list.c @@ -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; diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c index 6acbf976d8..c67307c28b 100644 --- a/t/helper/test-tool.c +++ b/t/helper/test-tool.c @@ -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) diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h index 035e82ec6a..19ad2b0df8 100644 --- a/t/helper/test-tool.h +++ b/t/helper/test-tool.h @@ -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 diff --git a/t/perf/p0071-sort.sh b/t/perf/p0071-sort.sh index 7c9a35a646..6e924f5fa3 100755 --- a/t/perf/p0071-sort.sh +++ b/t/perf/p0071-sort.sh @@ -16,7 +16,7 @@ test_perf 'sort(1)' ' ' test_perf 'string_list_sort()' ' - test-string-list sort actual + test-tool string-list sort actual ' test_expect_success 'string_list_sort() sorts like sort(1)' ' diff --git a/t/t0063-string-list.sh b/t/t0063-string-list.sh dissimilarity index 62% index dbfc05ebdc..c6ee9f66b1 100755 --- a/t/t0063-string-list.sh +++ b/t/t0063-string-list.sh @@ -1,91 +1,91 @@ -#!/bin/sh -# -# Copyright (c) 2012 Michael Haggerty -# - -test_description='Test string list functionality' - -. ./test-lib.sh - -test_split () { - cat >expected && - test_expect_success "split $1 at $2, max $3" " - test-string-list split '$1' '$2' '$3' >actual && - test_cmp expected actual && - test-string-list split_in_place '$1' '$2' '$3' >actual && - test_cmp expected actual - " -} - -test_split "foo:bar:baz" ":" "-1" <expected && + test_expect_success "split $1 at $2, max $3" " + test-tool string-list split '$1' '$2' '$3' >actual && + test_cmp expected actual && + test-tool string-list split_in_place '$1' '$2' '$3' >actual && + test_cmp expected actual + " +} + +test_split "foo:bar:baz" ":" "-1" <