Reverts "Add test for dynamic_content_color.0.dart (#158309)" (#158511)

Reverts: flutter/flutter#158309
Initiated by: bleroux
Reason for reverting: added test is failing on CI

Original PR Author: ValentinVignal

Reviewed By: {bleroux}

This change reverts the following previous change:
Fixes https://github.com/flutter/flutter/issues/130459

It adds a test for
- `examples/api/lib/material/color_scheme/dynamic_content_color.0.dart`
This commit is contained in:
auto-submit[bot]
2024-11-12 16:05:17 +00:00
committed by GitHub
parent 95a9b97f88
commit 423aa2ac74
3 changed files with 51 additions and 182 deletions

View File

@@ -142,18 +142,29 @@ class SampleChecker {
// Get a list of the filenames that were not found in the source files.
final List<String> missingFilenames = checkForMissingLinks(exampleFilenames, exampleLinks);
// Get a list of any tests that are missing.
final List<File> missingTests = checkForMissingTests(exampleFilenames);
// Get a list of any tests that are missing, as well as any that used to be
// missing, but have been implemented.
final (List<File> missingTests, List<File> noLongerMissing) = checkForMissingTests(exampleFilenames);
// Remove any that we know are exceptions (examples that aren't expected to be
// linked into any source files). These are typically template files used to
// generate new examples.
missingFilenames.removeWhere((String file) => _knownUnlinkedExamples.contains(file));
if (missingFilenames.isEmpty && missingTests.isEmpty && malformedLinks.isEmpty) {
if (missingFilenames.isEmpty && missingTests.isEmpty && noLongerMissing.isEmpty && malformedLinks.isEmpty) {
return true;
}
if (noLongerMissing.isNotEmpty) {
final StringBuffer buffer = StringBuffer('The following tests have been implemented! Huzzah!:\n');
for (final File name in noLongerMissing) {
buffer.writeln(' ${getRelativePath(name)}');
}
buffer.writeln('However, they now need to be removed from the _knownMissingTests');
buffer.write('list in the script $_scriptLocation.');
foundError(buffer.toString().split('\n'));
}
if (missingTests.isNotEmpty) {
final StringBuffer buffer = StringBuffer('The following example test files are missing:\n');
for (final File name in missingTests) {
@@ -268,14 +279,35 @@ class SampleChecker {
return '${path.join(testPath, path.basenameWithoutExtension(example.path))}_test.dart';
}
List<File> checkForMissingTests(List<File> exampleFilenames) {
(List<File>, List<File>) checkForMissingTests(List<File> exampleFilenames) {
final List<File> missingTests = <File>[];
final List<File> noLongerMissingTests = <File>[];
for (final File example in exampleFilenames) {
final File testFile = filesystem.file(getTestNameForExample(example, examples));
final String name = path.relative(testFile.absolute.path, from: flutterRoot.absolute.path);
if (!testFile.existsSync()) {
missingTests.add(testFile);
} else if (_knownMissingTests.contains(name.replaceAll(r'\', '/'))) {
noLongerMissingTests.add(testFile);
}
}
return missingTests;
// Skip any that we know are missing.
missingTests.removeWhere(
(File test) {
final String name = path.relative(test.absolute.path, from: flutterRoot.absolute.path).replaceAll(r'\', '/');
return _knownMissingTests.contains(name);
},
);
return (missingTests, noLongerMissingTests);
}
}
// These tests are known to be missing. They should all eventually be
// implemented, but until they are we allow them, so that we can catch any new
// examples that are added without tests.
//
// TODO(gspencergoog): implement the missing tests.
// See https://github.com/flutter/flutter/issues/130459
final Set<String> _knownMissingTests = <String>{
'examples/api/test/material/color_scheme/dynamic_content_color.0_test.dart',
};