Skip to content

Commit 683433b

Browse files
committed
t/harness: avoid tests outside the src tree
[perl #124050] t/harness can mistakenly run tests outside of the perl source tree cfa5625 made t/harness prepend '../' to test filenames if such a file existed. This allowed things like ./perl t/harness cpan/foo/t/foo.t to work even after harness had done a chdir("t"). However, it was then picking up a ../cpan/foo/t/foo.t file outside the src tree in preference to the one inside. Add belt-and-brace conditions: only modify the filename if the unmodified file doesn't exist, and only only if it doesn't already start with ../. Based on an earlier patch by Matthew Horsfall
1 parent ba3530a commit 683433b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

t/harness

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ if ($^O eq 'MSWin32') {
188188

189189
# Allow eg ./perl t/harness t/op/lc.t
190190
for (@tests) {
191-
if (-f "../$_") {
191+
if (! -f $_ && !/^\.\./ && -f "../$_") {
192192
$_ = "../$_";
193193
s{^\.\./t/}{};
194194
}

0 commit comments

Comments
 (0)