Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 5 /** |
| 6 * Classes and methods for enumerating and preparing tests. | 6 * Classes and methods for enumerating and preparing tests. |
| 7 * | 7 * |
| 8 * This library includes: | 8 * This library includes: |
| 9 * | 9 * |
| 10 * - Creating tests by listing all the Dart files in certain directories, | 10 * - Creating tests by listing all the Dart files in certain directories, |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 303 * The tests are compiled into a monolithic executable by the build step. | 303 * The tests are compiled into a monolithic executable by the build step. |
| 304 * The executable lists its tests when run with the --list command line flag. | 304 * The executable lists its tests when run with the --list command line flag. |
| 305 * Individual tests are run by specifying them on the command line. | 305 * Individual tests are run by specifying them on the command line. |
| 306 */ | 306 */ |
| 307 class CCTestSuite extends TestSuite { | 307 class CCTestSuite extends TestSuite { |
| 308 final String testPrefix; | 308 final String testPrefix; |
| 309 String targetRunnerPath; | 309 String targetRunnerPath; |
| 310 String hostRunnerPath; | 310 String hostRunnerPath; |
| 311 final String dartDir; | 311 final String dartDir; |
| 312 List<String> statusFilePaths; | 312 List<String> statusFilePaths; |
| 313 TestCaseEvent doTest; | 313 Function doTest; |
| 314 VoidFunction doDone; | 314 VoidFunction doDone; |
| 315 ReceivePort receiveTestName; | 315 ReceivePort receiveTestName; |
| 316 TestExpectations testExpectations; | 316 TestExpectations testExpectations; |
| 317 | 317 |
| 318 CCTestSuite(Map configuration, | 318 CCTestSuite(Map configuration, |
| 319 String suiteName, | 319 String suiteName, |
| 320 String runnerName, | 320 String runnerName, |
| 321 List<String> this.statusFilePaths, | 321 List<String> this.statusFilePaths, |
| 322 {this.testPrefix: ''}) | 322 {this.testPrefix: ''}) |
| 323 : super(configuration, suiteName), | 323 : super(configuration, suiteName), |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 353 | 353 |
| 354 if (configuration["report"]) { | 354 if (configuration["report"]) { |
| 355 SummaryReport.add(expectations); | 355 SummaryReport.add(expectations); |
| 356 } | 356 } |
| 357 | 357 |
| 358 if (expectations.contains(SKIP)) return; | 358 if (expectations.contains(SKIP)) return; |
| 359 | 359 |
| 360 var args = TestUtils.standardOptions(configuration); | 360 var args = TestUtils.standardOptions(configuration); |
| 361 args.add(testName); | 361 args.add(testName); |
| 362 | 362 |
| 363 var command = CommandBuilder.instance.getCommand( | |
| 364 'run_vm_unittest', targetRunnerPath, args); | |
| 363 doTest( | 365 doTest( |
| 364 new TestCase(constructedName, | 366 new TestCase(constructedName, |
| 365 [new Command('run_vm_unittest', targetRunnerPath, args)], | 367 [command], |
| 366 configuration, | 368 configuration, |
| 367 completeHandler, | |
| 368 expectations)); | 369 expectations)); |
| 369 } | 370 } |
| 370 } | 371 } |
| 371 | 372 |
| 372 void forEachTest(TestCaseEvent onTest, Map testCache, [VoidFunction onDone]) { | 373 void forEachTest(Function onTest, Map testCache, [VoidFunction onDone]) { |
| 373 doTest = onTest; | 374 doTest = onTest; |
| 374 doDone = onDone; | 375 doDone = onDone; |
| 375 | 376 |
| 376 var filesRead = 0; | 377 var filesRead = 0; |
| 377 void statusFileRead() { | 378 void statusFileRead() { |
| 378 filesRead++; | 379 filesRead++; |
| 379 if (filesRead == statusFilePaths.length) { | 380 if (filesRead == statusFilePaths.length) { |
| 380 receiveTestName = new ReceivePort(); | 381 receiveTestName = new ReceivePort(); |
| 381 var port = spawnFunction(ccTestLister); | 382 var port = spawnFunction(ccTestLister); |
| 382 port.send(hostRunnerPath, receiveTestName.toSendPort()); | 383 port.send(hostRunnerPath, receiveTestName.toSendPort()); |
| 383 receiveTestName.receive(testNameHandler); | 384 receiveTestName.receive(testNameHandler); |
| 384 } | 385 } |
| 385 } | 386 } |
| 386 | 387 |
| 387 testExpectations = new TestExpectations(); | 388 testExpectations = new TestExpectations(); |
| 388 for (var statusFilePath in statusFilePaths) { | 389 for (var statusFilePath in statusFilePaths) { |
| 389 ReadTestExpectationsInto(testExpectations, | 390 ReadTestExpectationsInto(testExpectations, |
| 390 '$dartDir/$statusFilePath', | 391 '$dartDir/$statusFilePath', |
| 391 configuration, | 392 configuration, |
| 392 statusFileRead); | 393 statusFileRead); |
| 393 } | 394 } |
| 394 } | 395 } |
| 395 | |
| 396 void completeHandler(TestCase testCase) { | |
| 397 } | |
| 398 } | 396 } |
| 399 | 397 |
| 400 | 398 |
| 401 class TestInformation { | 399 class TestInformation { |
| 402 Path filePath; | 400 Path filePath; |
| 403 Map optionsFromFile; | 401 Map optionsFromFile; |
| 404 bool hasCompileError; | 402 bool hasCompileError; |
| 405 bool hasRuntimeError; | 403 bool hasRuntimeError; |
| 406 bool isNegativeIfChecked; | 404 bool isNegativeIfChecked; |
| 407 bool hasFatalTypeErrors; | 405 bool hasFatalTypeErrors; |
| 408 Set<String> multitestOutcome; | 406 Set<String> multitestOutcome; |
| 409 | 407 |
| 410 TestInformation(this.filePath, this.optionsFromFile, | 408 TestInformation(this.filePath, this.optionsFromFile, |
| 411 this.hasCompileError, this.hasRuntimeError, | 409 this.hasCompileError, this.hasRuntimeError, |
| 412 this.isNegativeIfChecked, this.hasFatalTypeErrors, | 410 this.isNegativeIfChecked, this.hasFatalTypeErrors, |
| 413 this.multitestOutcome) { | 411 this.multitestOutcome) { |
| 414 assert(filePath.isAbsolute); | 412 assert(filePath.isAbsolute); |
| 415 } | 413 } |
| 416 } | 414 } |
| 417 | 415 |
| 418 /** | 416 /** |
| 419 * A standard [TestSuite] implementation that searches for tests in a | 417 * A standard [TestSuite] implementation that searches for tests in a |
| 420 * directory, and creates [TestCase]s that compile and/or run them. | 418 * directory, and creates [TestCase]s that compile and/or run them. |
| 421 */ | 419 */ |
| 422 class StandardTestSuite extends TestSuite { | 420 class StandardTestSuite extends TestSuite { |
| 423 final Path suiteDir; | 421 final Path suiteDir; |
| 424 final List<String> statusFilePaths; | 422 final List<String> statusFilePaths; |
| 425 TestCaseEvent doTest; | 423 Function doTest; |
| 426 TestExpectations testExpectations; | 424 TestExpectations testExpectations; |
| 427 List<TestInformation> cachedTests; | 425 List<TestInformation> cachedTests; |
| 428 final Path dartDir; | 426 final Path dartDir; |
| 429 Predicate<String> isTestFilePredicate; | 427 Predicate<String> isTestFilePredicate; |
| 430 final bool listRecursively; | 428 final bool listRecursively; |
| 431 | 429 |
| 432 static final RegExp multiTestRegExp = new RegExp(r"/// [0-9][0-9]:(.*)"); | 430 static final RegExp multiTestRegExp = new RegExp(r"/// [0-9][0-9]:(.*)"); |
| 433 | 431 |
| 434 StandardTestSuite(Map configuration, | 432 StandardTestSuite(Map configuration, |
| 435 String suiteName, | 433 String suiteName, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 499 */ | 497 */ |
| 500 bool isTestFile(String filename) { | 498 bool isTestFile(String filename) { |
| 501 // Use the specified predicate, if provided. | 499 // Use the specified predicate, if provided. |
| 502 if (isTestFilePredicate != null) return isTestFilePredicate(filename); | 500 if (isTestFilePredicate != null) return isTestFilePredicate(filename); |
| 503 | 501 |
| 504 return filename.endsWith("Test.dart"); | 502 return filename.endsWith("Test.dart"); |
| 505 } | 503 } |
| 506 | 504 |
| 507 List<String> additionalOptions(Path filePath) => []; | 505 List<String> additionalOptions(Path filePath) => []; |
| 508 | 506 |
| 509 void forEachTest(TestCaseEvent onTest, Map testCache, [VoidFunction onDone]) { | 507 void forEachTest(Function onTest, Map testCache, [VoidFunction onDone]) { |
| 510 updateDartium().then((_) { | 508 updateDartium().then((_) { |
| 511 doTest = onTest; | 509 doTest = onTest; |
| 512 | 510 |
| 513 return readExpectations(); | 511 return readExpectations(); |
| 514 }).then((expectations) { | 512 }).then((expectations) { |
| 515 testExpectations = expectations; | 513 testExpectations = expectations; |
| 516 | 514 |
| 517 // Checked if we have already found and generated the tests for | 515 // Checked if we have already found and generated the tests for |
| 518 // this suite. | 516 // this suite. |
| 519 if (!testCache.containsKey(suiteName)) { | 517 if (!testCache.containsKey(suiteName)) { |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 732 var commonArguments = commonArgumentsFromFile(info.filePath, | 730 var commonArguments = commonArgumentsFromFile(info.filePath, |
| 733 info.optionsFromFile); | 731 info.optionsFromFile); |
| 734 | 732 |
| 735 List<List<String>> vmOptionsList = getVmOptions(info.optionsFromFile); | 733 List<List<String>> vmOptionsList = getVmOptions(info.optionsFromFile); |
| 736 assert(!vmOptionsList.isEmpty); | 734 assert(!vmOptionsList.isEmpty); |
| 737 | 735 |
| 738 for (var vmOptions in vmOptionsList) { | 736 for (var vmOptions in vmOptionsList) { |
| 739 doTest(new TestCase('$suiteName/$testName', | 737 doTest(new TestCase('$suiteName/$testName', |
| 740 makeCommands(info, vmOptions, commonArguments), | 738 makeCommands(info, vmOptions, commonArguments), |
| 741 configuration, | 739 configuration, |
| 742 completeHandler, | |
| 743 expectations, | 740 expectations, |
| 744 isNegative: isNegative, | 741 isNegative: isNegative, |
| 745 info: info)); | 742 info: info)); |
| 746 } | 743 } |
| 747 } | 744 } |
| 748 | 745 |
| 749 List<Command> makeCommands(TestInformation info, var vmOptions, var args) { | 746 List<Command> makeCommands(TestInformation info, var vmOptions, var args) { |
| 750 var compiler = configuration['compiler']; | 747 var compiler = configuration['compiler']; |
| 751 switch (compiler) { | 748 switch (compiler) { |
| 752 case 'dart2js': | 749 case 'dart2js': |
| 753 args = new List.from(args); | 750 args = new List.from(args); |
| 754 String tempDir = createOutputDirectory(info.filePath, ''); | 751 String tempDir = createOutputDirectory(info.filePath, ''); |
| 755 args.add('--out=$tempDir/out.js'); | 752 args.add('--out=$tempDir/out.js'); |
| 756 | 753 |
| 757 List<Command> commands = | 754 var command = CommandBuilder.instance.getCompilationCommand( |
| 758 <Command>[new CompilationCommand(compiler, | 755 compiler, "$tempDir/out.js", !useSdk, |
| 759 "$tempDir/out.js", | 756 dart2JsBootstrapDependencies, compilerPath, args); |
| 760 !useSdk, | 757 |
| 761 dart2JsBootstrapDependencies, | 758 List<Command> commands = <Command>[command]; |
| 762 compilerPath, | |
| 763 args)]; | |
| 764 if (info.hasCompileError) { | 759 if (info.hasCompileError) { |
| 765 // Do not attempt to run the compiled result. A compilation | 760 // Do not attempt to run the compiled result. A compilation |
| 766 // error should be reported by the compilation command. | 761 // error should be reported by the compilation command. |
| 767 } else if (configuration['runtime'] == 'd8') { | 762 } else if (configuration['runtime'] == 'd8') { |
| 768 commands.add(new Command("d8", d8FileName, ['$tempDir/out.js'])); | 763 commands.add(CommandBuilder.instance.getCommand( |
| 764 "d8", d8FileName, ['$tempDir/out.js'])); | |
| 769 } else if (configuration['runtime'] == 'jsshell') { | 765 } else if (configuration['runtime'] == 'jsshell') { |
| 770 commands.add( | 766 commands.add(CommandBuilder.instance.getCommand( |
| 771 new Command("jsshell", jsShellFileName, ['$tempDir/out.js'])); | 767 "jsshell", jsShellFileName, ['$tempDir/out.js'])); |
| 772 } | 768 } |
| 773 return commands; | 769 return commands; |
| 774 | 770 |
| 775 case 'dart2dart': | 771 case 'dart2dart': |
| 776 args = new List.from(args); | 772 args = new List.from(args); |
| 777 args.add('--output-type=dart'); | 773 args.add('--output-type=dart'); |
| 778 String tempDir = createOutputDirectory(info.filePath, ''); | 774 String tempDir = createOutputDirectory(info.filePath, ''); |
| 779 args.add('--out=$tempDir/out.dart'); | 775 args.add('--out=$tempDir/out.dart'); |
| 780 | 776 |
| 781 List<Command> commands = | 777 List<Command> commands = |
| 782 <Command>[new CompilationCommand(compiler, | 778 <Command>[CommandBuilder.instance.getCompilationCommand( |
| 783 "$tempDir/out.dart", | 779 compiler, "$tempDir/out.dart", !useSdk, |
| 784 !useSdk, | 780 dart2JsBootstrapDependencies, compilerPath, args)]; |
| 785 dart2JsBootstrapDependencies, | |
| 786 compilerPath, | |
| 787 args)]; | |
| 788 if (info.hasCompileError) { | 781 if (info.hasCompileError) { |
| 789 // Do not attempt to run the compiled result. A compilation | 782 // Do not attempt to run the compiled result. A compilation |
| 790 // error should be reported by the compilation command. | 783 // error should be reported by the compilation command. |
| 791 } else if (configuration['runtime'] == 'vm') { | 784 } else if (configuration['runtime'] == 'vm') { |
| 792 // TODO(antonm): support checked. | 785 // TODO(antonm): support checked. |
| 793 var vmArguments = new List.from(vmOptions); | 786 var vmArguments = new List.from(vmOptions); |
| 794 vmArguments.addAll([ | 787 vmArguments.addAll([ |
| 795 '--ignore-unrecognized-flags', '$tempDir/out.dart']); | 788 '--ignore-unrecognized-flags', '$tempDir/out.dart']); |
| 796 commands.add(new Command("vm", vmFileName, vmArguments)); | 789 commands.add( |
| 790 CommandBuilder.instance.getCommand("vm", vmFileName, vmArguments)); | |
| 797 } else { | 791 } else { |
| 798 throw 'Unsupported runtime ${configuration["runtime"]} for dart2dart'; | 792 throw 'Unsupported runtime ${configuration["runtime"]} for dart2dart'; |
| 799 } | 793 } |
| 800 return commands; | 794 return commands; |
| 801 | 795 |
| 802 case 'none': | 796 case 'none': |
| 803 case 'dartc': | 797 var arguments = new List.from(vmOptions); |
| 798 arguments.addAll(args); | |
| 799 return <Command>[CommandBuilder.instance.getCommand( | |
| 800 'vm', dartShellFileName, arguments)]; | |
| 801 | |
| 804 case 'dartanalyzer': | 802 case 'dartanalyzer': |
| 805 case 'dart2analyzer': | 803 case 'dart2analyzer': |
| 806 var displayName = (configuration['compiler'] == 'none' | 804 return <Command>[CommandBuilder.instance.getAnalysisCommand( |
| 807 ? 'vm' : configuration['compiler']); | 805 compiler, dartShellFileName, args, flavour: compiler)]; |
| 808 var arguments = new List.from(vmOptions); | |
| 809 arguments.addAll(args); | |
| 810 return <Command>[ | |
| 811 new Command(displayName, dartShellFileName, arguments)]; | |
| 812 | 806 |
| 813 default: | 807 default: |
| 814 throw 'Unknown compiler ${configuration["compiler"]}'; | 808 throw 'Unknown compiler ${configuration["compiler"]}'; |
| 815 } | 809 } |
| 816 } | 810 } |
| 817 | 811 |
| 818 CreateTest makeTestCaseCreator(RegExp pattern, Map optionsFromFile) { | 812 CreateTest makeTestCaseCreator(RegExp pattern, Map optionsFromFile) { |
| 819 return (Path filePath, | 813 return (Path filePath, |
| 820 bool hasCompileError, | 814 bool hasCompileError, |
| 821 bool hasRuntimeError, | 815 bool hasRuntimeError, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 893 File file = new File(dartWrapperFilename); | 887 File file = new File(dartWrapperFilename); |
| 894 RandomAccessFile dartWrapper = file.openSync(mode: FileMode.WRITE); | 888 RandomAccessFile dartWrapper = file.openSync(mode: FileMode.WRITE); |
| 895 | 889 |
| 896 var usePackageImport = dartLibraryFilename.segments().contains("pkg"); | 890 var usePackageImport = dartLibraryFilename.segments().contains("pkg"); |
| 897 var libraryPathComponent = _createUrlPathFromFile(dartLibraryFilename); | 891 var libraryPathComponent = _createUrlPathFromFile(dartLibraryFilename); |
| 898 dartWrapper.writeStringSync(dartTestWrapper(usePackageImport, | 892 dartWrapper.writeStringSync(dartTestWrapper(usePackageImport, |
| 899 libraryPathComponent)); | 893 libraryPathComponent)); |
| 900 dartWrapper.closeSync(); | 894 dartWrapper.closeSync(); |
| 901 } | 895 } |
| 902 | 896 |
| 903 | |
| 904 /** | 897 /** |
| 905 * The [StandardTestSuite] has support for tests that | 898 * The [StandardTestSuite] has support for tests that |
| 906 * compile a test from Dart to JavaScript, and then run the resulting | 899 * compile a test from Dart to JavaScript, and then run the resulting |
| 907 * JavaScript. This function creates a working directory to hold the | 900 * JavaScript. This function creates a working directory to hold the |
| 908 * JavaScript version of the test, and copies the appropriate framework | 901 * JavaScript version of the test, and copies the appropriate framework |
| 909 * files to that directory. It creates a [BrowserTestCase], which has | 902 * files to that directory. It creates a [BrowserTestCase], which has |
| 910 * two sequential steps to be run by the [ProcessQueue] when the test is | 903 * two sequential steps to be run by the [ProcessQueue] when the test is |
| 911 * executed: a compilation step and an execution step, both with the | 904 * executed: a compilation step and an execution step, both with the |
| 912 * appropriate executable and arguments. The [expectations] object can be | 905 * appropriate executable and arguments. The [expectations] object can be |
| 913 * either a Set<String> if the test is a regular test, or a Map<String | 906 * either a Set<String> if the test is a regular test, or a Map<String |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1001 // compiled, move the input scripts over with the script so they can | 994 // compiled, move the input scripts over with the script so they can |
| 1002 // be accessed. | 995 // be accessed. |
| 1003 String result = new File.fromPath(fromPath).readAsStringSync(); | 996 String result = new File.fromPath(fromPath).readAsStringSync(); |
| 1004 new File('$tempDir/$baseName.dart').writeAsStringSync(result); | 997 new File('$tempDir/$baseName.dart').writeAsStringSync(result); |
| 1005 } | 998 } |
| 1006 } | 999 } |
| 1007 | 1000 |
| 1008 | 1001 |
| 1009 // Variables for browser multi-tests. | 1002 // Variables for browser multi-tests. |
| 1010 List<String> subtestNames = info.optionsFromFile['subtestNames']; | 1003 List<String> subtestNames = info.optionsFromFile['subtestNames']; |
| 1011 BrowserTestCase multitestParentTest; | |
| 1012 int subtestIndex = 0; | 1004 int subtestIndex = 0; |
| 1013 // Construct the command that executes the browser test | 1005 // Construct the command that executes the browser test |
| 1014 do { | 1006 do { |
| 1015 List<Command> commandSet = new List<Command>.from(commands); | 1007 List<Command> commandSet = new List<Command>.from(commands); |
| 1016 if (subtestIndex != 0) { | |
| 1017 // NOTE: The first time we enter this loop, all the compilation | |
| 1018 // commands will be executed. On subsequent loop iterations, we | |
| 1019 // don't need to do any compilations. Thus we set "commandSet = []". | |
| 1020 commandSet = []; | |
| 1021 } | |
| 1022 | 1008 |
| 1023 var htmlPath_subtest = _createUrlPathFromFile(new Path(htmlPath)); | 1009 var htmlPath_subtest = _createUrlPathFromFile(new Path(htmlPath)); |
| 1024 var fullHtmlPath = _getUriForBrowserTest(info, htmlPath_subtest, | 1010 var fullHtmlPath = _getUriForBrowserTest(info, htmlPath_subtest, |
| 1025 subtestNames, subtestIndex); | 1011 subtestNames, subtestIndex); |
| 1026 | 1012 |
| 1027 List<String> args = <String>[]; | 1013 List<String> args = <String>[]; |
| 1028 | 1014 |
| 1029 if (configuration['use_browser_controller']) { | 1015 if (configuration['use_browser_controller']) { |
| 1030 // This command is not actually run, it is used for reproducing | 1016 // This command is not actually run, it is used for reproducing |
| 1031 // the failure. | 1017 // the failure. |
| 1032 args = ['tools/testing/dart/launch_browser.dart', | 1018 args = ['tools/testing/dart/launch_browser.dart', |
| 1033 runtime, | 1019 runtime, |
| 1034 fullHtmlPath]; | 1020 fullHtmlPath]; |
| 1035 commandSet.add(new Command(runtime, | 1021 commandSet.add(CommandBuilder.instance.getBrowserTestCommand( |
| 1036 TestUtils.dartTestExecutable.toString(), | 1022 runtime, fullHtmlPath, |
| 1037 args)); | 1023 TestUtils.dartTestExecutable.toString(), args)); |
| 1038 } else if (TestUtils.usesWebDriver(runtime)) { | 1024 } else if (TestUtils.usesWebDriver(runtime)) { |
| 1039 args = [ | 1025 args = [ |
| 1040 dartDir.append('tools/testing/run_selenium.py').toNativePath(), | 1026 dartDir.append('tools/testing/run_selenium.py').toNativePath(), |
| 1041 '--browser=$runtime', | 1027 '--browser=$runtime', |
| 1042 // NOTE: This value will be overridden by the test runner | 1028 // NOTE: This value will be overridden by the test runner |
| 1043 '--timeout=${configuration['timeout']}', | 1029 '--timeout=${configuration['timeout']}', |
| 1044 '--out=$fullHtmlPath']; | 1030 '--out=$fullHtmlPath']; |
| 1045 if (runtime == 'dartium') { | 1031 if (runtime == 'dartium') { |
| 1046 args.add('--executable=$dartiumFilename'); | 1032 args.add('--executable=$dartiumFilename'); |
| 1047 } | 1033 } |
| 1048 if (subtestIndex != 0) { | 1034 if (subtestIndex != 0) { |
| 1049 args.add('--force-refresh'); | 1035 args.add('--force-refresh'); |
| 1050 } | 1036 } |
| 1051 commandSet.add(new Command(runtime, 'python', args)); | 1037 commandSet.add(CommandBuilder.instance.getSeleniumTestCommand( |
| 1038 runtime, fullHtmlPath, 'python', args)); | |
| 1052 } else { | 1039 } else { |
| 1053 if (runtime != "drt") { | 1040 assert(runtime == "drt"); |
| 1054 print("Unknown runtime $runtime"); | |
| 1055 exit(1); | |
| 1056 } | |
| 1057 | 1041 |
| 1058 var dartFlags = []; | 1042 var dartFlags = []; |
| 1059 var contentShellOptions = []; | 1043 var contentShellOptions = []; |
| 1060 | 1044 |
| 1061 contentShellOptions.add('--no-timeout'); | 1045 contentShellOptions.add('--no-timeout'); |
| 1062 contentShellOptions.add('--dump-render-tree'); | 1046 contentShellOptions.add('--dump-render-tree'); |
| 1063 | 1047 |
| 1064 if (compiler == 'none' || compiler == 'dart2dart') { | 1048 if (compiler == 'none' || compiler == 'dart2dart') { |
| 1065 dartFlags.add('--ignore-unrecognized-flags'); | 1049 dartFlags.add('--ignore-unrecognized-flags'); |
| 1066 if (configuration["checked"]) { | 1050 if (configuration["checked"]) { |
| 1067 dartFlags.add('--enable_asserts'); | 1051 dartFlags.add('--enable_asserts'); |
| 1068 dartFlags.add("--enable_type_checks"); | 1052 dartFlags.add("--enable_type_checks"); |
| 1069 } | 1053 } |
| 1070 dartFlags.addAll(vmOptions); | 1054 dartFlags.addAll(vmOptions); |
| 1071 } | 1055 } |
| 1072 | 1056 |
| 1073 if (expectedOutput != null) { | 1057 if (expectedOutput != null) { |
| 1074 if (expectedOutput.toNativePath().endsWith('.png')) { | 1058 if (expectedOutput.toNativePath().endsWith('.png')) { |
| 1075 // pixel tests are specified by running DRT "foo.html'-p" | 1059 // pixel tests are specified by running DRT "foo.html'-p" |
| 1076 contentShellOptions.add('--notree'); | 1060 contentShellOptions.add('--notree'); |
| 1077 fullHtmlPath = "${fullHtmlPath}'-p"; | 1061 fullHtmlPath = "${fullHtmlPath}'-p"; |
| 1078 } | 1062 } |
| 1079 } | 1063 } |
| 1080 commandSet.add(new ContentShellCommand(contentShellFilename, | 1064 commandSet.add(CommandBuilder.instance.getContentShellCommand( |
| 1081 fullHtmlPath, | 1065 contentShellFilename, fullHtmlPath, contentShellOptions, |
| 1082 contentShellOptions, | 1066 dartFlags, expectedOutput)); |
| 1083 dartFlags, | |
| 1084 expectedOutput)); | |
| 1085 } | 1067 } |
| 1086 | 1068 |
| 1087 // Create BrowserTestCase and queue it. | 1069 // Create BrowserTestCase and queue it. |
| 1088 String testDisplayName = '$suiteName/$testName'; | 1070 String testDisplayName = '$suiteName/$testName'; |
| 1089 var testCase; | 1071 var testCase; |
| 1090 if (info.optionsFromFile['isMultiHtmlTest']) { | 1072 if (info.optionsFromFile['isMultiHtmlTest']) { |
| 1091 testDisplayName = '$testDisplayName/${subtestNames[subtestIndex]}'; | 1073 testDisplayName = '$testDisplayName/${subtestNames[subtestIndex]}'; |
| 1092 testCase = new BrowserTestCase(testDisplayName, | 1074 testCase = new BrowserTestCase(testDisplayName, |
| 1093 commandSet, configuration, completeHandler, | 1075 commandSet, configuration, |
| 1094 expectations['$testName/${subtestNames[subtestIndex]}'], | 1076 expectations['$testName/${subtestNames[subtestIndex]}'], |
| 1095 info, info.hasCompileError || info.hasRuntimeError, fullHtmlPath, | 1077 info, info.hasCompileError || info.hasRuntimeError, fullHtmlPath); |
| 1096 subtestIndex != 0); | |
| 1097 } else { | 1078 } else { |
| 1098 testCase = new BrowserTestCase(testDisplayName, | 1079 testCase = new BrowserTestCase(testDisplayName, |
| 1099 commandSet, configuration, completeHandler, expectations, | 1080 commandSet, configuration, expectations, |
| 1100 info, info.hasCompileError || info.hasRuntimeError, fullHtmlPath, | 1081 info, info.hasCompileError || info.hasRuntimeError, fullHtmlPath); |
| 1101 false); | |
| 1102 } | |
| 1103 if (subtestIndex == 0) { | |
| 1104 multitestParentTest = testCase; | |
| 1105 } else { | |
| 1106 multitestParentTest.addObserver(testCase); | |
| 1107 } | 1082 } |
| 1108 | 1083 |
| 1109 doTest(testCase); | 1084 doTest(testCase); |
| 1110 subtestIndex++; | 1085 subtestIndex++; |
| 1111 } while(subtestIndex < subtestNames.length); | 1086 } while(subtestIndex < subtestNames.length); |
| 1112 } | 1087 } |
| 1113 } | 1088 } |
| 1114 | 1089 |
| 1115 /** Helper to create a compilation command for a single input file. */ | 1090 /** Helper to create a compilation command for a single input file. */ |
| 1116 Command _compileCommand(String inputFile, String outputFile, | 1091 Command _compileCommand(String inputFile, String outputFile, |
| 1117 String compiler, String dir, vmOptions, optionsFromFile) { | 1092 String compiler, String dir, vmOptions, optionsFromFile) { |
| 1118 assert (['dart2js', 'dart2dart'].contains(compiler)); | 1093 assert (['dart2js', 'dart2dart'].contains(compiler)); |
| 1119 String executable = compilerPath; | 1094 String executable = compilerPath; |
| 1120 List<String> args = TestUtils.standardOptions(configuration); | 1095 List<String> args = TestUtils.standardOptions(configuration); |
| 1121 String packageRoot = | 1096 String packageRoot = |
| 1122 packageRootArgument(optionsFromFile['packageRoot']); | 1097 packageRootArgument(optionsFromFile['packageRoot']); |
| 1123 if (packageRoot != null) { | 1098 if (packageRoot != null) { |
| 1124 args.add(packageRoot); | 1099 args.add(packageRoot); |
| 1125 } | 1100 } |
| 1126 args.add('--out=$outputFile'); | 1101 args.add('--out=$outputFile'); |
| 1127 args.add(inputFile); | 1102 args.add(inputFile); |
| 1128 if (executable.endsWith('.dart')) { | 1103 if (executable.endsWith('.dart')) { |
| 1129 // Run the compiler script via the Dart VM. | 1104 // Run the compiler script via the Dart VM. |
| 1130 args.insert(0, executable); | 1105 args.insert(0, executable); |
| 1131 executable = dartShellFileName; | 1106 executable = dartShellFileName; |
| 1132 } | 1107 } |
| 1133 return new CompilationCommand(compiler, | 1108 return CommandBuilder.instance.getCompilationCommand( |
| 1134 outputFile, | 1109 compiler, outputFile, !useSdk, |
| 1135 !useSdk, | 1110 dart2JsBootstrapDependencies, compilerPath, args); |
| 1136 dart2JsBootstrapDependencies, | |
| 1137 compilerPath, | |
| 1138 args); | |
| 1139 } | 1111 } |
| 1140 | 1112 |
| 1141 /** | 1113 /** |
| 1142 * Create a directory for the generated test. If a Dart language test | 1114 * Create a directory for the generated test. If a Dart language test |
| 1143 * needs to be run in a browser, the Dart test needs to be embedded in | 1115 * needs to be run in a browser, the Dart test needs to be embedded in |
| 1144 * an HTML page, with a testing framework based on scripting and DOM events. | 1116 * an HTML page, with a testing framework based on scripting and DOM events. |
| 1145 * These scripts and pages are written to a generated_test directory | 1117 * These scripts and pages are written to a generated_test directory |
| 1146 * inside the build directory of the checkout. | 1118 * inside the build directory of the checkout. |
| 1147 * | 1119 * |
| 1148 * Those tests which are already HTML web applications (web tests), with | 1120 * Those tests which are already HTML web applications (web tests), with |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1221 if (configuration['dartium'] != '') { | 1193 if (configuration['dartium'] != '') { |
| 1222 return configuration['dartium']; | 1194 return configuration['dartium']; |
| 1223 } | 1195 } |
| 1224 if (Platform.operatingSystem == 'macos') { | 1196 if (Platform.operatingSystem == 'macos') { |
| 1225 return dartDir.append('client/tests/dartium/Chromium.app/Contents/' | 1197 return dartDir.append('client/tests/dartium/Chromium.app/Contents/' |
| 1226 'MacOS/Chromium').toNativePath(); | 1198 'MacOS/Chromium').toNativePath(); |
| 1227 } | 1199 } |
| 1228 return dartDir.append('client/tests/dartium/chrome').toNativePath(); | 1200 return dartDir.append('client/tests/dartium/chrome').toNativePath(); |
| 1229 } | 1201 } |
| 1230 | 1202 |
| 1231 void completeHandler(TestCase testCase) { | |
| 1232 } | |
| 1233 | |
| 1234 List<String> commonArgumentsFromFile(Path filePath, Map optionsFromFile) { | 1203 List<String> commonArgumentsFromFile(Path filePath, Map optionsFromFile) { |
| 1235 List args = TestUtils.standardOptions(configuration); | 1204 List args = TestUtils.standardOptions(configuration); |
| 1236 | 1205 |
| 1237 String packageRoot = packageRootArgument(optionsFromFile['packageRoot']); | 1206 String packageRoot = packageRootArgument(optionsFromFile['packageRoot']); |
| 1238 if (packageRoot != null) { | 1207 if (packageRoot != null) { |
| 1239 args.add(packageRoot); | 1208 args.add(packageRoot); |
| 1240 } | 1209 } |
| 1241 args.addAll(additionalOptions(filePath)); | 1210 args.addAll(additionalOptions(filePath)); |
| 1242 if (configuration['analyzer']) { | 1211 if (configuration['analyzer']) { |
| 1243 args.add('--machine'); | 1212 args.add('--machine'); |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1660 'org.junit.runner.JUnitCore']; | 1629 'org.junit.runner.JUnitCore']; |
| 1661 args.addAll(testClasses); | 1630 args.addAll(testClasses); |
| 1662 | 1631 |
| 1663 // Lengthen the timeout for JUnit tests. It is normal for them | 1632 // Lengthen the timeout for JUnit tests. It is normal for them |
| 1664 // to run for a few minutes. | 1633 // to run for a few minutes. |
| 1665 Map updatedConfiguration = new Map(); | 1634 Map updatedConfiguration = new Map(); |
| 1666 configuration.forEach((key, value) { | 1635 configuration.forEach((key, value) { |
| 1667 updatedConfiguration[key] = value; | 1636 updatedConfiguration[key] = value; |
| 1668 }); | 1637 }); |
| 1669 updatedConfiguration['timeout'] *= 3; | 1638 updatedConfiguration['timeout'] *= 3; |
| 1639 var command = CommandBuilder.instance.getCommand('junit_test', 'java', args) ; | |
|
ricow1
2013/07/30 09:30:11
long line
kustermann
2013/07/31 15:53:54
Done.
| |
| 1670 doTest(new TestCase(suiteName, | 1640 doTest(new TestCase(suiteName, |
| 1671 [new Command('junit_test', 'java', args)], | 1641 [command], |
| 1672 updatedConfiguration, | 1642 updatedConfiguration, |
| 1673 completeHandler, | |
| 1674 new Set<String>.from([PASS]))); | 1643 new Set<String>.from([PASS]))); |
| 1675 doDone(); | 1644 doDone(); |
| 1676 } | 1645 } |
| 1677 | 1646 |
| 1678 void completeHandler(TestCase testCase) { | |
| 1679 } | |
| 1680 | |
| 1681 void computeClassPath() { | 1647 void computeClassPath() { |
| 1682 classPath = | 1648 classPath = |
| 1683 ['$buildDir/analyzer/util/analyzer/dart_analyzer.jar', | 1649 ['$buildDir/analyzer/util/analyzer/dart_analyzer.jar', |
| 1684 '$buildDir/analyzer/dart_analyzer_tests.jar', | 1650 '$buildDir/analyzer/dart_analyzer_tests.jar', |
| 1685 // Third party libraries. | 1651 // Third party libraries. |
| 1686 '$dartDir/third_party/args4j/2.0.12/args4j-2.0.12.jar', | 1652 '$dartDir/third_party/args4j/2.0.12/args4j-2.0.12.jar', |
| 1687 '$dartDir/third_party/guava/r13/guava-13.0.1.jar', | 1653 '$dartDir/third_party/guava/r13/guava-13.0.1.jar', |
| 1688 '$dartDir/third_party/rhino/1_7R3/js.jar', | 1654 '$dartDir/third_party/rhino/1_7R3/js.jar', |
| 1689 '$dartDir/third_party/hamcrest/v1_3/hamcrest-core-1.3.0RC2.jar', | 1655 '$dartDir/third_party/hamcrest/v1_3/hamcrest-core-1.3.0RC2.jar', |
| 1690 '$dartDir/third_party/hamcrest/v1_3/hamcrest-generator-1.3.0RC2.jar', | 1656 '$dartDir/third_party/hamcrest/v1_3/hamcrest-generator-1.3.0RC2.jar', |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1966 * $pass tests are expected to pass | 1932 * $pass tests are expected to pass |
| 1967 * $failOk tests are expected to fail that we won't fix | 1933 * $failOk tests are expected to fail that we won't fix |
| 1968 * $fail tests are expected to fail that we should fix | 1934 * $fail tests are expected to fail that we should fix |
| 1969 * $crash tests are expected to crash that we should fix | 1935 * $crash tests are expected to crash that we should fix |
| 1970 * $timeout tests are allowed to timeout | 1936 * $timeout tests are allowed to timeout |
| 1971 * $compileErrorSkip tests are skipped on browsers due to compile-time error | 1937 * $compileErrorSkip tests are skipped on browsers due to compile-time error |
| 1972 """; | 1938 """; |
| 1973 print(report); | 1939 print(report); |
| 1974 } | 1940 } |
| 1975 } | 1941 } |
| OLD | NEW |