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

Side by Side Diff: pkg/analysis_server/test/completion_test_support.dart

Issue 806413003: Print a count of total tests and expected failures in completion tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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 | « pkg/analysis_server/test/completion_test.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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.completion.support; 5 library test.completion.support;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analysis_server/src/protocol.dart'; 10 import 'package:analysis_server/src/protocol.dart';
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 for (String result in spec.positiveResults) { 89 for (String result in spec.positiveResults) {
90 assertHasCompletion(result); 90 assertHasCompletion(result);
91 } 91 }
92 for (String result in spec.negativeResults) { 92 for (String result in spec.negativeResults) {
93 assertHasNoCompletion(result); 93 assertHasNoCompletion(result);
94 } 94 }
95 }).whenComplete(() { 95 }).whenComplete(() {
96 super.tearDown(); 96 super.tearDown();
97 }); 97 });
98 } 98 }
99
100 /**
101 * Generate a set of completion tests based on the given [originalSource].
102 *
103 * The source string has completion points embedded in it, which are
104 * identified by '!X' where X is a single character. Each X is matched to
105 * positive or negative results in the array of [validationStrings].
106 * Validation strings contain the name of a prediction with a two character
107 * prefix. The first character of the prefix corresponds to an X in the
108 * [originalSource]. The second character is either a '+' or a '-' indicating
109 * whether the string is a positive or negative result.
110 *
111 * The [originalSource] is the source for a completion test that contains
112 * completion points. The [validationStrings] are the positive and negative
113 * predictions.
114 *
115 * Optional argument [failingTests], if given, is a string, each character of
116 * which corresponds to an X in the [originalSource] for which the test is
117 * expected to fail. This sould be used to mark known completion bugs that
118 * have not yet been fixed.
119 */
120 static void buildTests(String baseName, String originalSource,
121 List<String> results, {Map<String, String> extraFiles, String failingTests :
122 ''}) {
123 List<LocationSpec> completionTests =
124 LocationSpec.from(originalSource, results);
125 completionTests.sort((LocationSpec first, LocationSpec second) {
126 return first.id.compareTo(second.id);
127 });
128 if (completionTests.isEmpty) {
129 test(baseName, () {
130 fail(
131 "Expected exclamation point ('!') within the source denoting the"
132 "position at which code completion should occur");
133 });
134 }
135 Set<String> allSpecIds =
136 completionTests.map((LocationSpec spec) => spec.id).toSet();
137 for (String id in failingTests.split('')) {
138 if (!allSpecIds.contains(id)) {
139 test("$baseName-$id", () {
140 fail(
141 "Test case '$id' included in failingTests, but this id does not ex ist.");
142 });
143 }
144 }
145 for (LocationSpec spec in completionTests) {
146 if (failingTests.contains(spec.id)) {
147 test("$baseName-${spec.id} (expected failure)", () {
148 CompletionTestCase test = new CompletionTestCase();
149 return new Future(() => test.runTest(spec, extraFiles)).then((_) {
150 fail('Test passed - expected to fail.');
151 }, onError: (_) {});
152 });
153 } else {
154 test("$baseName-${spec.id}", () {
155 CompletionTestCase test = new CompletionTestCase();
156 return test.runTest(spec, extraFiles);
157 });
158 }
159 }
160 }
161 } 99 }
162 100
163 /** 101 /**
164 * A specification of the completion results expected at a given location. 102 * A specification of the completion results expected at a given location.
165 */ 103 */
166 class LocationSpec { 104 class LocationSpec {
167 String id; 105 String id;
168 int testLocation = -1; 106 int testLocation = -1;
169 List<String> positiveResults = <String>[]; 107 List<String> positiveResults = <String>[];
170 List<String> negativeResults = <String>[]; 108 List<String> negativeResults = <String>[];
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 err 201 err
264 ..write(' ') 202 ..write(' ')
265 ..write(ch); 203 ..write(ch);
266 } 204 }
267 } 205 }
268 throw new IllegalStateException(err.toString()); 206 throw new IllegalStateException(err.toString());
269 } 207 }
270 return tests.values.toList(); 208 return tests.values.toList();
271 } 209 }
272 } 210 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/completion_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698