Changeset 27031 in webkit for trunk/JavaScriptCore
- Timestamp:
- Oct 25, 2007, 2:08:51 AM (18 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r27029 r27031 1 2007-10-25 Eric Seidel <[email protected]> 2 3 Reviewed by Maciej. 4 5 More preparation work before adding long-running mode to testkjs. 6 7 * kjs/testkjs.cpp: 8 (TestFunctionImp::callAsFunction): 9 (prettyPrintScript): 10 (runWithScripts): 11 (parseArguments): 12 (kjsmain): 13 (fillBufferWithContentsOfFile): 14 1 15 2007-10-25 Eric Seidel <[email protected]> 2 16 -
trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r27028 r27031 1380 1380 isa = PBXProject; 1381 1381 buildConfigurationList = 149C277108902AFE008A9EFC /* Build configuration list for PBXProject "JavaScriptCore" */; 1382 compatibilityVersion = "Xcode 2.4";1383 1382 hasScannedForEncodings = 1; 1384 1383 mainGroup = 0867D691FE84028FC02AAC07 /* JavaScriptCore */; -
trunk/JavaScriptCore/kjs/testkjs.cpp
r27029 r27031 53 53 54 54 static void testIsInteger(); 55 static bool fillBufferWithContentsOfFile(const char*fileName, Vector<char>& buffer);55 static bool fillBufferWithContentsOfFile(const UString& fileName, Vector<char>& buffer); 56 56 57 57 class StopWatch … … 160 160 UString fileName = args[0]->toString(exec); 161 161 Vector<char> script; 162 if (!fillBufferWithContentsOfFile(fileName .UTF8String().c_str(), script))162 if (!fillBufferWithContentsOfFile(fileName, script)) 163 163 return throwError(exec, GeneralError, "Could not open file."); 164 164 … … 173 173 UString fileName = args[0]->toString(exec); 174 174 Vector<char> script; 175 if (!fillBufferWithContentsOfFile(fileName .UTF8String().c_str(), script))175 if (!fillBufferWithContentsOfFile(fileName, script)) 176 176 return throwError(exec, GeneralError, "Could not open file."); 177 177 … … 188 188 } 189 189 190 #if PLATFORM(WIN_OS)191 192 190 // Use SEH for Release builds only to get rid of the crash report dialog 193 // (luck yly the same tests fail in Release and Debug builds so far). Need to191 // (luckily the same tests fail in Release and Debug builds so far). Need to 194 192 // be in a separate main function because the kjsmain function requires object 195 193 // unwinding. 196 194 197 #if defined(_DEBUG) 195 #if PLATFORM(WIN_OS) && !defined(_DEBUG) 196 #define TRY __try { 197 #define EXCEPT(x) } __except (EXCEPTION_EXECUTE_HANDLER) { x; } 198 #else 198 199 #define TRY 199 200 #define EXCEPT(x) 200 #else201 #define TRY __try {202 #define EXCEPT(x) } __except (EXCEPTION_EXECUTE_HANDLER) { x; }203 #endif204 205 #else206 207 #define TRY208 #define EXCEPT(x)209 210 201 #endif 211 202 … … 251 242 } 252 243 253 static bool prettyPrintScript(const char*fileName, const Vector<char>& script)244 static bool prettyPrintScript(const UString& fileName, const Vector<char>& script) 254 245 { 255 246 int errLine = 0; … … 257 248 UString s = Parser::prettyPrint(script.data(), &errLine, &errMsg); 258 249 if (s.isNull()) { 259 fprintf(stderr, "%s:%d: %s.\n", fileName , errLine, errMsg.UTF8String().c_str());250 fprintf(stderr, "%s:%d: %s.\n", fileName.UTF8String().c_str(), errLine, errMsg.UTF8String().c_str()); 260 251 return false; 261 252 } … … 265 256 } 266 257 267 static bool doIt(int argc, char** argv) 268 { 269 bool success = true; 270 bool prettyPrint = false; 271 258 static bool runWithScripts(const Vector<UString>& fileNames, bool prettyPrint) 259 { 272 260 RefPtr<Interpreter> interp = setupInterpreter(); 273 261 Vector<char> script; 262 263 bool success = true; 264 265 for (size_t i = 0; i < fileNames.size(); i++) { 266 UString fileName = fileNames[i]; 267 268 if (!fillBufferWithContentsOfFile(fileName, script)) 269 return false; // fail early so we can catch missing files 270 271 if (prettyPrint) 272 prettyPrintScript(fileName, script); 273 else { 274 Completion completion = interp->evaluate(fileName, 0, script.data()); 275 success = success && completion.complType() != Throw; 276 } 277 } 278 return success; 279 } 280 281 static void parseArguments(int argc, char** argv, Vector<UString>& fileNames, bool& prettyPrint) 282 { 283 if (argc < 2) { 284 fprintf(stderr, "Usage: testkjs file1 [file2...]\n"); 285 exit(-1); 286 } 274 287 275 288 for (int i = 1; i < argc; i++) { … … 281 294 continue; 282 295 } 283 284 script.clear(); 285 if (!fillBufferWithContentsOfFile(fileName, script)) { 286 success = false; 287 break; // fail early so we can catch missing files 288 } 289 290 if (prettyPrint) 291 prettyPrintScript(fileName, script); 292 else { 293 Completion completion = interp->evaluate(fileName, 0, script.data()); 294 success = success && completion.complType() != Throw; 295 } 296 } 297 298 return success; 299 } 300 296 fileNames.append(fileName); 297 } 298 } 301 299 302 300 int kjsmain(int argc, char** argv) 303 301 { 304 if (argc < 2) {305 fprintf(stderr, "Usage: testkjs file1 [file2...]\n");306 return -1;307 }308 309 302 testIsInteger(); 310 303 311 304 JSLock lock; 312 313 bool success = doIt(argc, argv); 305 306 bool prettyPrint = false; 307 Vector<UString> fileNames; 308 parseArguments(argc, argv, fileNames, prettyPrint); 309 310 bool success = runWithScripts(fileNames, prettyPrint); 314 311 315 312 #ifndef NDEBUG … … 349 346 } 350 347 351 static bool fillBufferWithContentsOfFile(const char*fileName, Vector<char>& buffer)352 { 353 FILE* f = fopen(fileName , "r");348 static bool fillBufferWithContentsOfFile(const UString& fileName, Vector<char>& buffer) 349 { 350 FILE* f = fopen(fileName.UTF8String().c_str(), "r"); 354 351 if (!f) { 355 fprintf(stderr, "Could not open file: %s\n", fileName );352 fprintf(stderr, "Could not open file: %s\n", fileName.UTF8String().c_str()); 356 353 return false; 357 354 }
Note:
See TracChangeset
for help on using the changeset viewer.