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 <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>
Nguyễn Thái Ngọc Duy committed
Jun 25, 2016 at 07:22 UTC
949782d860889cbd50edfdf8c00e91d7a4f6cb05
2 files changed
+11
-3
t/t0070-fundamental.sh
+1
-1
@@ -31,7 +31,7 @@ test_expect_success 'git_mkstemps_mode does not fail if fd 0 is not open' '
31
32
test_expect_success 'check for a bug in the regex routines' '
33
# if this test fails, re-build git with NO_REGEX=1
34
- test-regex
34
+ test-regex --bug
35
'
36
37
test_done
test-regex.c
+10
-2
@@ -1,6 +1,6 @@
1
#include "git-compat-util.h"
2
3
-int main(int argc, char **argv)
3
+static int test_regex_bug(void)
4
{
5
char *pat = "[^={} \t]+";
6
char *str = "={}\nfred";
@@ -16,5 +16,13 @@ int main(int argc, char **argv)
16
if (m[0].rm_so == 3) /* matches '\n' when it should not */
17
die("regex bug confirmed: re-build git with NO_REGEX=1");
18
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");
28
}