77import java .io .File ;
88import java .io .FileFilter ;
99import java .io .FileNotFoundException ;
10- import java .io .FileReader ;
1110import java .io .IOException ;
1211import java .io .PrintStream ;
1312import java .net .URL ;
@@ -52,7 +51,7 @@ public MozillaSuiteTest(File jsFile, boolean interpretedMode) {
5251 ShellTest .cacheFramework ();
5352 }
5453
55- public static File getTestDir () throws IOException {
54+ private static File getTestDir () throws IOException {
5655 File testDir = null ;
5756 if (System .getProperty ("mozilla.js.tests" ) != null ) {
5857 testDir = new File (System .getProperty ("mozilla.js.tests" ));
@@ -81,36 +80,29 @@ public static File getTestDir() throws IOException {
8180 return testDir ;
8281 }
8382
84- public static String getTestFilename (boolean interpretedMode ) {
83+ private static String getTestFilename (boolean interpretedMode ) {
8584 return interpretedMode ? "interpreted.tests" : "compiled.tests" ;
8685 }
8786
88- public static File [] getTestFiles (boolean interpretedMode ) throws IOException {
87+ private static File [] getTestFiles (boolean interpretedMode ) throws IOException {
8988 File testDir = getTestDir ();
90- String [] tests =
91- TestUtils .loadTestsFromResource ("/" + getTestFilename (interpretedMode ), null );
92- Arrays .sort (tests );
93- File [] files = new File [tests .length ];
94- for (int i = 0 ; i < files .length ; i ++) {
95- files [i ] = new File (testDir , tests [i ]);
96- }
97- if (files .length == 0 ) {
89+ String [] tests = TestUtils .loadTestsFromResource ("/" + getTestFilename (interpretedMode ));
90+ if (tests .length == 0 ) {
9891 throw new IOException (
9992 "No Mozilla Suite tests found in "
10093 + testDir
10194 + ". Check mozilla.js.tests property" );
10295 }
103- return files ;
104- }
10596
106- public static String loadFile (File f ) throws IOException {
107- int length = (int ) f .length (); // don't worry about very long files
108- char [] buf = new char [length ];
109- new FileReader (f ).read (buf , 0 , length );
110- return new String (buf );
97+ Arrays .sort (tests );
98+ File [] files = new File [tests .length ];
99+ for (int i = 0 ; i < files .length ; i ++) {
100+ files [i ] = new File (testDir , tests [i ]);
101+ }
102+ return files ;
111103 }
112104
113- @ Parameters (name = "{index}, js={0}, opt ={1}" )
105+ @ Parameters (name = "{index}, js={0}, interpreted ={1}" )
114106 public static Collection <Object []> mozillaSuiteValues () throws IOException {
115107 List <Object []> result = new ArrayList <Object []>();
116108 for (boolean im : new boolean [] {false , true }) {
@@ -122,19 +114,6 @@ public static Collection<Object[]> mozillaSuiteValues() throws IOException {
122114 return result ;
123115 }
124116
125- // move "@Parameters" to this method to test a single Mozilla test
126- // @Parameters(name = "{index}, js={0}, opt={1}")
127- public static Collection <Object []> singleDoctest () throws IOException {
128- final String SINGLE_TEST_FILE = "..." ;
129-
130- List <Object []> result = new ArrayList <Object []>();
131- for (boolean im : new boolean [] {false , true }) {
132- File f = new File (getTestDir (), SINGLE_TEST_FILE );
133- result .add (new Object [] {f , im });
134- }
135- return result ;
136- }
137-
138117 private static class ShellTestParameters extends ShellTest .Parameters {
139118 @ Override
140119 public int getTimeoutMilliseconds () {
@@ -204,7 +183,7 @@ public void runMozillaTest() throws Exception {
204183 public static void main (String [] args ) throws IOException {
205184 try (PrintStream out = new PrintStream ("fix-tests-files.sh" )) {
206185 try {
207- for (boolean im : new boolean [] {false , true }) {
186+ for (boolean interpretedMode : new boolean [] {false , true }) {
208187 File testDir = getTestDir ();
209188 File [] allTests =
210189 TestUtils .recursiveListFiles (
@@ -217,13 +196,13 @@ public boolean accept(File pathname) {
217196 }
218197 });
219198 HashSet <File > diff = new HashSet <File >(Arrays .asList (allTests ));
220- File testFiles [] = getTestFiles (im );
199+ File testFiles [] = getTestFiles (interpretedMode );
221200 diff .removeAll (Arrays .asList (testFiles ));
222201 ArrayList <String > skippedPassed = new ArrayList <String >();
223202 int absolutePathLength = testDir .getAbsolutePath ().length () + 1 ;
224203 for (File testFile : diff ) {
225204 try {
226- ( new MozillaSuiteTest (testFile , im ) ).runMozillaTest ();
205+ new MozillaSuiteTest (testFile , interpretedMode ).runMozillaTest ();
227206 // strip off testDir
228207 String canonicalized =
229208 testFile .getAbsolutePath ().substring (absolutePathLength );
@@ -237,7 +216,7 @@ public boolean accept(File pathname) {
237216 // skipped but now pass. Print out shell commands to update the
238217 // appropriate *.tests file.
239218 if (skippedPassed .size () > 0 ) {
240- out .println ("cat >> " + getTestFilename (im ) + " <<EOF" );
219+ out .println ("cat >> " + getTestFilename (interpretedMode ) + " <<EOF" );
241220 String [] sorted = skippedPassed .toArray (new String [0 ]);
242221 Arrays .sort (sorted );
243222 for (int j = 0 ; j < sorted .length ; j ++) {
0 commit comments