Skip to content

Commit 949782d

Browse files
pcloudsgitster
authored andcommitted
test-regex: isolate the bug test code
This is in preparation to turn test-regex into some generic regex testing command. Helped-by: Eric Sunshine <[email protected]> Helped-by: Ramsay Jones <[email protected]> Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 60452a3 commit 949782d

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

t/t0070-fundamental.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ test_expect_success 'git_mkstemps_mode does not fail if fd 0 is not open' '
3131

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

3737
test_done

test-regex.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "git-compat-util.h"
22

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

19-
exit(0);
19+
return 0;
20+
}
21+
22+
int main(int argc, char **argv)
23+
{
24+
if (argc == 2 && !strcmp(argv[1], "--bug"))
25+
return test_regex_bug();
26+
else
27+
usage("test-regex --bug");
2028
}

0 commit comments

Comments
 (0)