diff --git a/tests/run-tests.py b/tests/run-tests.py
index a7e49a5b3e6f38338660c0d98f9c593f70064e95_dGVzdHMvcnVuLXRlc3RzLnB5..a18eef03d879b179c69744ff3568615402542938_dGVzdHMvcnVuLXRlc3RzLnB5 100755
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -2353,6 +2353,12 @@
 
         self._testdir = osenvironb[b'TESTDIR'] = getattr(
             os, 'getcwdb', os.getcwd)()
+        # assume all tests in same folder for now
+        if testdescs:
+            pathname = os.path.dirname(testdescs[0]['path'])
+            if pathname and not osenvironb[b'TESTDIR'].endswith('/'):
+                osenvironb[b'TESTDIR'] += '/'
+            osenvironb[b'TESTDIR'] += pathname
         if self.options.outputdir:
             self._outputdir = canonpath(_bytespath(self.options.outputdir))
         else:
diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t
index a7e49a5b3e6f38338660c0d98f9c593f70064e95_dGVzdHMvdGVzdC1ydW4tdGVzdHMudA==..a18eef03d879b179c69744ff3568615402542938_dGVzdHMvdGVzdC1ydW4tdGVzdHMudA== 100644
--- a/tests/test-run-tests.t
+++ b/tests/test-run-tests.t
@@ -1261,6 +1261,22 @@
   .
   # Ran 1 tests, 0 skipped, 0 failed.
 
+support for running run-tests.py from another directory
+  $ mkdir tmp && cd tmp
+  $ cat > useful-file.sh << EOF
+  > important command
+  > EOF
+
+  $ cat > test-folder.t << EOF
+  >   $ cat \$TESTDIR/useful-file.sh
+  >   important command
+  > EOF
+
+  $ cd ..
+  $ $PYTHON $TESTDIR/run-tests.py tmp/test-folder.t
+  .
+  # Ran 1 tests, 0 skipped, 0 failed.
+
 support for bisecting failed tests automatically
   $ hg init bisect
   $ cd bisect