| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
package com.netscape.javascript.qa.drivers; |
| 7 |
|
| 8 |
import java.util.Vector; |
| 9 |
import java.util.Date; |
| 10 |
import java.io.*; |
| 11 |
import java.applet.Applet; |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
public class RefDrv extends TestDriver { |
| 58 |
String SUFFIX = ".js"; |
| 59 |
boolean CODE_COVERAGE = false; |
| 60 |
String HELPER_STRING; |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
public RefDrv( String[] args) { |
| 69 |
super( args ); |
| 70 |
setSuffix( ".js"); |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
public static void main ( String[] args ) { |
| 85 |
RefDrv d = new RefDrv( args ); |
| 86 |
d.start(); |
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
public boolean processOptions() { |
| 95 |
int length = ARGS.length; |
| 96 |
|
| 97 |
if (ARGS[0].startsWith("-")) { |
| 98 |
|
| 99 |
|
| 100 |
for (int i=0; i < ARGS.length; i++ ) { |
| 101 |
if ( ARGS[i].equals("-d") ) { |
| 102 |
p( "-d " ); |
| 103 |
|
| 104 |
this.TEST_DIRECTORY = ARGS[i].endsWith(File.separator) |
| 105 |
? new File( ARGS[++i] ) |
| 106 |
: new File( ARGS[++i] + File.separator ); |
| 107 |
p( "-d " +this.TEST_DIRECTORY ); |
| 108 |
|
| 109 |
if ( ! ( this.TEST_DIRECTORY ).isDirectory() ) { |
| 110 |
p( "error: " + |
| 111 |
this.TEST_DIRECTORY.getAbsolutePath() + |
| 112 |
" is not a TEST_DIRECTORY." ); |
| 113 |
return false; |
| 114 |
} else { |
| 115 |
continue; |
| 116 |
} |
| 117 |
} |
| 118 |
if ( ARGS[i].equals("-s") ) { |
| 119 |
p( "-s "); |
| 120 |
FILES = new String[20] ; |
| 121 |
for ( int j = ++i, k=0; j < ARGS.length; j++ ) { |
| 122 |
if ( ARGS[j].startsWith("-") ){ |
| 123 |
break; |
| 124 |
} |
| 125 |
FILES[k++] = ARGS[j]; |
| 126 |
} |
| 127 |
} |
| 128 |
if ( ARGS[i].equals("-h") ) { |
| 129 |
p( "-h" ); |
| 130 |
this.HELPER_STRING = new String( ARGS[++i] ); |
| 131 |
this.HELPER_FUNCTIONS = new File( HELPER_STRING ); |
| 132 |
if ( ! (this.HELPER_FUNCTIONS ).isFile() ) { |
| 133 |
p( "error: "+ |
| 134 |
this.HELPER_FUNCTIONS.getAbsolutePath()+ |
| 135 |
" file not found." ); |
| 136 |
return false; |
| 137 |
} |
| 138 |
p( "-h " +this.HELPER_FUNCTIONS ); |
| 139 |
} |
| 140 |
if ( ARGS[i].equals("-c")) { |
| 141 |
p("-c"); |
| 142 |
this.CODE_COVERAGE = new Boolean( ARGS[++i] ).booleanValue(); |
| 143 |
} |
| 144 |
if ( ARGS[i].equals("-o") ) { |
| 145 |
p( "-o" ); |
| 146 |
OUTPUT_DIRECTORY = new File(ARGS[++i]+File.separator); |
| 147 |
if ( !OUTPUT_DIRECTORY.exists() || |
| 148 |
!OUTPUT_DIRECTORY.isDirectory() ) |
| 149 |
{ |
| 150 |
p( "error: "+ |
| 151 |
OUTPUT_DIRECTORY.getAbsolutePath()+ |
| 152 |
" is not a directory."); |
| 153 |
return false; |
| 154 |
} |
| 155 |
} |
| 156 |
|
| 157 |
if ( ARGS[i].equals("-p") ) { |
| 158 |
this.OPT_LEVEL = Integer.parseInt( ARGS[++i] ); |
| 159 |
} |
| 160 |
|
| 161 |
if ( ARGS[i].equals("-db" )) { |
| 162 |
this.DEBUG_LEVEL = Integer.parseInt( ARGS[++i] ); |
| 163 |
this.OPT_LEVEL = 0; |
| 164 |
} |
| 165 |
|
| 166 |
if ( ARGS[i].equals("-e")) { |
| 167 |
this.EXECUTABLE = ARGS[++i]; |
| 168 |
} |
| 169 |
if ( ARGS[i].equals("-t")) { |
| 170 |
String __tinderbox = ARGS[++i]; |
| 171 |
|
| 172 |
if ( __tinderbox.equals("true") || __tinderbox.equals("1")){ |
| 173 |
this.TINDERBOX = true; |
| 174 |
} else { |
| 175 |
this.TINDERBOX = false; |
| 176 |
} |
| 177 |
} |
| 178 |
} |
| 179 |
|
| 180 |
return true; |
| 181 |
|
| 182 |
} else { |
| 183 |
|
| 184 |
switch ( ARGS.length ) { |
| 185 |
case 0: |
| 186 |
p( "error: specify location of JavaScript "+ |
| 187 |
"tests" ); |
| 188 |
return false; |
| 189 |
case 1: |
| 190 |
p( "error: specify location of JavaScript "+ |
| 191 |
"HELPER_FUNCTIONS file" ); |
| 192 |
return false; |
| 193 |
case 2: |
| 194 |
this.TEST_DIRECTORY = ARGS[0].endsWith(File.separator) |
| 195 |
? new File( ARGS[0] ) |
| 196 |
: new File( ARGS[0] + File.separator ); |
| 197 |
this.HELPER_FUNCTIONS = new File( ARGS[1] ); |
| 198 |
if ( ! ( this.TEST_DIRECTORY ).isDirectory() ) { |
| 199 |
p( "error: " + |
| 200 |
this.TEST_DIRECTORY.getAbsolutePath() +" is not a directory." ); |
| 201 |
return false; |
| 202 |
} |
| 203 |
if ( ! (this.HELPER_FUNCTIONS ).isFile() ) { |
| 204 |
p( "error: "+ |
| 205 |
this.HELPER_FUNCTIONS.getAbsolutePath()+ |
| 206 |
" file not found." ); |
| 207 |
return false; |
| 208 |
} |
| 209 |
return true; |
| 210 |
default: |
| 211 |
p( "could not understand arguments." ); |
| 212 |
return false; |
| 213 |
} |
| 214 |
} |
| 215 |
} |
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
public synchronized void executeSuite( TestSuite suite ) { |
| 222 |
TestEnvironment context; |
| 223 |
TestFile file; |
| 224 |
|
| 225 |
p("executing suite" ); |
| 226 |
try { |
| 227 |
for ( int i = 0; i < suite.size(); i++ ) { |
| 228 |
synchronized ( suite ) { |
| 229 |
file = (TestFile) suite.elementAt( i ); |
| 230 |
|
| 231 |
if ( getSystemInformation()[0].startsWith( "Mac" )) { |
| 232 |
context = new MacRefEnv( file, suite, this ); |
| 233 |
((MacRefEnv) context).runTest(); |
| 234 |
} else { |
| 235 |
context = new RefEnv( file, suite, this ); |
| 236 |
((RefEnv) context).runTest(); |
| 237 |
} |
| 238 |
} |
| 239 |
|
| 240 |
writeFileResult( file, suite, OUTPUT_DIRECTORY ); |
| 241 |
writeCaseResults(file, suite, OUTPUT_DIRECTORY ); |
| 242 |
context.close(); |
| 243 |
context = null; |
| 244 |
|
| 245 |
if ( ! file.passed ) { |
| 246 |
suite.passed = false; |
| 247 |
} |
| 248 |
} |
| 249 |
} catch ( Exception e ) { |
| 250 |
e.printStackTrace() ; |
| 251 |
} |
| 252 |
writeSuiteResult( suite, OUTPUT_DIRECTORY ); |
| 253 |
writeSuiteSummary( suite, OUTPUT_DIRECTORY ); |
| 254 |
} |
| 255 |
} |
| 256 |
|