@@ -11,8 +11,6 @@ import 'package:args/src/arg_results.dart';
1111
1212import '../tool/coverage_merger.dart' as coverageMerger;
1313
14- part 'coverage_suite_expected.dart' ;
15-
1614bool debug = false ;
1715
1816Future <void > main ([List <String > arguments = const < String > []]) async {
@@ -111,20 +109,6 @@ Future<void> _run(Directory coverageTmpDir, List<String> arguments) async {
111109 }
112110 }
113111
114- StringBuffer updatedExpectations = new StringBuffer ();
115- updatedExpectations.write ("""
116- // Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
117- // for details. All rights reserved. Use of this source code is governed by a
118- // BSD-style license that can be found in the LICENSE file.
119-
120- part of "coverage_suite.dart";
121-
122- // This is the currently recorded state
123- // using out/ReleaseX64/dart-sdk/bin/dart (which for instance makes a
124- // difference for compute_platform_binaries_location.dart).
125- const Map<String, ({int hitCount, int missCount})> _expect = {
126- """ );
127-
128112 for (MapEntry <Uri , coverageMerger.CoverageInfo > coverageEntry
129113 in coverageData.entries) {
130114 if (coverageEntry.value.error) {
@@ -134,66 +118,36 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
134118 StringBuffer sb = new StringBuffer ();
135119 int hitCount = coverageEntry.value.hitCount;
136120 int missCount = coverageEntry.value.missCount;
137- double percent = (hitCount / (hitCount + missCount) * 100 );
138- if (percent.isNaN) percent = 100 ;
139- if (options.updateExpectations) {
140- updatedExpectations.writeln (" // $percent %." );
141- updatedExpectations.writeln (" \" ${coverageEntry .key }\" : "
142- "(hitCount: $hitCount , missCount: $missCount ,)," );
143- continue ;
144- }
145- bool pass = true ;
146- ({int hitCount, int missCount})? expected =
147- _expect[coverageEntry.key.toString ()];
148- if (expected != null ) {
149- // TODO(jensj): Should we warn if hitCount goes down?
150- // Or be ok with it if both hitCount and missCount goes up?
151- // Or something else?
152- double expectedPercent = (expected.hitCount /
153- (expected.hitCount + expected.missCount) *
154- 100 );
155- if (expectedPercent.isNaN) expectedPercent = 100 ;
156- int requireAtLeast = expectedPercent.floor ();
157- pass = percent >= requireAtLeast;
158- if (! pass) {
159- sb.write ("${coverageEntry .value .visualization }" );
160- sb.write ("\n\n Expected at least $requireAtLeast %, got $percent % "
161- "($hitCount hits (expected: ${expected .hitCount }) and "
162- "$missCount misses (expected: ${expected .missCount }))." );
163- sb.write ("\n\n To re-run this test, run:" );
164- var extraFlags = _assertsEnabled ? ' --enable-asserts' : '' ;
165- // It looks like coverage results vary slightly based on the number of
166- // tasks, so include a `--tasks=` argument in the repro instructions.
167- //
168- // TODO(paulberry): why do coverage results vary based on the number
169- // of tasks? (Note: possibly due to
170- // https://github.com/dart-lang/sdk/issues/42061)
171- sb.write (
172- "\n\n dart$extraFlags pkg/front_end/test/coverage_suite.dart "
173- "--tasks=${options .numberOfWorkers }" );
174- sb.write ("\n\n Or update the expectations directly via" );
175- sb.write (
176- "\n\n dart$extraFlags pkg/front_end/test/coverage_suite.dart "
177- "--tasks=${options .numberOfWorkers } "
178- "--add-and-remove-comments "
179- "--update-expectations" );
180- }
121+ final bool pass = missCount == 0 ;
122+ if (! pass) {
123+ sb.write ("${coverageEntry .value .visualization }" );
124+ double percent = (hitCount / (hitCount + missCount) * 100 );
125+ sb.write ("\n\n Expected 100% coverage, but got $percent % "
126+ "($hitCount hits and $missCount misses)." );
127+ sb.write ("\n\n To re-run this test, run:" );
128+ var extraFlags = _assertsEnabled ? ' --enable-asserts' : '' ;
129+ // It looks like coverage results vary slightly based on the number of
130+ // tasks, so include a `--tasks=` argument in the repro instructions.
131+ //
132+ // TODO(paulberry): why do coverage results vary based on the number
133+ // of tasks? (Note: possibly due to
134+ // https://github.com/dart-lang/sdk/issues/42061)
135+ sb.write (
136+ "\n\n dart$extraFlags pkg/front_end/test/coverage_suite.dart "
137+ "--tasks=${options .numberOfWorkers }" );
138+ sb.write ("\n\n Or automatically insert ignore comments via" );
139+ sb.write (
140+ "\n\n dart$extraFlags pkg/front_end/test/coverage_suite.dart "
141+ "--tasks=${options .numberOfWorkers } "
142+ "--add-and-remove-comments" );
143+ sb.write ("\n\n If that does not work, create a bug report and approve "
144+ "the failure." );
181145 }
182146 addResult (coverageEntry.key.toString (), pass,
183147 log: sb.isEmpty ? null : sb.toString ());
184148 }
185149 }
186150
187- updatedExpectations.writeln ("};" );
188- if (options.updateExpectations) {
189- File f = new File .fromUri (
190- Uri .base .resolve ("pkg/front_end/test/coverage_suite_expected.dart" ));
191- f.writeAsStringSync (updatedExpectations.toString ());
192- ProcessResult formatResult =
193- Process .runSync (Platform .resolvedExecutable, ["format" , f.path]);
194- print ("Formatting exit-code: ${formatResult .exitCode }" );
195- }
196-
197151 // Write results.json and logs.json.
198152 Uri resultJsonUri = options.outputDirectory.resolve ("results.json" );
199153 Uri logsJsonUri = options.outputDirectory.resolve ("logs.json" );
@@ -237,7 +191,6 @@ class Options {
237191 final String ? configurationName;
238192 final bool verbose;
239193 final bool debug;
240- final bool updateExpectations;
241194 final bool addAndRemoveCommentsInFiles;
242195 final Uri outputDirectory;
243196 final int numberOfWorkers;
@@ -246,7 +199,6 @@ class Options {
246199 this .configurationName,
247200 this .verbose,
248201 this .debug,
249- this .updateExpectations,
250202 this .addAndRemoveCommentsInFiles,
251203 this .outputDirectory, {
252204 required this .numberOfWorkers,
@@ -266,8 +218,6 @@ class Options {
266218 abbr: "j" ,
267219 help: "The number of parallel tasks to run." ,
268220 defaultsTo: "${getDefaultThreads ()}" )
269- ..addFlag ("update-expectations" ,
270- help: "update expectations" , defaultsTo: false )
271221 ..addFlag ("add-and-remove-comments" ,
272222 help: "Automatically remove old and then "
273223 "re-add ignore comments in files" ,
@@ -288,7 +238,6 @@ class Options {
288238 if (tasks == null || tasks < 1 ) {
289239 throw "--tasks (-j) has to be an integer >= 1" ;
290240 }
291- bool updateExpectations = parsedOptions["update-expectations" ];
292241 bool addAndRemoveCommentsInFiles = parsedOptions["add-and-remove-comments" ];
293242
294243 if (verbose) {
@@ -298,15 +247,13 @@ class Options {
298247 "debug = ${debug },\n "
299248 "${outputDirectory },\n "
300249 "numberOfWorkers: ${tasks },\n "
301- "updateExpectations = ${updateExpectations }\n "
302250 "addAndRemoveCommentsInFiles = ${addAndRemoveCommentsInFiles }" );
303251 }
304252
305253 return Options (
306254 parsedOptions["named-configuration" ],
307255 verbose,
308256 debug,
309- updateExpectations,
310257 addAndRemoveCommentsInFiles,
311258 outputDirectory,
312259 numberOfWorkers: tasks,
0 commit comments