Revert "Allow Flutter golden file tests to be flaky (#114450)" (#114902)

This reverts commit 53e6876226.
This commit is contained in:
Zachary Anderson
2022-11-08 09:26:55 -08:00
committed by GitHub
parent a1432a9c5d
commit a84e369bd2
35 changed files with 1351 additions and 2093 deletions

View File

@@ -8,7 +8,7 @@ import 'dart:typed_data';
import 'package:file/file.dart';
import 'package:file/memory.dart';
import 'package:flutter_goldens/src/flutter_goldens_io.dart';
import 'package:flutter_goldens/flutter_goldens.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:platform/platform.dart';

View File

@@ -418,8 +418,8 @@ Future<void> verifyNoSyncAsyncStar(String workingDirectory, {int minimumMatches
}
}
final RegExp _findGoldenTestPattern = RegExp(r'(matchesGoldenFile|expectFlakyGolden)\(');
final RegExp _findGoldenDefinitionPattern = RegExp(r'(matchesGoldenFile|expectFlakyGolden)\(Object');
final RegExp _findGoldenTestPattern = RegExp(r'matchesGoldenFile\(');
final RegExp _findGoldenDefinitionPattern = RegExp(r'matchesGoldenFile\(Object');
final RegExp _leadingComment = RegExp(r'//');
final RegExp _goldenTagPattern1 = RegExp(r'@Tags\(');
final RegExp _goldenTagPattern2 = RegExp(r"'reduced-test-set'");
@@ -431,17 +431,8 @@ const String _ignoreGoldenTag = '// flutter_ignore: golden_tag (see analyze.dart
const String _ignoreGoldenTagForFile = '// flutter_ignore_for_file: golden_tag (see analyze.dart)';
Future<void> verifyGoldenTags(String workingDirectory, { int minimumMatches = 2000 }) async {
// Skip flutter_goldens/lib because this library uses `matchesGoldenFile`
// but is not itself a test that needs tags.
final String flutterGoldensPackageLib = path.join(flutterPackages, 'flutter_goldens', 'lib');
bool isWithinFlutterGoldenLib(File file) {
return path.isWithin(flutterGoldensPackageLib, file.path);
}
final List<String> errors = <String>[];
final Stream<File> allTestFiles = _allFiles(workingDirectory, 'dart', minimumMatches: minimumMatches)
.where((File file) => !isWithinFlutterGoldenLib(file));
await for (final File file in allTestFiles) {
await for (final File file in _allFiles(workingDirectory, 'dart', minimumMatches: minimumMatches)) {
bool needsTag = false;
bool hasTagNotation = false;
bool hasReducedTag = false;

View File

@@ -1,16 +0,0 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This would fail analysis, but it is ignored
// flutter_ignore_for_file: golden_tag (see analyze.dart)
@Tags(<String>['some-other-tag'])
import 'package:test/test.dart';
import 'golden_class.dart';
void main() {
expectFlakyGolden('key', 'String');
}

View File

@@ -1,14 +0,0 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// The reduced test set tag is missing. This should fail analysis.
@Tags(<String>['some-other-tag'])
import 'package:test/test.dart';
import 'golden_class.dart';
void main() {
expectFlakyGolden('finder', 'missing_tag.png');
}

View File

@@ -1,11 +0,0 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// The tag is missing. This should fail analysis.
import 'golden_class.dart';
void main() {
expectFlakyGolden('key', 'missing_tag.png');
}

View File

@@ -7,7 +7,3 @@
void matchesGoldenFile(Object key) {
return;
}
void expectFlakyGolden(Object key, String string){
return;
}

View File

@@ -35,11 +35,8 @@
/// ```
/// {@end-tool}
///
/// expectFlakyGolden(a, b)
// Other comments
// matchesGoldenFile('comment.png');
// expectFlakyGolden(a, b);
String literal = 'matchesGoldenFile()'; // flutter_ignore: golden_tag (see analyze.dart)
String flakyLiteral = 'expectFlakyGolden';

View File

@@ -79,9 +79,7 @@ void main() {
'at the top of the file before import statements.';
const String missingTag = "Files containing golden tests must be tagged with 'reduced-test-set'.";
final List<String> lines = <String>[
'║ test/analyze-test-input/root/packages/foo/flaky_golden_no_tag.dart: $noTag',
'║ test/analyze-test-input/root/packages/foo/golden_missing_tag.dart: $missingTag',
'║ test/analyze-test-input/root/packages/foo/flaky_golden_missing_tag.dart: $missingTag',
'║ test/analyze-test-input/root/packages/foo/golden_no_tag.dart: $noTag',
]
.map((String line) => line.replaceAll('/', Platform.isWindows ? r'\' : '/'))

View File

@@ -17,7 +17,6 @@ const double todoCost = 1009.0; // about two average SWE days, in dollars
const double ignoreCost = 2003.0; // four average SWE days, in dollars
const double pythonCost = 3001.0; // six average SWE days, in dollars
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
const double flakyGoldenCost = 2467.0; // Similar to skip cost
const double ignoreForFileCost = 2477.0; // similar thinking as skipCost
const double asDynamicCost = 2011.0; // a few days to refactor the code.
const double deprecationCost = 233.0; // a few hours to remove the old code.
@@ -70,9 +69,6 @@ Future<double> findCostsForFile(File file) async {
if (isTest && line.contains('skip:') && !line.contains('[intended]')) {
total += skipCost;
}
if (isTest && line.contains('expectFlakyGolden(')) {
total += flakyGoldenCost;
}
if (isDart && isOptingOutOfNullSafety(line)) {
total += fileNullSafetyMigrationCost;
}