diff --git a/tests/run-tests.py b/tests/run-tests.py
index 23bba755cf809b5208e7cb05240c273cb9e22d32_dGVzdHMvcnVuLXRlc3RzLnB5..fc0f3ed071fc3547c991dc6eb4ff03101a90d1fb_dGVzdHMvcnVuLXRlc3RzLnB5 100755
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -2373,6 +2373,8 @@
             self._outputdir = canonpath(_bytespath(self.options.outputdir))
         else:
             self._outputdir = self._testdir
+            if testdescs and pathname:
+                self._outputdir = os.path.join(self._outputdir, pathname)
 
         if 'PYTHONHASHSEED' not in os.environ:
             # use a random python hash seed all the time
diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t
index 23bba755cf809b5208e7cb05240c273cb9e22d32_dGVzdHMvdGVzdC1ydW4tdGVzdHMudA==..fc0f3ed071fc3547c991dc6eb4ff03101a90d1fb_dGVzdHMvdGVzdC1ydW4tdGVzdHMudA== 100644
--- a/tests/test-run-tests.t
+++ b/tests/test-run-tests.t
@@ -1281,6 +1281,7 @@
 
 support for running run-tests.py from another directory
   $ mkdir tmp && cd tmp
+
   $ cat > useful-file.sh << EOF
   > important command
   > EOF
@@ -1290,4 +1291,9 @@
   >   important command
   > EOF
 
+  $ cat > test-folder-fail.t << EOF
+  >   $ cat \$TESTDIR/useful-file.sh
+  >   important commando
+  > EOF
+
   $ cd ..
@@ -1293,7 +1299,19 @@
   $ cd ..
-  $ $PYTHON $TESTDIR/run-tests.py tmp/test-folder.t
-  .
-  # Ran 1 tests, 0 skipped, 0 failed.
+  $ $PYTHON $TESTDIR/run-tests.py tmp/test-*.t
+  
+  --- $TESTTMP/anothertests/tmp/test-folder-fail.t
+  +++ $TESTTMP/anothertests/tmp/test-folder-fail.t.err
+  @@ -1,2 +1,2 @@
+     $ cat $TESTDIR/useful-file.sh
+  -  important commando
+  +  important command
+  
+  ERROR: test-folder-fail.t output changed
+  !.
+  Failed test-folder-fail.t: output changed
+  # Ran 2 tests, 0 skipped, 1 failed.
+  python hash seed: * (glob)
+  [1]
 
 support for bisecting failed tests automatically
   $ hg init bisect