Skip to content

Commit 0502663

Browse files
spectre10gitster
authored andcommitted
t: migrate t0110-urlmatch-normalization to the new framework
helper/test-urlmatch-normalization along with t0110-urlmatch-normalization test the `url_normalize()` function from 'urlmatch.h'. Migrate them to the unit testing framework for better performance. And also add different test_msg()s for better debugging. In the migration, last two of the checks from `t_url_general_escape()` were slightly changed compared to the shell script. This involves changing '\'' -> ' '\!' -> ! in the urls of those checks. This is because in C strings, we don't need to escape "'" and "!". Other than these two, all the urls were pasted verbatim from the shell script. Another change is the removal of a MINGW prerequisite from one of the test. It was there because[1] on Windows, the command line is a Unicode string, it is not possible to pass arbitrary bytes to a program. But in unit tests we don't have this limitation. And since we can construct strings with arbitrary bytes in C, let's also remove the test files which contain URLs with arbitrary bytes in the 't/t0110' directory and instead embed those URLs in the unit test code itself. [1]: https://lore.kernel.org/git/[email protected]/ Mentored-by: Christian Couder <[email protected]> Mentored-by: Kaartic Sivaraam <[email protected]> Signed-off-by: Ghanshyam Thakkar <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 25673b1 commit 0502663

18 files changed

+272
-261
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,6 @@ TEST_BUILTINS_OBJS += test-submodule.o
843843
TEST_BUILTINS_OBJS += test-subprocess.o
844844
TEST_BUILTINS_OBJS += test-trace2.o
845845
TEST_BUILTINS_OBJS += test-truncate.o
846-
TEST_BUILTINS_OBJS += test-urlmatch-normalization.o
847846
TEST_BUILTINS_OBJS += test-userdiff.o
848847
TEST_BUILTINS_OBJS += test-wildmatch.o
849848
TEST_BUILTINS_OBJS += test-windows-named-pipe.o
@@ -1346,6 +1345,7 @@ UNIT_TEST_PROGRAMS += t-strbuf
13461345
UNIT_TEST_PROGRAMS += t-strcmp-offset
13471346
UNIT_TEST_PROGRAMS += t-strvec
13481347
UNIT_TEST_PROGRAMS += t-trailer
1348+
UNIT_TEST_PROGRAMS += t-urlmatch-normalization
13491349
UNIT_TEST_PROGS = $(patsubst %,$(UNIT_TEST_BIN)/%$X,$(UNIT_TEST_PROGRAMS))
13501350
UNIT_TEST_OBJS = $(patsubst %,$(UNIT_TEST_DIR)/%.o,$(UNIT_TEST_PROGRAMS))
13511351
UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/test-lib.o

t/helper/test-tool.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ static struct test_cmd cmds[] = {
8383
{ "trace2", cmd__trace2 },
8484
{ "truncate", cmd__truncate },
8585
{ "userdiff", cmd__userdiff },
86-
{ "urlmatch-normalization", cmd__urlmatch_normalization },
8786
{ "xml-encode", cmd__xml_encode },
8887
{ "wildmatch", cmd__wildmatch },
8988
#ifdef GIT_WINDOWS_NATIVE

t/helper/test-tool.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ int cmd__subprocess(int argc, const char **argv);
7676
int cmd__trace2(int argc, const char **argv);
7777
int cmd__truncate(int argc, const char **argv);
7878
int cmd__userdiff(int argc, const char **argv);
79-
int cmd__urlmatch_normalization(int argc, const char **argv);
8079
int cmd__xml_encode(int argc, const char **argv);
8180
int cmd__wildmatch(int argc, const char **argv);
8281
#ifdef GIT_WINDOWS_NATIVE

t/helper/test-urlmatch-normalization.c

Lines changed: 0 additions & 56 deletions
This file was deleted.

t/t0110-urlmatch-normalization.sh

Lines changed: 0 additions & 182 deletions
This file was deleted.

t/t0110/README

Lines changed: 0 additions & 9 deletions
This file was deleted.

t/t0110/url-1

Lines changed: 0 additions & 1 deletion
This file was deleted.

t/t0110/url-10

Lines changed: 0 additions & 1 deletion
This file was deleted.

t/t0110/url-11

Lines changed: 0 additions & 1 deletion
This file was deleted.

t/t0110/url-2

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)