Skip to content

Commit 4c6120d

Browse files
zandersogspencergoog
authored andcommitted
Revert "Allow Flutter golden file tests to be flaky (flutter#114450)" (flutter#114902)
This reverts commit 53e6876.
1 parent c4e2924 commit 4c6120d

35 files changed

+1351
-2093
lines changed

dev/automated_tests/flutter_test/flutter_gold_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'dart:typed_data';
88

99
import 'package:file/file.dart';
1010
import 'package:file/memory.dart';
11-
import 'package:flutter_goldens/src/flutter_goldens_io.dart';
11+
import 'package:flutter_goldens/flutter_goldens.dart';
1212
import 'package:flutter_test/flutter_test.dart';
1313
import 'package:platform/platform.dart';
1414

dev/bots/analyze.dart

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,8 @@ Future<void> verifyNoSyncAsyncStar(String workingDirectory, {int minimumMatches
418418
}
419419
}
420420

421-
final RegExp _findGoldenTestPattern = RegExp(r'(matchesGoldenFile|expectFlakyGolden)\(');
422-
final RegExp _findGoldenDefinitionPattern = RegExp(r'(matchesGoldenFile|expectFlakyGolden)\(Object');
421+
final RegExp _findGoldenTestPattern = RegExp(r'matchesGoldenFile\(');
422+
final RegExp _findGoldenDefinitionPattern = RegExp(r'matchesGoldenFile\(Object');
423423
final RegExp _leadingComment = RegExp(r'//');
424424
final RegExp _goldenTagPattern1 = RegExp(r'@Tags\(');
425425
final RegExp _goldenTagPattern2 = RegExp(r"'reduced-test-set'");
@@ -431,17 +431,8 @@ const String _ignoreGoldenTag = '// flutter_ignore: golden_tag (see analyze.dart
431431
const String _ignoreGoldenTagForFile = '// flutter_ignore_for_file: golden_tag (see analyze.dart)';
432432

433433
Future<void> verifyGoldenTags(String workingDirectory, { int minimumMatches = 2000 }) async {
434-
// Skip flutter_goldens/lib because this library uses `matchesGoldenFile`
435-
// but is not itself a test that needs tags.
436-
final String flutterGoldensPackageLib = path.join(flutterPackages, 'flutter_goldens', 'lib');
437-
bool isWithinFlutterGoldenLib(File file) {
438-
return path.isWithin(flutterGoldensPackageLib, file.path);
439-
}
440-
441434
final List<String> errors = <String>[];
442-
final Stream<File> allTestFiles = _allFiles(workingDirectory, 'dart', minimumMatches: minimumMatches)
443-
.where((File file) => !isWithinFlutterGoldenLib(file));
444-
await for (final File file in allTestFiles) {
435+
await for (final File file in _allFiles(workingDirectory, 'dart', minimumMatches: minimumMatches)) {
445436
bool needsTag = false;
446437
bool hasTagNotation = false;
447438
bool hasReducedTag = false;

dev/bots/test/analyze-test-input/root/packages/foo/flaky_golden_ignore.dart

Lines changed: 0 additions & 16 deletions
This file was deleted.

dev/bots/test/analyze-test-input/root/packages/foo/flaky_golden_missing_tag.dart

Lines changed: 0 additions & 14 deletions
This file was deleted.

dev/bots/test/analyze-test-input/root/packages/foo/golden_class.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,3 @@
77
void matchesGoldenFile(Object key) {
88
return;
99
}
10-
11-
void expectFlakyGolden(Object key, String string){
12-
return;
13-
}

dev/bots/test/analyze-test-input/root/packages/foo/golden_doc.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,8 @@
3535
/// ```
3636
/// {@end-tool}
3737
///
38-
/// expectFlakyGolden(a, b)
3938
4039
// Other comments
4140
// matchesGoldenFile('comment.png');
42-
// expectFlakyGolden(a, b);
4341

4442
String literal = 'matchesGoldenFile()'; // flutter_ignore: golden_tag (see analyze.dart)
45-
String flakyLiteral = 'expectFlakyGolden';

dev/bots/test/analyze_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ void main() {
7979
'at the top of the file before import statements.';
8080
const String missingTag = "Files containing golden tests must be tagged with 'reduced-test-set'.";
8181
final List<String> lines = <String>[
82-
'║ test/analyze-test-input/root/packages/foo/flaky_golden_no_tag.dart: $noTag',
8382
'║ test/analyze-test-input/root/packages/foo/golden_missing_tag.dart: $missingTag',
84-
'║ test/analyze-test-input/root/packages/foo/flaky_golden_missing_tag.dart: $missingTag',
8583
'║ test/analyze-test-input/root/packages/foo/golden_no_tag.dart: $noTag',
8684
]
8785
.map((String line) => line.replaceAll('/', Platform.isWindows ? r'\' : '/'))

dev/devicelab/bin/tasks/technical_debt__cost.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ const double todoCost = 1009.0; // about two average SWE days, in dollars
1717
const double ignoreCost = 2003.0; // four average SWE days, in dollars
1818
const double pythonCost = 3001.0; // six average SWE days, in dollars
1919
const double skipCost = 2473.0; // 20 hours: 5 to fix the issue we're ignoring, 15 to fix the bugs we missed because the test was off
20-
const double flakyGoldenCost = 2467.0; // Similar to skip cost
2120
const double ignoreForFileCost = 2477.0; // similar thinking as skipCost
2221
const double asDynamicCost = 2011.0; // a few days to refactor the code.
2322
const double deprecationCost = 233.0; // a few hours to remove the old code.
@@ -70,9 +69,6 @@ Future<double> findCostsForFile(File file) async {
7069
if (isTest && line.contains('skip:') && !line.contains('[intended]')) {
7170
total += skipCost;
7271
}
73-
if (isTest && line.contains('expectFlakyGolden(')) {
74-
total += flakyGoldenCost;
75-
}
7672
if (isDart && isOptingOutOfNullSafety(line)) {
7773
total += fileNullSafetyMigrationCost;
7874
}

examples/api/test/flutter_test_config.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import 'dart:async';
66

77

8-
import 'package:flutter_goldens/flutter_goldens.dart' as flutter_goldens;
8+
import 'goldens_io.dart' if (dart.library.html) 'goldens_web.dart' as flutter_goldens;
99

1010
Future<void> testExecutable(FutureOr<void> Function() testMain) {
1111
// Enable golden file testing using Skia Gold.
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,4 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// The tag is missing. This should fail analysis.
6-
7-
import 'golden_class.dart';
8-
9-
void main() {
10-
expectFlakyGolden('key', 'missing_tag.png');
11-
}
5+
export 'package:flutter_goldens/flutter_goldens.dart' show testExecutable;

0 commit comments

Comments
 (0)