public static File getTestDir() throws IOException { File testDir = null; if (System.getProperty("mozilla.js.tests") != null) { testDir = new File(System.getProperty("mozilla.js.tests")); } else { URL url = StandardTests.class.getResource("."); String path = url.getFile(); int jsIndex = path.lastIndexOf("/js"); if (jsIndex == -1) { throw new IllegalStateException("You aren't running the tests "+ "from within the standard mozilla/js directory structure"); } path = path.substring(0, jsIndex + 3).replace('/', File.separatorChar); path = path.replace("%20", " "); testDir = new File(path, "tests"); } if (!testDir.isDirectory()) { throw new FileNotFoundException(testDir + " is not a directory"); } return testDir; }