| 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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 } | 392 } |
| 393 | 393 |
| 394 void processFile(String filename) { | 394 void processFile(String filename) { |
| 395 if (!isTestFile(filename)) return; | 395 if (!isTestFile(filename)) return; |
| 396 | 396 |
| 397 // Only run the tests that match the pattern. | 397 // Only run the tests that match the pattern. |
| 398 RegExp pattern = configuration['selectors'][suiteName]; | 398 RegExp pattern = configuration['selectors'][suiteName]; |
| 399 if (!pattern.hasMatch(filename)) return; | 399 if (!pattern.hasMatch(filename)) return; |
| 400 if (filename.endsWith('test_config.dart')) return; | 400 if (filename.endsWith('test_config.dart')) return; |
| 401 | 401 |
| 402 var optionsFromFile = optionsFromFile(filename); | 402 var optionsFromFile = readOptionsFromFile(filename); |
| 403 Function createTestCase = makeTestCaseCreator(optionsFromFile); | 403 Function createTestCase = makeTestCaseCreator(optionsFromFile); |
| 404 | 404 |
| 405 if (optionsFromFile['isMultitest']) { | 405 if (optionsFromFile['isMultitest']) { |
| 406 testGeneratorStarted(); | 406 testGeneratorStarted(); |
| 407 DoMultitest(filename, | 407 DoMultitest(filename, |
| 408 TestUtils.buildDir(configuration), | 408 TestUtils.buildDir(configuration), |
| 409 directoryPath, | 409 directoryPath, |
| 410 createTestCase, | 410 createTestCase, |
| 411 testGeneratorDone); | 411 testGeneratorDone); |
| 412 } else { | 412 } else { |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 args.add('--fatal-type-errors'); | 719 args.add('--fatal-type-errors'); |
| 720 } | 720 } |
| 721 | 721 |
| 722 bool isMultitest = optionsFromFile["isMultitest"]; | 722 bool isMultitest = optionsFromFile["isMultitest"]; |
| 723 List<String> dartOptions = optionsFromFile["dartOptions"]; | 723 List<String> dartOptions = optionsFromFile["dartOptions"]; |
| 724 List<List<String>> vmOptionsList = optionsFromFile["vmOptions"]; | 724 List<List<String>> vmOptionsList = optionsFromFile["vmOptions"]; |
| 725 Expect.isTrue(!isMultitest || dartOptions == null); | 725 Expect.isTrue(!isMultitest || dartOptions == null); |
| 726 if (dartOptions == null) { | 726 if (dartOptions == null) { |
| 727 args.add(filename); | 727 args.add(filename); |
| 728 } else { | 728 } else { |
| 729 var filename = dartOptions[0]; | 729 var executable_name = dartOptions[0]; |
| 730 // TODO(ager): Get rid of this hack when the runtime checkout goes away. | 730 // TODO(ager): Get rid of this hack when the runtime checkout goes away. |
| 731 var file = new File(filename); | 731 var file = new File(executable_name); |
| 732 if (!file.existsSync()) { | 732 if (!file.existsSync()) { |
| 733 filename = '../$filename'; | 733 executable_name = '../$filename'; |
| 734 Expect.isTrue(new File(filename).existsSync()); | 734 Expect.isTrue(new File(executable_name).existsSync()); |
| 735 dartOptions[0] = filename; | 735 dartOptions[0] = executable_name; |
| 736 } | 736 } |
| 737 args.addAll(dartOptions); | 737 args.addAll(dartOptions); |
| 738 } | 738 } |
| 739 | 739 |
| 740 var result = new List<List<String>>(); | 740 var result = new List<List<String>>(); |
| 741 Expect.isFalse(vmOptionsList.isEmpty(), "empty vmOptionsList"); | 741 Expect.isFalse(vmOptionsList.isEmpty(), "empty vmOptionsList"); |
| 742 for (var vmOptions in vmOptionsList) { | 742 for (var vmOptions in vmOptionsList) { |
| 743 var options = new List<String>.from(vmOptions); | 743 var options = new List<String>.from(vmOptions); |
| 744 options.addAll(args); | 744 options.addAll(args); |
| 745 result.add(options); | 745 result.add(options); |
| 746 } | 746 } |
| 747 | 747 |
| 748 return result; | 748 return result; |
| 749 } | 749 } |
| 750 | 750 |
| 751 Map optionsFromFile(String filename) { | 751 Map readOptionsFromFile(String filename) { |
| 752 RegExp testOptionsRegExp = const RegExp(@"// VMOptions=(.*)"); | 752 RegExp testOptionsRegExp = const RegExp(@"// VMOptions=(.*)"); |
| 753 RegExp dartOptionsRegExp = const RegExp(@"// DartOptions=(.*)"); | 753 RegExp dartOptionsRegExp = const RegExp(@"// DartOptions=(.*)"); |
| 754 RegExp multiTestRegExp = const RegExp(@"/// [0-9][0-9]:(.*)"); | 754 RegExp multiTestRegExp = const RegExp(@"/// [0-9][0-9]:(.*)"); |
| 755 RegExp leadingHashRegExp = const RegExp(@"^#", multiLine: true); | 755 RegExp leadingHashRegExp = const RegExp(@"^#", multiLine: true); |
| 756 RegExp isolateStubsRegExp = const RegExp(@"// IsolateStubs=(.*)"); | 756 RegExp isolateStubsRegExp = const RegExp(@"// IsolateStubs=(.*)"); |
| 757 RegExp domImportRegExp = | 757 RegExp domImportRegExp = |
| 758 const RegExp(@"^#import.*(dart:(dom|html)|html\.dart).*\)", | 758 const RegExp(@"^#import.*(dart:(dom|html)|html\.dart).*\)", |
| 759 multiLine: true); | 759 multiLine: true); |
| 760 RegExp libraryDefinitionRegExp = | 760 RegExp libraryDefinitionRegExp = |
| 761 const RegExp(@"^#library\(", multiLine: true); | 761 const RegExp(@"^#library\(", multiLine: true); |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 if (name == '') { | 1054 if (name == '') { |
| 1055 name = '${buildDir(configuration)}/${compilerName(configuration)}'; | 1055 name = '${buildDir(configuration)}/${compilerName(configuration)}'; |
| 1056 } | 1056 } |
| 1057 if (!(new File(name)).existsSync() && !configuration['list']) { | 1057 if (!(new File(name)).existsSync() && !configuration['list']) { |
| 1058 throw "Executable '$name' does not exist"; | 1058 throw "Executable '$name' does not exist"; |
| 1059 } | 1059 } |
| 1060 return name; | 1060 return name; |
| 1061 } | 1061 } |
| 1062 | 1062 |
| 1063 static String outputDir(Map configuration) { | 1063 static String outputDir(Map configuration) { |
| 1064 var outputDir = ''; | 1064 var result = ''; |
| 1065 var system = configuration['system']; | 1065 var system = configuration['system']; |
| 1066 if (system == 'linux') { | 1066 if (system == 'linux') { |
| 1067 outputDir = 'out/'; | 1067 result = 'out/'; |
| 1068 } else if (system == 'macos') { | 1068 } else if (system == 'macos') { |
| 1069 outputDir = 'xcodebuild/'; | 1069 result = 'xcodebuild/'; |
| 1070 } | 1070 } |
| 1071 return outputDir; | 1071 return result; |
| 1072 } | 1072 } |
| 1073 | 1073 |
| 1074 static String buildDir(Map configuration) { | 1074 static String buildDir(Map configuration) { |
| 1075 var buildDir = outputDir(configuration); | 1075 var result = outputDir(configuration); |
| 1076 buildDir += (configuration['mode'] == 'debug') ? 'Debug_' : 'Release_'; | 1076 result += (configuration['mode'] == 'debug') ? 'Debug_' : 'Release_'; |
| 1077 buildDir += configuration['arch']; | 1077 result += configuration['arch']; |
| 1078 return buildDir; | 1078 return result; |
| 1079 } | 1079 } |
| 1080 | 1080 |
| 1081 static String dartDir() { | 1081 static String dartDir() { |
| 1082 String scriptPath = new Options().script.replaceAll('\\', '/'); | 1082 String scriptPath = new Options().script.replaceAll('\\', '/'); |
| 1083 String toolsDir = scriptPath.substring(0, scriptPath.lastIndexOf('/')); | 1083 String toolsDir = scriptPath.substring(0, scriptPath.lastIndexOf('/')); |
| 1084 return new File('$toolsDir/..').fullPathSync().replaceAll('\\', '/'); | 1084 return new File('$toolsDir/..').fullPathSync().replaceAll('\\', '/'); |
| 1085 } | 1085 } |
| 1086 | 1086 |
| 1087 static List<String> standardOptions(Map configuration) { | 1087 static List<String> standardOptions(Map configuration) { |
| 1088 List args = ["--ignore-unrecognized-flags"]; | 1088 List args = ["--ignore-unrecognized-flags"]; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1142 * $noCrash tests are expected to be flaky but not crash | 1142 * $noCrash tests are expected to be flaky but not crash |
| 1143 * $pass tests are expected to pass | 1143 * $pass tests are expected to pass |
| 1144 * $failOk tests are expected to fail that we won't fix | 1144 * $failOk tests are expected to fail that we won't fix |
| 1145 * $fail tests are expected to fail that we should fix | 1145 * $fail tests are expected to fail that we should fix |
| 1146 * $crash tests are expected to crash that we should fix | 1146 * $crash tests are expected to crash that we should fix |
| 1147 * $timeout tests are allowed to timeout | 1147 * $timeout tests are allowed to timeout |
| 1148 """; | 1148 """; |
| 1149 print(report); | 1149 print(report); |
| 1150 } | 1150 } |
| 1151 } | 1151 } |
| OLD | NEW |