| 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 library multitest; | 5 library multitest; |
| 6 | 6 |
| 7 import "dart:async"; | 7 import "dart:async"; |
| 8 import "dart:io"; | 8 import "dart:io"; |
| 9 import "test_suite.dart"; | 9 import "test_suite.dart"; |
| 10 import "utils.dart"; | 10 import "utils.dart"; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 final String line_separator = | 71 final String line_separator = |
| 72 (first_newline == 0 || contents[first_newline - 1] != '\r') | 72 (first_newline == 0 || contents[first_newline - 1] != '\r') |
| 73 ? '\n' | 73 ? '\n' |
| 74 : '\r\n'; | 74 : '\r\n'; |
| 75 List<String> lines = contents.split(line_separator); | 75 List<String> lines = contents.split(line_separator); |
| 76 if (lines.last == '') lines.removeLast(); | 76 if (lines.last == '') lines.removeLast(); |
| 77 bytes = null; | 77 bytes = null; |
| 78 contents = null; | 78 contents = null; |
| 79 Set<String> validMultitestOutcomes = new Set<String>.from( | 79 Set<String> validMultitestOutcomes = new Set<String>.from( |
| 80 ['ok', 'compile-time error', 'runtime error', | 80 ['ok', 'compile-time error', 'runtime error', |
| 81 'static type warning', 'dynamic type error']); | 81 'static type warning', 'dynamic type error', |
| 82 'checked mode compile-time error']); |
| 82 | 83 |
| 83 List<String> testTemplate = new List<String>(); | 84 List<String> testTemplate = new List<String>(); |
| 84 testTemplate.add( | 85 testTemplate.add( |
| 85 '// Test created from multitest named ${filePath.toNativePath()}.'); | 86 '// Test created from multitest named ${filePath.toNativePath()}.'); |
| 86 // Create the set of multitests, which will have a new test added each | 87 // Create the set of multitests, which will have a new test added each |
| 87 // time we see a multitest line with a new key. | 88 // time we see a multitest line with a new key. |
| 88 Map<String, List<String>> testsAsLines = new Map<String, List<String>>(); | 89 Map<String, List<String>> testsAsLines = new Map<String, List<String>>(); |
| 89 | 90 |
| 90 int lineCount = 0; | 91 int lineCount = 0; |
| 91 for (String line in lines) { | 92 for (String line in lines) { |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 String baseFilename = filePath.filenameWithoutExtension; | 235 String baseFilename = filePath.filenameWithoutExtension; |
| 235 for (String key in tests.keys) { | 236 for (String key in tests.keys) { |
| 236 final Path multitestFilename = | 237 final Path multitestFilename = |
| 237 targetDir.append('${baseFilename}_$key.dart'); | 238 targetDir.append('${baseFilename}_$key.dart'); |
| 238 writeFile(multitestFilename.toNativePath(), tests[key]); | 239 writeFile(multitestFilename.toNativePath(), tests[key]); |
| 239 Set<String> outcome = outcomes[key]; | 240 Set<String> outcome = outcomes[key]; |
| 240 bool hasStaticWarning = outcome.contains('static type warning'); | 241 bool hasStaticWarning = outcome.contains('static type warning'); |
| 241 bool hasRuntimeErrors = outcome.contains('runtime error'); | 242 bool hasRuntimeErrors = outcome.contains('runtime error'); |
| 242 bool hasCompileError = outcome.contains('compile-time error'); | 243 bool hasCompileError = outcome.contains('compile-time error'); |
| 243 bool isNegativeIfChecked = outcome.contains('dynamic type error'); | 244 bool isNegativeIfChecked = outcome.contains('dynamic type error'); |
| 245 bool hasCompileErrorIfChecked = outcome.contains('checked mode compile-tim
e error'); |
| 244 doTest(multitestFilename, | 246 doTest(multitestFilename, |
| 245 hasCompileError, | 247 hasCompileError, |
| 246 hasRuntimeErrors, | 248 hasRuntimeErrors, |
| 247 isNegativeIfChecked: isNegativeIfChecked, | 249 isNegativeIfChecked: isNegativeIfChecked, |
| 250 hasCompileErrorIfChecked: hasCompileErrorIfChecked, |
| 248 hasStaticWarning: hasStaticWarning, | 251 hasStaticWarning: hasStaticWarning, |
| 249 multitestOutcome: outcome, | 252 multitestOutcome: outcome, |
| 250 multitestKey: key, | 253 multitestKey: key, |
| 251 originTestPath: filePath); | 254 originTestPath: filePath); |
| 252 } | 255 } |
| 253 | 256 |
| 254 return null; | 257 return null; |
| 255 }); | 258 }); |
| 256 } | 259 } |
| 257 | 260 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 271 // TestSuite.forDirectory. | 274 // TestSuite.forDirectory. |
| 272 split.removeLast(); | 275 split.removeLast(); |
| 273 } | 276 } |
| 274 String path = '${generatedTestDir.path}/${split.last}'; | 277 String path = '${generatedTestDir.path}/${split.last}'; |
| 275 Directory dir = new Directory(path); | 278 Directory dir = new Directory(path); |
| 276 if (!dir.existsSync()) { | 279 if (!dir.existsSync()) { |
| 277 dir.createSync(); | 280 dir.createSync(); |
| 278 } | 281 } |
| 279 return new Path(new File(path).absolute.path); | 282 return new Path(new File(path).absolute.path); |
| 280 } | 283 } |
| OLD | NEW |