Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove obsolete test structure handling
  • Loading branch information
stuartmorgan-g committed Jun 29, 2023
commit 3ee856c4377d0cfdec279c2883c7abf2ca9cda61
45 changes: 12 additions & 33 deletions script/tool/lib/src/drive_examples_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -170,34 +170,23 @@ class DriveExamplesCommand extends PackageLoopingCommand {
continue;
}

for (final File driver in drivers) {
final List<File> testTargets = <File>[];

// Try to find a matching app to drive without the _test.dart
// TODO(stuartmorgan): Migrate all remaining uses of this legacy
// approach (currently only video_player) and remove support for it:
// https://github.com/flutter/flutter/issues/85224.
final File? legacyTestFile = _getLegacyTestFileForTestDriver(driver);
if (legacyTestFile != null) {
testTargets.add(legacyTestFile);
} else {
for (final File testFile in await _getIntegrationTests(example)) {
// Check files for known problematic patterns.
final bool passesValidation = _validateIntegrationTest(testFile);
if (!passesValidation) {
// Report the issue, but continue with the test as the validation
// errors don't prevent running.
errors.add('${testFile.basename} failed validation');
}
testTargets.add(testFile);
}
}
final List<File> testTargets = await _getIntegrationTests(example);

// Check files for known problematic patterns.
testTargets
.where((File file) => !_validateIntegrationTest(file))
.forEach((File file) {
// Report the issue, but continue with the test as the validation
// errors don't prevent running.
errors.add('${file.basename} failed validation');
});

for (final File driver in drivers) {
if (testTargets.isEmpty) {
final String driverRelativePath =
getRelativePosixPath(driver, from: package.directory);
printError(
'Found $driverRelativePath, but no integration_test/*_test.dart files.');
'Found $driverRelativePath, but no integration_test/*.dart files.');
errors.add('No test files for $driverRelativePath');
continue;
}
Expand Down Expand Up @@ -293,16 +282,6 @@ class DriveExamplesCommand extends PackageLoopingCommand {
return drivers;
}

File? _getLegacyTestFileForTestDriver(File testDriver) {
final String testName = testDriver.basename.replaceAll(
RegExp(r'_test.dart$'),
'.dart',
);
final File testFile = testDriver.parent.childFile(testName);

return testFile.existsSync() ? testFile : null;
}

Future<List<File>> _getIntegrationTests(RepositoryPackage example) async {
final List<File> tests = <File>[];
final Directory integrationTestDir =
Expand Down