Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #library("test_suite"); | 5 #library("test_suite"); |
| 6 | 6 |
| 7 #import("status_file_parser.dart"); | 7 #import("status_file_parser.dart"); |
| 8 #import("test_runner.dart"); | 8 #import("test_runner.dart"); |
| 9 #import("multitest.dart"); | 9 #import("multitest.dart"); |
| 10 | 10 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 filename.substring(middle + 1, filename.length - 5); | 237 filename.substring(middle + 1, filename.length - 5); |
| 238 } else { | 238 } else { |
| 239 // This case is hit by the dartc client compilation | 239 // This case is hit by the dartc client compilation |
| 240 // tests. These tests are pretty broken compared to the | 240 // tests. These tests are pretty broken compared to the |
| 241 // rest. They use the .dart suffix in the status files. They | 241 // rest. They use the .dart suffix in the status files. They |
| 242 // find tests in weird ways (testing that they contain "#"). | 242 // find tests in weird ways (testing that they contain "#"). |
| 243 // They need to be redone. | 243 // They need to be redone. |
| 244 start = filename.indexOf(directoryPath); | 244 start = filename.indexOf(directoryPath); |
| 245 testName = filename.substring(start + directoryPath.length + 1, | 245 testName = filename.substring(start + directoryPath.length + 1, |
| 246 filename.length); | 246 filename.length); |
| 247 if (configuration['component'] != 'dartc') { | |
| 248 if (testName.endsWith('.dart')) { | |
| 249 testName = testName.substring(0, testName.length - 5); | |
| 250 } | |
| 251 } | |
| 247 } | 252 } |
| 248 Set<String> expectations = testExpectations.expectations(testName); | 253 Set<String> expectations = testExpectations.expectations(testName); |
| 249 if (configuration["report"]) { | 254 if (configuration["report"]) { |
| 250 // Tests with multiple VMOptions are counted more than once. | 255 // Tests with multiple VMOptions are counted more than once. |
| 251 for (var dummy in optionsFromFile["vmOptions"]) { | 256 for (var dummy in optionsFromFile["vmOptions"]) { |
| 252 SummaryReport.add(expectations); | 257 SummaryReport.add(expectations); |
| 253 } | 258 } |
| 254 } | 259 } |
| 255 if (expectations.contains(SKIP)) return; | 260 if (expectations.contains(SKIP)) return; |
| 256 | 261 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 enqueueTestCaseFromTestInformation(info); | 309 enqueueTestCaseFromTestInformation(info); |
| 305 }; | 310 }; |
| 306 } | 311 } |
| 307 | 312 |
| 308 void processFile(String filename) { | 313 void processFile(String filename) { |
| 309 if (!isTestFile(filename)) return; | 314 if (!isTestFile(filename)) return; |
| 310 | 315 |
| 311 // Only run the tests that match the pattern. | 316 // Only run the tests that match the pattern. |
| 312 RegExp pattern = configuration['selectors'][suiteName]; | 317 RegExp pattern = configuration['selectors'][suiteName]; |
| 313 if (!pattern.hasMatch(filename)) return; | 318 if (!pattern.hasMatch(filename)) return; |
| 319 if (filename.endsWith('test_config.dart')) return; | |
| 314 | 320 |
| 315 var optionsFromFile = optionsFromFile(filename); | 321 var optionsFromFile = optionsFromFile(filename); |
| 316 Function createTestCase = makeTestCaseCreator(optionsFromFile); | 322 Function createTestCase = makeTestCaseCreator(optionsFromFile); |
| 317 | 323 |
| 318 if (optionsFromFile['isMultitest']) { | 324 if (optionsFromFile['isMultitest']) { |
| 319 testGeneratorStarted(); | 325 testGeneratorStarted(); |
| 320 DoMultitest(filename, | 326 DoMultitest(filename, |
| 321 TestUtils.outputDir(configuration), | 327 TestUtils.outputDir(configuration), |
| 322 directoryPath, | 328 directoryPath, |
| 323 createTestCase, | 329 createTestCase, |
| 324 testGeneratorDone); | 330 testGeneratorDone); |
| 325 } else { | 331 } else { |
| 326 createTestCase(filename, optionsFromFile['isNegative']); | 332 createTestCase(filename, optionsFromFile['isNegative']); |
| 327 } | 333 } |
| 328 } | 334 } |
| 335 | |
| 329 | 336 |
| 330 void enqueueDartiumTest(String filename, | 337 void enqueueDartiumTest(String filename, |
| 331 String testName, | 338 String testName, |
| 332 Map optionsFromFile, | 339 Map optionsFromFile, |
| 333 Set<String> expectations, | 340 Set<String> expectations, |
| 334 bool isNegative) { | 341 bool isNegative) { |
| 342 // TODO(whesse): Merge with enqueueChromiumTest, using mainly | |
| 343 // enqueueChromiumTest's code and design. | |
| 335 if (optionsFromFile['isMultitest']) return; | 344 if (optionsFromFile['isMultitest']) return; |
| 336 bool isWebTest = optionsFromFile['containsDomImport']; | 345 bool isWebTest = optionsFromFile['containsDomImport']; |
| 337 bool isLibraryDefinition = optionsFromFile['isLibraryDefinition']; | 346 bool isLibraryDefinition = optionsFromFile['isLibraryDefinition']; |
| 338 if (!isLibraryDefinition && optionsFromFile['containsSourceOrImport']) { | 347 if (!isLibraryDefinition && optionsFromFile['containsSourceOrImport']) { |
| 339 print('Warning for $filename: Browser tests require #library ' + | 348 print('Warning for $filename: Browser tests require #library ' + |
| 340 'in any file that uses #import or #source'); | 349 'in any file that uses #import or #source'); |
| 341 } | 350 } |
| 342 | 351 |
| 343 String tempDirTemplate = '${TestUtils.buildDir(configuration)}/tmp'; | 352 String tempDirTemplate = '${TestUtils.buildDir(configuration)}/tmp'; |
| 344 if (isWebTest) tempDirTemplate = 'client/' + tempDirTemplate; | |
| 345 Directory tempDir = new Directory(tempDirTemplate); | 353 Directory tempDir = new Directory(tempDirTemplate); |
| 346 // TODO(whesse): When implementing client web tests, | |
| 347 // create directory in the client case, if it doesn't exist. | |
| 348 tempDir.createTempSync(); | 354 tempDir.createTempSync(); |
| 349 | 355 |
| 350 String dartTestFilename = new File(filename).fullPathSync(); | 356 String dartTestFilename = new File(filename).fullPathSync(); |
| 351 String dartWrapperFilename = '${tempDir.path}/test.dart'; | 357 dartTestFilename = dartTestFilename.replaceAll('\\', '/'); |
|
Bill Hesse
2012/01/03 18:29:07
Let's remove these again, since the test doesn't e
| |
| 352 if (!isWebTest) { | 358 filename = filename.replaceAll('\\', '/'); |
| 359 String dartWrapperFilename; | |
| 360 String scriptPath; | |
| 361 if (isWebTest) { | |
| 362 scriptPath = 'file://$dartTestFilename'; | |
| 363 } else { | |
| 364 dartWrapperFilename = '${tempDir.path}/test.dart'; | |
| 365 scriptPath = '../../../$dartWrapperFilename'; | |
| 353 // test.dart will import the dart test directly, if it is a library, | 366 // test.dart will import the dart test directly, if it is a library, |
| 354 // or indirectly through test_as_library.dart, if it is not. | 367 // or indirectly through test_as_library.dart, if it is not. |
| 355 String dartLibraryFilename; | 368 String dartLibraryFilename; |
| 356 if (isLibraryDefinition) { | 369 if (isLibraryDefinition) { |
| 357 dartLibraryFilename = dartTestFilename; | 370 dartLibraryFilename = dartTestFilename; |
| 358 } else { | 371 } else { |
| 359 dartLibraryFilename = 'test_as_library.dart'; | 372 dartLibraryFilename = 'test_as_library.dart'; |
| 360 File file = new File('${tempDir.path}/$dartLibraryFilename'); | 373 File file = new File('${tempDir.path}/$dartLibraryFilename'); |
| 361 RandomAccessFile dartLibrary = file.openSync(writable: true); | 374 RandomAccessFile dartLibrary = file.openSync(writable: true); |
| 362 dartLibrary.writeStringSync(WrapDartTestInLibrary(dartTestFilename)); | 375 dartLibrary.writeStringSync(WrapDartTestInLibrary(dartTestFilename)); |
| 363 dartLibrary.closeSync(); | 376 dartLibrary.closeSync(); |
| 364 } | 377 } |
| 365 | 378 |
| 366 File file = new File(dartWrapperFilename); | 379 File file = new File(dartWrapperFilename); |
| 367 RandomAccessFile dartWrapper = file.openSync(writable: true); | 380 RandomAccessFile dartWrapper = file.openSync(writable: true); |
| 368 dartWrapper.writeStringSync(DartTestWrapper( | 381 dartWrapper.writeStringSync(DartTestWrapper( |
| 369 'dart:dom', | 382 'dart:dom', |
| 370 '../../../tests/isolate/src/TestFramework.dart', | 383 '../../../tests/isolate/src/TestFramework.dart', |
| 371 dartLibraryFilename)); | 384 dartLibraryFilename)); |
| 372 dartWrapper.closeSync(); | 385 dartWrapper.closeSync(); |
| 373 } else { | |
| 374 return; // TODO(whesse): Implement client web tests on dartium. | |
| 375 } | 386 } |
| 376 // Create the HTML file for the test. | 387 // Create the HTML file for the test. |
| 388 // NOTE: This must be 3 directories below the dart root, due to test | |
| 389 // client/samples/dartcombat containing a relative path to its .css file. | |
| 377 File htmlTestBase = new File('${tempDir.path}/${getHtmlName(filename)}'); | 390 File htmlTestBase = new File('${tempDir.path}/${getHtmlName(filename)}'); |
| 378 RandomAccessFile htmlTest = htmlTestBase.openSync(writable: true); | 391 RandomAccessFile htmlTest = htmlTestBase.openSync(writable: true); |
| 379 htmlTest.writeStringSync(GetHtmlContents( | 392 htmlTest.writeStringSync(GetHtmlContents( |
| 380 filename, | 393 filename, |
| 381 '../../../client/testing/unittest/test_controller.js', | 394 '../../../client/testing/unittest/test_controller.js', |
| 382 scriptType, | 395 scriptType, |
| 383 '../../../$dartWrapperFilename')); | 396 scriptPath)); |
| 384 htmlTest.closeSync(); | 397 htmlTest.closeSync(); |
| 385 | 398 |
| 386 for (var vmOptions in optionsFromFile["vmOptions"]) { | 399 for (var vmOptions in optionsFromFile["vmOptions"]) { |
| 387 var drtFlags = ['-no-timeout']; | 400 var drtFlags = ['--no-timeout']; |
| 388 var dartFlags = ['--enable_asserts', '--enable_type_checks']; | 401 var dartFlags = ['--enable_asserts', '--enable_type_checks']; |
| 389 dartFlags.addAll(vmOptions); | 402 dartFlags.addAll(vmOptions); |
| 390 drtFlags.add('--dart-flags=${Strings.join(dartFlags, " ")}'); | 403 drtFlags.add('--dart-flags=${Strings.join(dartFlags, " ")}'); |
| 391 var args = drtFlags; | 404 var args = drtFlags; |
| 392 args.add(htmlTestBase.fullPathSync()); | 405 args.add(htmlTestBase.fullPathSync()); |
| 393 | 406 |
| 394 // Create BrowserTestCase and queue it. | 407 // Create BrowserTestCase and queue it. |
| 395 var testCase = new BrowserTestCase( | 408 var testCase = new BrowserTestCase( |
| 396 testName, | 409 testName, |
| 397 null, | 410 null, |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 411 Set<String> expectations, | 424 Set<String> expectations, |
| 412 bool isNegative) { | 425 bool isNegative) { |
| 413 if (optionsFromFile['isMultitest']) return; | 426 if (optionsFromFile['isMultitest']) return; |
| 414 bool isWebTest = optionsFromFile['containsDomImport']; | 427 bool isWebTest = optionsFromFile['containsDomImport']; |
| 415 bool isLibraryDefinition = optionsFromFile['isLibraryDefinition']; | 428 bool isLibraryDefinition = optionsFromFile['isLibraryDefinition']; |
| 416 if (!isLibraryDefinition && optionsFromFile['containsSourceOrImport']) { | 429 if (!isLibraryDefinition && optionsFromFile['containsSourceOrImport']) { |
| 417 print('Warning for $filename: Browser tests require #library ' + | 430 print('Warning for $filename: Browser tests require #library ' + |
| 418 'in any file that uses #import or #source'); | 431 'in any file that uses #import or #source'); |
| 419 } | 432 } |
| 420 | 433 |
| 421 String dartDir = new File('.').fullPathSync(); | 434 filename = filename.replaceAll('\\', '/'); |
| 435 String dartDir = new File('.').fullPathSync().replaceAll('\\', '/'); | |
| 422 String buildDir = TestUtils.buildDir(configuration); | 436 String buildDir = TestUtils.buildDir(configuration); |
| 423 String testPath = new File(filename).fullPathSync(); | 437 String testPath = new File(filename).fullPathSync().replaceAll('\\', '/'); |
| 424 String outputDirBase = '$dartDir/$buildDir/generated_tests/chromium'; | 438 String outputDirBase = '$dartDir/$buildDir/generated_tests/chromium'; |
| 425 | 439 |
| 426 Expect.isTrue(testPath.startsWith(dartDir)); | 440 Expect.isTrue(testPath.startsWith(dartDir)); |
| 427 String testRelativePath = testPath.substring(dartDir.length + 1); | 441 String testRelativePath = testPath.substring(dartDir.length + 1); |
| 428 String testNameBase; | 442 String testNameBase; |
| 429 String testRelativeDir; | 443 String testRelativeDir; |
| 430 String testRelativeDirFlattened; | 444 String testRelativeDirFlattened; |
| 431 | 445 |
| 432 int start = testRelativePath.lastIndexOf('src' + pathSeparator); | 446 int start = testRelativePath.lastIndexOf('src' + pathSeparator); |
| 433 if (start != -1) { | 447 if (start != -1) { |
| 434 Expect.isTrue(testRelativePath.endsWith('.dart')); | 448 Expect.isTrue(testRelativePath.endsWith('.dart')); |
| 435 testNameBase = | 449 testNameBase = |
| 436 testRelativePath.substring(start + 4, testRelativePath.length - 5); | 450 testRelativePath.substring(start + 4, testRelativePath.length - 5); |
| 437 testRelativeDir = testRelativePath.substring(0, start - 1); | 451 testRelativeDir = testRelativePath.substring(0, start - 1); |
| 438 testRelativeDirFlattened = testRelativeDir.replaceAll(pathSeparator, '_'); | 452 testRelativeDirFlattened = testRelativeDir.replaceAll('/', '_'); |
| 439 } else { | 453 } else { |
| 440 Expect.fail('Web tests not imlemented yet'); | 454 Expect.isTrue(testRelativePath.endsWith('_tests.dart')); |
| 455 start = testRelativePath.lastIndexOf(pathSeparator); | |
| 456 testNameBase = | |
| 457 testRelativePath.substring(start + 1, testRelativePath.length - 11); | |
| 441 } | 458 } |
| 442 | 459 |
| 443 if (!new Directory('$dartDir/$buildDir/generated_tests').existsSync()) { | 460 if (!new Directory('$dartDir/$buildDir/generated_tests').existsSync()) { |
| 444 new Directory('$dartDir/$buildDir/generated_tests').createSync(); | 461 new Directory('$dartDir/$buildDir/generated_tests').createSync(); |
| 445 } | 462 } |
| 446 if (!new Directory(outputDirBase).existsSync()) { | 463 if (!new Directory(outputDirBase).existsSync()) { |
| 447 new Directory(outputDirBase).createSync(); | 464 new Directory(outputDirBase).createSync(); |
| 448 } | 465 } |
| 449 Directory tempDir = new Directory( | 466 Directory tempDir = new Directory( |
| 450 '$outputDirBase/${testRelativeDirFlattened}_$testNameBase'); | 467 '$outputDirBase/${testRelativeDirFlattened}_$testNameBase'); |
| 451 if (!tempDir.existsSync()) { | 468 if (!tempDir.existsSync()) { |
| 452 tempDir.createSync(); | 469 tempDir.createSync(); |
| 453 } | 470 } |
| 454 | 471 |
| 455 String dartWrapperFilename = '${tempDir.path}/test.dart'; | 472 String dartWrapperFilename = '${tempDir.path}/test.dart'; |
| 456 String compiledDartWrapperFilename = '${tempDir.path}/test.js'; | 473 String compiledDartWrapperFilename = '${tempDir.path}/test.js'; |
| 457 String domLibraryImport = 'dart:dom'; | 474 String domLibraryImport = 'dart:dom'; |
| 458 if (configuration['component'] == 'chromium') { | 475 if (configuration['component'] == 'chromium') { |
| 459 domLibraryImport = | 476 domLibraryImport = |
| 460 '$dartDir/client/testing/unittest/dom_for_unittest.dart'; | 477 '$dartDir/client/testing/unittest/dom_for_unittest.dart'; |
| 461 } | 478 } |
| 462 | 479 |
| 480 File htmlTestBase; | |
| 463 if (!isWebTest) { | 481 if (!isWebTest) { |
| 464 // test.dart will import the dart test directly, if it is a library, | 482 // test.dart will import the dart test directly, if it is a library, |
| 465 // or indirectly through test_as_library.dart, if it is not. | 483 // or indirectly through test_as_library.dart, if it is not. |
| 466 String dartLibraryFilename; | 484 String dartLibraryFilename; |
| 467 if (isLibraryDefinition) { | 485 if (isLibraryDefinition) { |
| 468 dartLibraryFilename = testPath; | 486 dartLibraryFilename = testPath; |
| 469 } else { | 487 } else { |
| 470 dartLibraryFilename = 'test_as_library.dart'; | 488 dartLibraryFilename = 'test_as_library.dart'; |
| 471 File file = new File('${tempDir.path}/$dartLibraryFilename'); | 489 File file = new File('${tempDir.path}/$dartLibraryFilename'); |
| 472 RandomAccessFile dartLibrary = file.openSync(writable: true); | 490 RandomAccessFile dartLibrary = file.openSync(writable: true); |
| 473 dartLibrary.writeStringSync(WrapDartTestInLibrary(testPath)); | 491 dartLibrary.writeStringSync(WrapDartTestInLibrary(testPath)); |
| 474 dartLibrary.closeSync(); | 492 dartLibrary.closeSync(); |
| 475 } | 493 } |
| 476 | 494 |
| 477 File file = new File(dartWrapperFilename); | 495 File file = new File(dartWrapperFilename); |
| 478 RandomAccessFile dartWrapper = file.openSync(writable: true); | 496 RandomAccessFile dartWrapper = file.openSync(writable: true); |
| 479 dartWrapper.writeStringSync(DartTestWrapper( | 497 dartWrapper.writeStringSync(DartTestWrapper( |
| 480 domLibraryImport, | 498 domLibraryImport, |
| 481 '$dartDir/tests/isolate/src/TestFramework.dart', | 499 '$dartDir/tests/isolate/src/TestFramework.dart', |
| 482 dartLibraryFilename)); | 500 dartLibraryFilename)); |
| 483 dartWrapper.closeSync(); | 501 dartWrapper.closeSync(); |
| 502 htmlTestBase = new File('${tempDir.path}/${getHtmlName(filename)}'); | |
| 484 } else { | 503 } else { |
| 485 return; // TODO(whesse): Implement client web tests on dartium. | 504 dartWrapperFilename = testPath; |
| 505 // TODO(whesse): Once test.py is retired, adjust the relative path in | |
| 506 // the client/samples/dartcombat test to its css file, remove the | |
| 507 // "../../" from this path, and move this out of the isWebTest guard. | |
| 508 htmlTestBase = new File('${tempDir.path}/../../${getHtmlName(filename)}'); | |
| 486 } | 509 } |
| 487 // Create the HTML file for the test. | 510 // Create the HTML file for the test. |
| 488 File htmlTestBase = new File('${tempDir.path}/${getHtmlName(filename)}'); | |
| 489 RandomAccessFile htmlTest = htmlTestBase.openSync(writable: true); | 511 RandomAccessFile htmlTest = htmlTestBase.openSync(writable: true); |
| 490 htmlTest.writeStringSync(GetHtmlContents( | 512 htmlTest.writeStringSync(GetHtmlContents( |
| 491 filename, | 513 filename, |
| 492 '$dartDir/client/testing/unittest/test_controller.js', | 514 '$dartDir/client/testing/unittest/test_controller.js', |
| 493 scriptType, | 515 scriptType, |
| 494 compiledDartWrapperFilename)); | 516 compiledDartWrapperFilename)); |
| 495 htmlTest.closeSync(); | 517 htmlTest.closeSync(); |
| 496 | 518 |
| 497 for (var vmOptions in optionsFromFile["vmOptions"]) { | 519 for (var vmOptions in optionsFromFile["vmOptions"]) { |
| 498 List<String> compilerArgs; | 520 List<String> compilerArgs; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 559 case 'chromium': | 581 case 'chromium': |
| 560 case 'frogium': | 582 case 'frogium': |
| 561 return tempDir.path + 'test.js'; | 583 return tempDir.path + 'test.js'; |
| 562 default: | 584 default: |
| 563 Expect.fail('Unimplemented component scriptType'); | 585 Expect.fail('Unimplemented component scriptType'); |
| 564 return null; | 586 return null; |
| 565 } | 587 } |
| 566 } | 588 } |
| 567 | 589 |
| 568 String getHtmlName(String filename) { | 590 String getHtmlName(String filename) { |
| 569 switch (configuration['component']) { | 591 return filename.replaceAll('/', '_') + configuration['component'] + '.html'; |
| 570 case 'dartium': | |
| 571 return filename.replaceAll(pathSeparator, '_') + 'dartium.html'; | |
| 572 case 'chromium': | |
| 573 case 'frogium': | |
| 574 return 'test.html'; | |
| 575 default: | |
| 576 Expect.fail('Unimplemented component scriptType'); | |
| 577 return null; | |
| 578 } | |
| 579 } | 592 } |
| 580 | 593 |
| 581 String get dumpRenderTreeFilename() { | 594 String get dumpRenderTreeFilename() { |
| 582 if (new Platform().operatingSystem() == 'macos') { | 595 if (new Platform().operatingSystem() == 'macos') { |
| 583 return 'client/tests/drt/DumpRenderTree.app/Contents/' + | 596 return 'client/tests/drt/DumpRenderTree.app/Contents/' + |
| 584 'MacOS/DumpRenderTree'; | 597 'MacOS/DumpRenderTree'; |
| 585 } | 598 } |
| 586 return 'client/tests/drt/DumpRenderTree'; | 599 return 'client/tests/drt/DumpRenderTree'; |
| 587 } | 600 } |
| 588 | 601 |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1023 * $noCrash tests are expected to be flaky but not crash | 1036 * $noCrash tests are expected to be flaky but not crash |
| 1024 * $pass tests are expected to pass | 1037 * $pass tests are expected to pass |
| 1025 * $failOk tests are expected to fail that we won't fix | 1038 * $failOk tests are expected to fail that we won't fix |
| 1026 * $fail tests are expected to fail that we should fix | 1039 * $fail tests are expected to fail that we should fix |
| 1027 * $crash tests are expected to crash that we should fix | 1040 * $crash tests are expected to crash that we should fix |
| 1028 * $timeout tests are allowed to timeout\ | 1041 * $timeout tests are allowed to timeout\ |
| 1029 """; | 1042 """; |
| 1030 print(report); | 1043 print(report); |
| 1031 } | 1044 } |
| 1032 } | 1045 } |
| OLD | NEW |