]> git.ipfire.org Git - thirdparty/make.git/commitdiff
* tests/test_driver.pl: Add cd to the .run output file
authorPaul Smith <psmith@gnu.org>
Sun, 4 Feb 2024 14:47:36 +0000 (09:47 -0500)
committerPaul Smith <psmith@gnu.org>
Sun, 4 Feb 2024 16:34:49 +0000 (11:34 -0500)
tests/test_driver.pl

index e9f343343ae8c777001b9803f1afdd0e7679c17c..9df598c3b60ca6f4351498ebef749cf305ccdcbd 100644 (file)
@@ -184,21 +184,25 @@ sub resetENV
 # so it can either be a ref of a list or a string.
 sub cmd2str
 {
+    my @c;
     my $cmd = $_[0];
     if (!ref($cmd)) {
-        return $cmd;
+        push @c, $cmd;
+    } else {
+        foreach (@$cmd) {
+            if (/[][#;"*?&|<>(){}\$`^~!]/) {
+                s/\'/\'\\'\'/g;
+                push @c, "'$_'";
+            } else {
+                push @c, $_;
+            }
+        }
     }
 
-    my @c;
-    foreach (@$cmd) {
-        if (/[][#;"*?&|<>(){}\$`^~!]/) {
-            s/\'/\'\\'\'/g;
-            push @c, "'$_'";
-        } else {
-            push @c, $_;
-        }
+    if ($testpath eq $cwd) {
+        return join(' ', @c);
     }
-    return join(' ', @c);
+    return "(cd $testpath && " . join(' ', @c) . ')';
 }
 
 sub toplevel
@@ -255,7 +259,7 @@ sub toplevel
   # Locate the top source directory.
   $toppath = File::Spec->rel2abs(File::Spec->updir(), $srcpath);
 
-  $cwd = cwd();
+  local $cwd = cwd();
 
   $workpath = "$workdir";
 
@@ -649,7 +653,7 @@ sub run_all_tests
     $perl_testname = File::Spec->catfile($scriptpath, $testname);
     -f $perl_testname or die "Invalid test: $testname\n\n";
 
-    $testpath = File::Spec->catdir($workpath, $testname);
+    local $testpath = File::Spec->catdir($workpath, $testname);
 
     remove_directory_tree($testpath);
     mkdir($testpath, 0777) or &error("Couldn't mkdir $testpath: $!\n", 1);