Skip to content

Commit 839b639

Browse files
peffgitster
authored andcommitted
t9700: fix test for perl older than 5.14
Commit d53c2c6 (mingw: fix t9700's assumption about directory separators, 2016-01-27) uses perl's "/r" regex modifier to do a non-destructive replacement on a string, leaving the original unmodified and returning the result. This feature was introduced in perl 5.14, but systems with older perl are still common (e.g., CentOS 6.5 still has perl 5.10). Let's work around it by providing a helper function that does the same thing using older syntax. While we're at it, let's switch to using an alternate regex separator, which is slightly more readable. Reported-by: Christian Couder <[email protected]> Helped-by: Dennis Kaarsemaker <[email protected]> Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 80ce6c2 commit 839b639

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

t/t9700/test.pl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ BEGIN
1717
use Cwd;
1818
use File::Basename;
1919

20+
sub adjust_dirsep {
21+
my $path = shift;
22+
$path =~ s{\\}{/}g;
23+
return $path;
24+
}
25+
2026
BEGIN { use_ok('Git') }
2127

2228
# set up
@@ -33,7 +39,7 @@ BEGIN
3339
is($r->config_int("test.nonexistent"), undef, "config_int: nonexistent");
3440
ok($r->config_bool("test.booltrue"), "config_bool: true");
3541
ok(!$r->config_bool("test.boolfalse"), "config_bool: false");
36-
is($r->config_path("test.path") =~ s/\\/\//gr, $r->config("test.pathexpanded"),
42+
is(adjust_dirsep($r->config_path("test.path")), $r->config("test.pathexpanded"),
3743
"config_path: ~/foo expansion");
3844
is_deeply([$r->config_path("test.pathmulti")], ["foo", "bar"],
3945
"config_path: multiple values");

0 commit comments

Comments
 (0)