Skip to content

Commit

Permalink
test-regex: isolate the bug test code
Browse files Browse the repository at this point in the history
This is in preparation to turn test-regex into some generic regex
testing command.

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Helped-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
pclouds authored and gitster committed Jun 27, 2016
1 parent 60452a3 commit 949782d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion t/t0070-fundamental.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test_expect_success 'git_mkstemps_mode does not fail if fd 0 is not open' '

test_expect_success 'check for a bug in the regex routines' '
# if this test fails, re-build git with NO_REGEX=1
test-regex
test-regex --bug
'

test_done
12 changes: 10 additions & 2 deletions test-regex.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "git-compat-util.h"

int main(int argc, char **argv)
static int test_regex_bug(void)
{
char *pat = "[^={} \t]+";
char *str = "={}\nfred";
Expand All @@ -16,5 +16,13 @@ int main(int argc, char **argv)
if (m[0].rm_so == 3) /* matches '\n' when it should not */
die("regex bug confirmed: re-build git with NO_REGEX=1");

exit(0);
return 0;
}

int main(int argc, char **argv)
{
if (argc == 2 && !strcmp(argv[1], "--bug"))
return test_regex_bug();
else
usage("test-regex --bug");
}

0 comments on commit 949782d

Please sign in to comment.