| 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 String dartWrapperFilename; |
| 352 if (!isWebTest) { | 358 String scriptPath; |
| 359 if (isWebTest) { |
| 360 scriptPath = 'file://$dartTestFilename'; |
| 361 } else { |
| 362 dartWrapperFilename = '${tempDir.path}/test.dart'; |
| 363 scriptPath = '../../../$dartWrapperFilename'; |
| 353 // test.dart will import the dart test directly, if it is a library, | 364 // 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. | 365 // or indirectly through test_as_library.dart, if it is not. |
| 355 String dartLibraryFilename; | 366 String dartLibraryFilename; |
| 356 if (isLibraryDefinition) { | 367 if (isLibraryDefinition) { |
| 357 dartLibraryFilename = dartTestFilename; | 368 dartLibraryFilename = dartTestFilename; |
| 358 } else { | 369 } else { |
| 359 dartLibraryFilename = 'test_as_library.dart'; | 370 dartLibraryFilename = 'test_as_library.dart'; |
| 360 File file = new File('${tempDir.path}/$dartLibraryFilename'); | 371 File file = new File('${tempDir.path}/$dartLibraryFilename'); |
| 361 RandomAccessFile dartLibrary = file.openSync(writable: true); | 372 RandomAccessFile dartLibrary = file.openSync(writable: true); |
| 362 dartLibrary.writeStringSync(WrapDartTestInLibrary(dartTestFilename)); | 373 dartLibrary.writeStringSync(WrapDartTestInLibrary(dartTestFilename)); |
| 363 dartLibrary.closeSync(); | 374 dartLibrary.closeSync(); |
| 364 } | 375 } |
| 365 | 376 |
| 366 File file = new File(dartWrapperFilename); | 377 File file = new File(dartWrapperFilename); |
| 367 RandomAccessFile dartWrapper = file.openSync(writable: true); | 378 RandomAccessFile dartWrapper = file.openSync(writable: true); |
| 368 dartWrapper.writeStringSync(DartTestWrapper( | 379 dartWrapper.writeStringSync(DartTestWrapper( |
| 369 'dart:dom', | 380 'dart:dom', |
| 370 '../../../tests/isolate/src/TestFramework.dart', | 381 '../../../tests/isolate/src/TestFramework.dart', |
| 371 dartLibraryFilename)); | 382 dartLibraryFilename)); |
| 372 dartWrapper.closeSync(); | 383 dartWrapper.closeSync(); |
| 373 } else { | |
| 374 return; // TODO(whesse): Implement client web tests on dartium. | |
| 375 } | 384 } |
| 376 // Create the HTML file for the test. | 385 // Create the HTML file for the test. |
| 386 // NOTE: This must be 3 directories below the dart root, due to test |
| 387 // client/samples/dartcombat containing a relative path to its .css file. |
| 377 File htmlTestBase = new File('${tempDir.path}/${getHtmlName(filename)}'); | 388 File htmlTestBase = new File('${tempDir.path}/${getHtmlName(filename)}'); |
| 378 RandomAccessFile htmlTest = htmlTestBase.openSync(writable: true); | 389 RandomAccessFile htmlTest = htmlTestBase.openSync(writable: true); |
| 379 htmlTest.writeStringSync(GetHtmlContents( | 390 htmlTest.writeStringSync(GetHtmlContents( |
| 380 filename, | 391 filename, |
| 381 '../../../client/testing/unittest/test_controller.js', | 392 '../../../client/testing/unittest/test_controller.js', |
| 382 scriptType, | 393 scriptType, |
| 383 '../../../$dartWrapperFilename')); | 394 scriptPath)); |
| 384 htmlTest.closeSync(); | 395 htmlTest.closeSync(); |
| 385 | 396 |
| 386 for (var vmOptions in optionsFromFile["vmOptions"]) { | 397 for (var vmOptions in optionsFromFile["vmOptions"]) { |
| 387 var drtFlags = ['-no-timeout']; | 398 var drtFlags = ['--no-timeout']; |
| 388 var dartFlags = ['--enable_asserts', '--enable_type_checks']; | 399 var dartFlags = ['--enable_asserts', '--enable_type_checks']; |
| 389 dartFlags.addAll(vmOptions); | 400 dartFlags.addAll(vmOptions); |
| 390 drtFlags.add('--dart-flags=${Strings.join(dartFlags, " ")}'); | 401 drtFlags.add('--dart-flags=${Strings.join(dartFlags, " ")}'); |
| 391 var args = drtFlags; | 402 var args = drtFlags; |
| 392 args.add(htmlTestBase.fullPathSync()); | 403 args.add(htmlTestBase.fullPathSync()); |
| 393 | 404 |
| 394 // Create BrowserTestCase and queue it. | 405 // Create BrowserTestCase and queue it. |
| 395 var testCase = new BrowserTestCase( | 406 var testCase = new BrowserTestCase( |
| 396 testName, | 407 testName, |
| 397 null, | 408 null, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 428 String testNameBase; | 439 String testNameBase; |
| 429 String testRelativeDir; | 440 String testRelativeDir; |
| 430 String testRelativeDirFlattened; | 441 String testRelativeDirFlattened; |
| 431 | 442 |
| 432 int start = testRelativePath.lastIndexOf('src' + pathSeparator); | 443 int start = testRelativePath.lastIndexOf('src' + pathSeparator); |
| 433 if (start != -1) { | 444 if (start != -1) { |
| 434 Expect.isTrue(testRelativePath.endsWith('.dart')); | 445 Expect.isTrue(testRelativePath.endsWith('.dart')); |
| 435 testNameBase = | 446 testNameBase = |
| 436 testRelativePath.substring(start + 4, testRelativePath.length - 5); | 447 testRelativePath.substring(start + 4, testRelativePath.length - 5); |
| 437 testRelativeDir = testRelativePath.substring(0, start - 1); | 448 testRelativeDir = testRelativePath.substring(0, start - 1); |
| 438 testRelativeDirFlattened = testRelativeDir.replaceAll(pathSeparator, '_'); | 449 testRelativeDirFlattened = testRelativeDir.replaceAll('/', '_'); |
| 439 } else { | 450 } else { |
| 440 Expect.fail('Web tests not imlemented yet'); | 451 Expect.isTrue(testRelativePath.endsWith('_tests.dart')); |
| 452 start = testRelativePath.lastIndexOf(pathSeparator); |
| 453 testNameBase = |
| 454 testRelativePath.substring(start + 1, testRelativePath.length - 11); |
| 441 } | 455 } |
| 442 | 456 |
| 443 if (!new Directory('$dartDir/$buildDir/generated_tests').existsSync()) { | 457 if (!new Directory('$dartDir/$buildDir/generated_tests').existsSync()) { |
| 444 new Directory('$dartDir/$buildDir/generated_tests').createSync(); | 458 new Directory('$dartDir/$buildDir/generated_tests').createSync(); |
| 445 } | 459 } |
| 446 if (!new Directory(outputDirBase).existsSync()) { | 460 if (!new Directory(outputDirBase).existsSync()) { |
| 447 new Directory(outputDirBase).createSync(); | 461 new Directory(outputDirBase).createSync(); |
| 448 } | 462 } |
| 449 Directory tempDir = new Directory( | 463 Directory tempDir = new Directory( |
| 450 '$outputDirBase/${testRelativeDirFlattened}_$testNameBase'); | 464 '$outputDirBase/${testRelativeDirFlattened}_$testNameBase'); |
| 451 if (!tempDir.existsSync()) { | 465 if (!tempDir.existsSync()) { |
| 452 tempDir.createSync(); | 466 tempDir.createSync(); |
| 453 } | 467 } |
| 454 | 468 |
| 455 String dartWrapperFilename = '${tempDir.path}/test.dart'; | 469 String dartWrapperFilename = '${tempDir.path}/test.dart'; |
| 456 String compiledDartWrapperFilename = '${tempDir.path}/test.js'; | 470 String compiledDartWrapperFilename = '${tempDir.path}/test.js'; |
| 457 String domLibraryImport = 'dart:dom'; | 471 String domLibraryImport = 'dart:dom'; |
| 458 if (configuration['component'] == 'chromium') { | 472 if (configuration['component'] == 'chromium') { |
| 459 domLibraryImport = | 473 domLibraryImport = |
| 460 '$dartDir/client/testing/unittest/dom_for_unittest.dart'; | 474 '$dartDir/client/testing/unittest/dom_for_unittest.dart'; |
| 461 } | 475 } |
| 462 | 476 |
| 477 File htmlTestBase; |
| 463 if (!isWebTest) { | 478 if (!isWebTest) { |
| 464 // test.dart will import the dart test directly, if it is a library, | 479 // 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. | 480 // or indirectly through test_as_library.dart, if it is not. |
| 466 String dartLibraryFilename; | 481 String dartLibraryFilename; |
| 467 if (isLibraryDefinition) { | 482 if (isLibraryDefinition) { |
| 468 dartLibraryFilename = testPath; | 483 dartLibraryFilename = testPath; |
| 469 } else { | 484 } else { |
| 470 dartLibraryFilename = 'test_as_library.dart'; | 485 dartLibraryFilename = 'test_as_library.dart'; |
| 471 File file = new File('${tempDir.path}/$dartLibraryFilename'); | 486 File file = new File('${tempDir.path}/$dartLibraryFilename'); |
| 472 RandomAccessFile dartLibrary = file.openSync(writable: true); | 487 RandomAccessFile dartLibrary = file.openSync(writable: true); |
| 473 dartLibrary.writeStringSync(WrapDartTestInLibrary(testPath)); | 488 dartLibrary.writeStringSync(WrapDartTestInLibrary(testPath)); |
| 474 dartLibrary.closeSync(); | 489 dartLibrary.closeSync(); |
| 475 } | 490 } |
| 476 | 491 |
| 477 File file = new File(dartWrapperFilename); | 492 File file = new File(dartWrapperFilename); |
| 478 RandomAccessFile dartWrapper = file.openSync(writable: true); | 493 RandomAccessFile dartWrapper = file.openSync(writable: true); |
| 479 dartWrapper.writeStringSync(DartTestWrapper( | 494 dartWrapper.writeStringSync(DartTestWrapper( |
| 480 domLibraryImport, | 495 domLibraryImport, |
| 481 '$dartDir/tests/isolate/src/TestFramework.dart', | 496 '$dartDir/tests/isolate/src/TestFramework.dart', |
| 482 dartLibraryFilename)); | 497 dartLibraryFilename)); |
| 483 dartWrapper.closeSync(); | 498 dartWrapper.closeSync(); |
| 499 htmlTestBase = new File('${tempDir.path}/${getHtmlName(filename)}'); |
| 484 } else { | 500 } else { |
| 485 return; // TODO(whesse): Implement client web tests on dartium. | 501 dartWrapperFilename = testPath; |
| 502 // TODO(whesse): Once test.py is retired, adjust the relative path in |
| 503 // the client/samples/dartcombat test to its css file, remove the |
| 504 // "../../" from this path, and move this out of the isWebTest guard. |
| 505 htmlTestBase = new File('${tempDir.path}/../../${getHtmlName(filename)}'); |
| 486 } | 506 } |
| 487 // Create the HTML file for the test. | 507 // Create the HTML file for the test. |
| 488 File htmlTestBase = new File('${tempDir.path}/${getHtmlName(filename)}'); | |
| 489 RandomAccessFile htmlTest = htmlTestBase.openSync(writable: true); | 508 RandomAccessFile htmlTest = htmlTestBase.openSync(writable: true); |
| 490 htmlTest.writeStringSync(GetHtmlContents( | 509 htmlTest.writeStringSync(GetHtmlContents( |
| 491 filename, | 510 filename, |
| 492 '$dartDir/client/testing/unittest/test_controller.js', | 511 '$dartDir/client/testing/unittest/test_controller.js', |
| 493 scriptType, | 512 scriptType, |
| 494 compiledDartWrapperFilename)); | 513 compiledDartWrapperFilename)); |
| 495 htmlTest.closeSync(); | 514 htmlTest.closeSync(); |
| 496 | 515 |
| 497 for (var vmOptions in optionsFromFile["vmOptions"]) { | 516 for (var vmOptions in optionsFromFile["vmOptions"]) { |
| 498 List<String> compilerArgs; | 517 List<String> compilerArgs; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 case 'chromium': | 578 case 'chromium': |
| 560 case 'frogium': | 579 case 'frogium': |
| 561 return tempDir.path + 'test.js'; | 580 return tempDir.path + 'test.js'; |
| 562 default: | 581 default: |
| 563 Expect.fail('Unimplemented component scriptType'); | 582 Expect.fail('Unimplemented component scriptType'); |
| 564 return null; | 583 return null; |
| 565 } | 584 } |
| 566 } | 585 } |
| 567 | 586 |
| 568 String getHtmlName(String filename) { | 587 String getHtmlName(String filename) { |
| 569 switch (configuration['component']) { | 588 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 } | 589 } |
| 580 | 590 |
| 581 String get dumpRenderTreeFilename() { | 591 String get dumpRenderTreeFilename() { |
| 582 if (new Platform().operatingSystem() == 'macos') { | 592 if (new Platform().operatingSystem() == 'macos') { |
| 583 return 'client/tests/drt/DumpRenderTree.app/Contents/' + | 593 return 'client/tests/drt/DumpRenderTree.app/Contents/' + |
| 584 'MacOS/DumpRenderTree'; | 594 'MacOS/DumpRenderTree'; |
| 585 } | 595 } |
| 586 return 'client/tests/drt/DumpRenderTree'; | 596 return 'client/tests/drt/DumpRenderTree'; |
| 587 } | 597 } |
| 588 | 598 |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1026 * $noCrash tests are expected to be flaky but not crash | 1036 * $noCrash tests are expected to be flaky but not crash |
| 1027 * $pass tests are expected to pass | 1037 * $pass tests are expected to pass |
| 1028 * $failOk tests are expected to fail that we won't fix | 1038 * $failOk tests are expected to fail that we won't fix |
| 1029 * $fail tests are expected to fail that we should fix | 1039 * $fail tests are expected to fail that we should fix |
| 1030 * $crash tests are expected to crash that we should fix | 1040 * $crash tests are expected to crash that we should fix |
| 1031 * $timeout tests are allowed to timeout\ | 1041 * $timeout tests are allowed to timeout\ |
| 1032 """; | 1042 """; |
| 1033 print(report); | 1043 print(report); |
| 1034 } | 1044 } |
| 1035 } | 1045 } |
| OLD | NEW |