| 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 | 9 |
| 10 interface TestSuite { | 10 interface TestSuite { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 replyTo.send(""); | 38 replyTo.send(""); |
| 39 }; | 39 }; |
| 40 p.start(); | 40 p.start(); |
| 41 }); | 41 }); |
| 42 } | 42 } |
| 43 } | 43 } |
| 44 | 44 |
| 45 | 45 |
| 46 class CCTestSuite implements TestSuite { | 46 class CCTestSuite implements TestSuite { |
| 47 Map configuration; | 47 Map configuration; |
| 48 String suiteName; |
| 48 String runnerPath; | 49 String runnerPath; |
| 49 List<String> statusFilePaths; | 50 List<String> statusFilePaths; |
| 50 Function doTest; | 51 Function doTest; |
| 51 Function doDone; | 52 Function doDone; |
| 52 ReceivePort receiveTestName; | 53 ReceivePort receiveTestName; |
| 53 TestExpectations testExpectations; | 54 TestExpectations testExpectations; |
| 54 | 55 |
| 55 CCTestSuite(Map this.configuration, | 56 CCTestSuite(Map this.configuration, |
| 57 String this.suiteName, |
| 56 String runnerName, | 58 String runnerName, |
| 57 List<String> this.statusFilePaths) { | 59 List<String> this.statusFilePaths) { |
| 58 runnerPath = TestUtils.getBuildDir(configuration) + runnerName; | 60 runnerPath = TestUtils.buildDir(configuration) + runnerName; |
| 59 } | 61 } |
| 60 | 62 |
| 61 void complexStatusMatching() => false; | 63 void complexStatusMatching() => false; |
| 62 | 64 |
| 63 void testNameHandler(String testName, ignore) { | 65 void testNameHandler(String testName, ignore) { |
| 64 if (testName == "") { | 66 if (testName == "") { |
| 65 receiveTestName.close(); | 67 receiveTestName.close(); |
| 66 doDone(true); | 68 doDone(true); |
| 67 } else { | 69 } else { |
| 68 var timeout = configuration['timeout']; | 70 // If patterns are given only list the files that match one of the |
| 71 // patterns. Use the name "suiteName/testName" for cc tests. |
| 72 var patterns = configuration['patterns']; |
| 73 if (!patterns.isEmpty()) { |
| 74 var constructedName = '$suiteName/$testName'; |
| 75 if (!patterns.some((re) => re.hasMatch(constructedName))) return; |
| 76 } |
| 77 |
| 69 var expectations = testExpectations.expectations(testName); | 78 var expectations = testExpectations.expectations(testName); |
| 70 | 79 |
| 71 if (expectations.contains(SKIP)) return; | 80 if (expectations.contains(SKIP)) return; |
| 72 | 81 |
| 73 // TODO(ager): Pass extra options to the tests. | 82 // The cc test runner takes options after the name of the test |
| 83 // to run. |
| 84 var args = [testName]; |
| 85 args.addAll(TestUtils.standardOptions(configuration)); |
| 86 var timeout = configuration['timeout']; |
| 74 | 87 |
| 75 // TODO(ager): Actually filter out the tests that we don't want | |
| 76 // to run based on the patterns. | |
| 77 doTest(new TestCase(testName, | 88 doTest(new TestCase(testName, |
| 78 runnerPath, | 89 runnerPath, |
| 79 [testName], | 90 args, |
| 80 timeout, | 91 timeout, |
| 81 completeHandler, | 92 completeHandler, |
| 82 expectations)); | 93 expectations)); |
| 94 |
| 83 receiveTestName.receive(testNameHandler); | 95 receiveTestName.receive(testNameHandler); |
| 84 } | 96 } |
| 85 } | 97 } |
| 86 | 98 |
| 87 void forEachTest(Function onTest, [Function onDone]) { | 99 void forEachTest(Function onTest, [Function onDone]) { |
| 88 doTest = onTest; | 100 doTest = onTest; |
| 89 doDone = (ignore) => (onDone != null) ? onDone() : null; | 101 doDone = (ignore) => (onDone != null) ? onDone() : null; |
| 90 | 102 |
| 91 testExpectations = | 103 testExpectations = |
| 92 new TestExpectations(complexMatching: complexStatusMatching()); | 104 new TestExpectations(complexMatching: complexStatusMatching()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 113 String directoryPath; | 125 String directoryPath; |
| 114 List<String> statusFilePaths; | 126 List<String> statusFilePaths; |
| 115 Function doTest; | 127 Function doTest; |
| 116 Function doDone; | 128 Function doDone; |
| 117 String shellPath; | 129 String shellPath; |
| 118 TestExpectations testExpectations; | 130 TestExpectations testExpectations; |
| 119 | 131 |
| 120 StandardTestSuite(Map this.configuration, | 132 StandardTestSuite(Map this.configuration, |
| 121 String this.directoryPath, | 133 String this.directoryPath, |
| 122 List<String> this.statusFilePaths) { | 134 List<String> this.statusFilePaths) { |
| 123 shellPath = TestUtils.getDartShellFileName(configuration) ; | 135 shellPath = TestUtils.dartShellFileName(configuration) ; |
| 124 } | 136 } |
| 125 | 137 |
| 126 | 138 |
| 127 void isTestFile(String filename) => filename.endsWith("Test.dart"); | 139 void isTestFile(String filename) => filename.endsWith("Test.dart"); |
| 128 | 140 |
| 129 void listRecursively() => false; | 141 void listRecursively() => false; |
| 130 | 142 |
| 131 void complexStatusMatching() => false; | 143 void complexStatusMatching() => false; |
| 132 | 144 |
| 133 void forEachTest(Function onTest, [Function onDone = null]) { | 145 void forEachTest(Function onTest, [Function onDone = null]) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 return; | 180 return; |
| 169 } | 181 } |
| 170 | 182 |
| 171 int start = filename.lastIndexOf('src' + new Platform().pathSeparator()); | 183 int start = filename.lastIndexOf('src' + new Platform().pathSeparator()); |
| 172 String testName = filename.substring(start + 4, filename.length - 5); | 184 String testName = filename.substring(start + 4, filename.length - 5); |
| 173 Set<String> expectations = testExpectations.expectations(testName); | 185 Set<String> expectations = testExpectations.expectations(testName); |
| 174 | 186 |
| 175 if (expectations.contains(SKIP)) return; | 187 if (expectations.contains(SKIP)) return; |
| 176 | 188 |
| 177 var optionsFromFile = optionsFromFile(filename); | 189 var optionsFromFile = optionsFromFile(filename); |
| 178 var argumentLists = argumentLists(filename, optionsFromFile); | 190 var isNegative = optionsFromFile['isNegative']; |
| 191 var argumentLists = argumentListsFromFile(filename, optionsFromFile); |
| 192 var timeout = configuration['timeout']; |
| 193 |
| 179 for (var args in argumentLists) { | 194 for (var args in argumentLists) { |
| 180 var timeout = configuration['timeout']; | |
| 181 var isNegative = optionsFromFile['isNegative']; | |
| 182 doTest(new TestCase(testName, | 195 doTest(new TestCase(testName, |
| 183 shellPath, | 196 shellPath, |
| 184 args, | 197 args, |
| 185 timeout, | 198 timeout, |
| 186 completeHandler, | 199 completeHandler, |
| 187 expectations, | 200 expectations, |
| 188 isNegative)); | 201 isNegative)); |
| 189 } | 202 } |
| 190 } | 203 } |
| 191 | 204 |
| 192 void completeHandler(TestCase testCase) { | 205 void completeHandler(TestCase testCase) { |
| 193 } | 206 } |
| 194 | 207 |
| 195 List<List<String>> argumentLists(String filename, Map optionsFromFile) { | 208 |
| 196 List args = ["--ignore-unrecognized-flags"]; | 209 List<List<String>> argumentListsFromFile(String filename, |
| 197 if (configuration["checked"]) { | 210 Map optionsFromFile) { |
| 198 args.add('--enable_asserts'); | 211 List args = TestUtils.standardOptions(configuration); |
| 199 args.add("--enable_type_checks"); | |
| 200 } | |
| 201 if (configuration["component"] == "leg") { | |
| 202 args.add("--enable_leg"); | |
| 203 } | |
| 204 if (configuration["component"] == "dartc") { | |
| 205 if (configuration["mode"] == "release") { | |
| 206 args.add("--optimize"); | |
| 207 } | |
| 208 } | |
| 209 | 212 |
| 210 List<String> dartOptions = optionsFromFile["dartOptions"]; | 213 List<String> dartOptions = optionsFromFile["dartOptions"]; |
| 211 args.addAll(dartOptions == null ? [filename] : dartOptions); | 214 args.addAll(dartOptions == null ? [filename] : dartOptions); |
| 212 | 215 |
| 213 var result = new List<List<String>>(); | 216 var result = new List<List<String>>(); |
| 214 List<List<String>> vmOptionsList = optionsFromFile["vmOptions"]; | 217 List<List<String>> vmOptionsList = optionsFromFile["vmOptions"]; |
| 215 if (vmOptionsList.isEmpty()) { | 218 if (vmOptionsList.isEmpty()) { |
| 216 result.add(args); | 219 result.add(args); |
| 217 } else { | 220 } else { |
| 218 for (var vmOptions in vmOptionsList) { | 221 for (var vmOptions in vmOptionsList) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 } | 273 } |
| 271 | 274 |
| 272 return { "vmOptions": result, | 275 return { "vmOptions": result, |
| 273 "dartOptions": dartOptions, | 276 "dartOptions": dartOptions, |
| 274 "isNegative" : isNegative }; | 277 "isNegative" : isNegative }; |
| 275 } | 278 } |
| 276 } | 279 } |
| 277 | 280 |
| 278 | 281 |
| 279 class TestUtils { | 282 class TestUtils { |
| 280 static String getExecutableName(Map configuration) { | 283 static String executableName(Map configuration) { |
| 281 switch (configuration['component']) { | 284 switch (configuration['component']) { |
| 282 case 'vm': | 285 case 'vm': |
| 283 return 'dart_bin'; | 286 return 'dart_bin'; |
| 284 case 'dartc': | 287 case 'dartc': |
| 285 return 'compiler/bin/dartc_test'; | 288 return 'compiler/bin/dartc_test'; |
| 286 case 'frog': | 289 case 'frog': |
| 287 case 'leg': | 290 case 'leg': |
| 288 return 'frog/bin/frog'; | 291 return 'frog/bin/frog'; |
| 289 case 'frogsh': | 292 case 'frogsh': |
| 290 return 'frog/bin/frogsh'; | 293 return 'frog/bin/frogsh'; |
| 291 default: | 294 default: |
| 292 throw "Unknown executable for: ${configuration['component']}"; | 295 throw "Unknown executable for: ${configuration['component']}"; |
| 293 } | 296 } |
| 294 } | 297 } |
| 295 | 298 |
| 296 | 299 |
| 297 static String getDartShellFileName(Map configuration) { | 300 static String dartShellFileName(Map configuration) { |
| 298 var name = getBuildDir(configuration) + getExecutableName(configuration); | 301 var name = buildDir(configuration) + executableName(configuration); |
| 299 if (!(new File(name)).existsSync()) { | 302 if (!(new File(name)).existsSync()) { |
| 300 throw "Executable '$name' does not exist"; | 303 throw "Executable '$name' does not exist"; |
| 301 } | 304 } |
| 302 return name; | 305 return name; |
| 303 } | 306 } |
| 304 | 307 |
| 305 static String getBuildDir(Map configuration) { | 308 static String buildDir(Map configuration) { |
| 306 var buildDir = ''; | 309 var buildDir = ''; |
| 307 var system = configuration['system']; | 310 var system = configuration['system']; |
| 308 if (system == 'linux') { | 311 if (system == 'linux') { |
| 309 buildDir = 'out/'; | 312 buildDir = 'out/'; |
| 310 } else if (system == 'macos') { | 313 } else if (system == 'macos') { |
| 311 buildDir = 'xcodebuild/'; | 314 buildDir = 'xcodebuild/'; |
| 312 } | 315 } |
| 313 buildDir += (configuration['mode'] == 'debug') ? 'Debug_' : 'Release_'; | 316 buildDir += (configuration['mode'] == 'debug') ? 'Debug_' : 'Release_'; |
| 314 buildDir += configuration['architecture'] + '/'; | 317 buildDir += configuration['architecture'] + '/'; |
| 315 return buildDir; | 318 return buildDir; |
| 316 } | 319 } |
| 320 |
| 321 static List<String> standardOptions(Map configuration) { |
| 322 List args = ["--ignore-unrecognized-flags"]; |
| 323 if (configuration["checked"]) { |
| 324 args.add('--enable_asserts'); |
| 325 args.add("--enable_type_checks"); |
| 326 } |
| 327 if (configuration["component"] == "leg") { |
| 328 args.add("--enable_leg"); |
| 329 } |
| 330 if (configuration["component"] == "dartc") { |
| 331 if (configuration["mode"] == "release") { |
| 332 args.add("--optimize"); |
| 333 } |
| 334 } |
| 335 return args; |
| 336 } |
| 317 } | 337 } |
| OLD | NEW |