| 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("multitest"); | 5 #library("multitest"); |
| 6 | 6 |
| 7 #import("dart:io"); | 7 #import("dart:io"); |
| 8 | 8 |
| 9 // Multitests are Dart test scripts containing lines of the form | 9 // Multitests are Dart test scripts containing lines of the form |
| 10 // " [some dart code] /// [key]: [error type]" | 10 // " [some dart code] /// [key]: [error type]" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 } | 120 } |
| 121 | 121 |
| 122 | 122 |
| 123 void DoMultitest(String filename, | 123 void DoMultitest(String filename, |
| 124 String outputDir, | 124 String outputDir, |
| 125 String testDir, | 125 String testDir, |
| 126 Function doTest(String filename, | 126 Function doTest(String filename, |
| 127 bool isNegative, | 127 bool isNegative, |
| 128 [bool isNegativeIfChecked, | 128 [bool isNegativeIfChecked, |
| 129 bool hasFatalTypeErrors, | 129 bool hasFatalTypeErrors, |
| 130 bool hasRuntimeErrors]), | 130 bool hasRuntimeErrors, |
| 131 String multitestOutcome]), |
| 131 Function multitestDone) { | 132 Function multitestDone) { |
| 132 // Each new test is a single String value in the Map tests. | 133 // Each new test is a single String value in the Map tests. |
| 133 Map<String, String> tests = new Map<String, String>(); | 134 Map<String, String> tests = new Map<String, String>(); |
| 134 Map<String, String> outcomes = new Map<String, String>(); | 135 Map<String, String> outcomes = new Map<String, String>(); |
| 135 ExtractTestsFromMultitest(filename, tests, outcomes); | 136 ExtractTestsFromMultitest(filename, tests, outcomes); |
| 136 | 137 |
| 137 String directory = CreateMultitestDirectory(outputDir, testDir); | 138 String directory = CreateMultitestDirectory(outputDir, testDir); |
| 138 String pathSeparator = new Platform().pathSeparator(); | 139 String pathSeparator = new Platform().pathSeparator(); |
| 139 int start = filename.lastIndexOf(pathSeparator) + 1; | 140 int start = filename.lastIndexOf(pathSeparator) + 1; |
| 140 int end = filename.indexOf('.dart', start); | 141 int end = filename.indexOf('.dart', start); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 151 var outcome = outcomes[key]; | 152 var outcome = outcomes[key]; |
| 152 bool enableFatalTypeErrors = outcome.contains('static type error'); | 153 bool enableFatalTypeErrors = outcome.contains('static type error'); |
| 153 bool hasRuntimeErrors = outcome.contains('runtime error'); | 154 bool hasRuntimeErrors = outcome.contains('runtime error'); |
| 154 bool isNegative = hasRuntimeErrors | 155 bool isNegative = hasRuntimeErrors |
| 155 || outcome.contains('compile-time error'); | 156 || outcome.contains('compile-time error'); |
| 156 bool isNegativeIfChecked = outcome.contains('dynamic type error'); | 157 bool isNegativeIfChecked = outcome.contains('dynamic type error'); |
| 157 doTest(filename, | 158 doTest(filename, |
| 158 isNegative, | 159 isNegative, |
| 159 isNegativeIfChecked, | 160 isNegativeIfChecked, |
| 160 enableFatalTypeErrors, | 161 enableFatalTypeErrors, |
| 161 hasRuntimeErrors); | 162 hasRuntimeErrors, |
| 163 outcome); |
| 162 } | 164 } |
| 163 multitestDone(); | 165 multitestDone(); |
| 164 } | 166 } |
| 165 | 167 |
| 166 | 168 |
| 167 String CreateMultitestDirectory(String outputDir, String testDir) { | 169 String CreateMultitestDirectory(String outputDir, String testDir) { |
| 168 final String generatedTestDirectory = 'generated_tests'; | 170 final String generatedTestDirectory = 'generated_tests'; |
| 169 Directory generatedTestDir = new Directory('$outputDir/generated_tests'); | 171 Directory generatedTestDir = new Directory('$outputDir/generated_tests'); |
| 170 if (!new Directory(outputDir).existsSync()) { | 172 if (!new Directory(outputDir).existsSync()) { |
| 171 new Directory(outputDir).createSync(); | 173 new Directory(outputDir).createSync(); |
| 172 } | 174 } |
| 173 if (!generatedTestDir.existsSync()) { | 175 if (!generatedTestDir.existsSync()) { |
| 174 generatedTestDir.createSync(); | 176 generatedTestDir.createSync(); |
| 175 } | 177 } |
| 176 var split = testDir.split('/'); | 178 var split = testDir.split('/'); |
| 177 var lastComponent = split.removeLast(); | 179 var lastComponent = split.removeLast(); |
| 178 Expect.isTrue(lastComponent == 'src'); | 180 Expect.isTrue(lastComponent == 'src'); |
| 179 String path = '${generatedTestDir.path}/${split.last()}'; | 181 String path = '${generatedTestDir.path}/${split.last()}'; |
| 180 Directory dir = new Directory(path); | 182 Directory dir = new Directory(path); |
| 181 if (!dir.existsSync()) { | 183 if (!dir.existsSync()) { |
| 182 dir.createSync(); | 184 dir.createSync(); |
| 183 } | 185 } |
| 184 return path; | 186 return path; |
| 185 } | 187 } |
| OLD | NEW |