Skip to content

Commit

Permalink
t9700: fix test for perl older than 5.14
Browse files Browse the repository at this point in the history
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 <christian.couder@gmail.com>
Helped-by: Dennis Kaarsemaker <dennis@kaarsemaker.net>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Mar 4, 2016
1 parent 80ce6c2 commit 839b639
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion t/t9700/test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ BEGIN
use Cwd;
use File::Basename;

sub adjust_dirsep {
my $path = shift;
$path =~ s{\\}{/}g;
return $path;
}

BEGIN { use_ok('Git') }

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

0 comments on commit 839b639

Please sign in to comment.