Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: tools/testing/dart/multitest.dart

Issue 9559007: Update test.dart for detection output of machine formatted errors (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added diagnostic for @static-clean conflicts Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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);
141 String baseFilename = filename.substring(start, end); 142 String baseFilename = filename.substring(start, end);
142 for (String key in tests.getKeys()) { 143 for (String key in tests.getKeys()) {
143 final String filename = '$directory/${baseFilename}_$key.dart'; 144 final String filename = '$directory/${baseFilename}_$key.dart';
144 final File file = new File(filename); 145 final File file = new File(filename);
145 146
146 file.createSync(); 147 file.createSync();
147 RandomAccessFile openedFile = file.openSync(FileMode.WRITE); 148 RandomAccessFile openedFile = file.openSync(FileMode.WRITE);
148 var bytes = tests[key].charCodes(); 149 var bytes = tests[key].charCodes();
149 openedFile.writeListSync(bytes, 0, bytes.length); 150 openedFile.writeListSync(bytes, 0, bytes.length);
150 openedFile.closeSync(); 151 openedFile.closeSync();
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,
Bill Hesse 2012/03/02 08:55:18 Can't you remove all the boolean flag arguments fr
zundel 2012/03/02 23:51:00 I think you are right, I added TODO.
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698