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

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

Issue 9477013: Update ConstructorNamedArgumentTest to use the 'runtime-error' directive (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « tests/language/src/ConstructorNamedArgumentsTest.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 List<String> testTemplate = new List<String>(); 74 List<String> testTemplate = new List<String>();
75 testTemplate.add('// Test created from multitest named $filename.'); 75 testTemplate.add('// Test created from multitest named $filename.');
76 // Create the set of multitests, which will have a new test added each 76 // Create the set of multitests, which will have a new test added each
77 // time we see a multitest line with a new key. 77 // time we see a multitest line with a new key.
78 Map<String, List<String>> testsAsLines = new Map<String, List<String>>(); 78 Map<String, List<String>> testsAsLines = new Map<String, List<String>>();
79 79
80 // Matches #import( or #source( followed by " or ' followed by anything 80 // Matches #import( or #source( followed by " or ' followed by anything
81 // except dart: or /, at the beginning of a line. 81 // except dart: or /, at the beginning of a line.
82 RegExp relativeImportRegExp = 82 RegExp relativeImportRegExp =
83 const RegExp('^#(import|source)[(]["\'](?!(dart:|/))'); 83 const RegExp('^#(import|source)[(]["\'](?!(dart:|/))');
84 int lineCount = 0;
84 for (String line in lines) { 85 for (String line in lines) {
86 lineCount++;
85 if (line.contains('///')) { 87 if (line.contains('///')) {
86 var parts = line.split('///')[1].split(':'); 88 var parts = line.split('///')[1].split(':');
87 var key = parts[0].trim(); 89 var key = parts[0].trim();
88 var rest = parts[1].trim(); 90 var rest = parts[1].trim();
89 if (testsAsLines.containsKey(key)) { 91 if (testsAsLines.containsKey(key)) {
90 Expect.equals('continued', rest); 92 Expect.equals('continued', rest);
91 testsAsLines[key].add(line); 93 testsAsLines[key].add(line);
92 } else { 94 } else {
93 (testsAsLines[key] = new List<String>.from(testTemplate)).add(line); 95 (testsAsLines[key] = new List<String>.from(testTemplate)).add(line);
94 outcomes[key] = rest; 96 outcomes[key] = rest;
95 Expect.isTrue(validMultitestOutcomes.contains(rest)); 97 if (!validMultitestOutcomes.contains(rest)) {
98 Expect.fail("Invalid test directive on line ${lineCount}: $rest ");
99 }
96 } 100 }
97 } else { 101 } else {
98 testTemplate.add(line); 102 testTemplate.add(line);
99 for (var test in testsAsLines.getValues()) test.add(line); 103 for (var test in testsAsLines.getValues()) test.add(line);
100 } 104 }
101 // Warn if any import or source tags have relative paths. 105 // Warn if any import or source tags have relative paths.
102 if (relativeImportRegExp.hasMatch(line)) { 106 if (relativeImportRegExp.hasMatch(line)) {
103 print('Warning: Multitest cannot contain relative imports:'); 107 print('Warning: Multitest cannot contain relative imports:');
104 print(' $filename: $line'); 108 print(' $filename: $line');
105 } 109 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 var split = testDir.split('/'); 176 var split = testDir.split('/');
173 var lastComponent = split.removeLast(); 177 var lastComponent = split.removeLast();
174 Expect.isTrue(lastComponent == 'src'); 178 Expect.isTrue(lastComponent == 'src');
175 String path = '${generatedTestDir.path}/${split.last()}'; 179 String path = '${generatedTestDir.path}/${split.last()}';
176 Directory dir = new Directory(path); 180 Directory dir = new Directory(path);
177 if (!dir.existsSync()) { 181 if (!dir.existsSync()) {
178 dir.createSync(); 182 dir.createSync();
179 } 183 }
180 return path; 184 return path;
181 } 185 }
OLDNEW
« no previous file with comments | « tests/language/src/ConstructorNamedArgumentsTest.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698