diff --git a/run-tests b/run-tests
index f240599ff5d9eb24ffbb43f215841d80dce2e9d8..560cc4e0fcaac20af4e81936c0848a167dcf152b 100755
--- a/run-tests
+++ b/run-tests
@@ -41,7 +41,11 @@ env_program () {
 test_program () {
   testname=`basename "$1" .exe`
   testname=`basename "$testname" -test`
-  "$1" $testflags
+  if [ -z "$EMULATOR" ] || head -1 "$1" | grep '^#!' > /dev/null; then
+    "$1" $testflags
+  else
+    "$EMULATOR" "$1" $testflags
+  fi
   case "$?" in
       0)
     	echo PASS: $testname