mirror of
https://github.com/flutter/packages.git
synced 2025-06-09 14:19:08 +08:00
[flutter_plugin_tools] Make firebase-test-lab fail when no tests run (#4172)
If a package supports Android, it will now report failure instead of skip if no tests run. This matches the new behavior of drive-examples, and is intended to prevent recurrance of situations where we are silently failing to run tests because of, e.g., tests being in the wrong directory. Also fixes a long-standing but unnoticed problem where if a run tried to run more than one package's tests, it would hang forever (although on the bots it doesn't seem to time out, just end logs abruptly) due to a logic error in the call to configure gcloud. Fixes flutter/flutter#86732
This commit is contained in:
@ -76,13 +76,12 @@ class FirebaseTestLabCommand extends PackageLoopingCommand {
|
||||
|
||||
static const String _gradleWrapper = 'gradlew';
|
||||
|
||||
Completer<void>? _firebaseProjectConfigured;
|
||||
bool _firebaseProjectConfigured = false;
|
||||
|
||||
Future<void> _configureFirebaseProject() async {
|
||||
if (_firebaseProjectConfigured != null) {
|
||||
return _firebaseProjectConfigured!.future;
|
||||
if (_firebaseProjectConfigured) {
|
||||
return;
|
||||
}
|
||||
_firebaseProjectConfigured = Completer<void>();
|
||||
|
||||
final String serviceKey = getStringArg('service-key');
|
||||
if (serviceKey.isEmpty) {
|
||||
@ -110,31 +109,34 @@ class FirebaseTestLabCommand extends PackageLoopingCommand {
|
||||
print('');
|
||||
if (exitCode == 0) {
|
||||
print('Firebase project configured.');
|
||||
return;
|
||||
} else {
|
||||
logWarning(
|
||||
'Warning: gcloud config set returned a non-zero exit code. Continuing anyway.');
|
||||
}
|
||||
}
|
||||
_firebaseProjectConfigured!.complete(null);
|
||||
_firebaseProjectConfigured = true;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<PackageResult> runForPackage(Directory package) async {
|
||||
if (!package
|
||||
.childDirectory('example')
|
||||
.childDirectory('android')
|
||||
final Directory exampleDirectory = package.childDirectory('example');
|
||||
final Directory androidDirectory =
|
||||
exampleDirectory.childDirectory('android');
|
||||
if (!androidDirectory.existsSync()) {
|
||||
return PackageResult.skip(
|
||||
'${getPackageDescription(exampleDirectory)} does not support Android.');
|
||||
}
|
||||
|
||||
if (!androidDirectory
|
||||
.childDirectory('app')
|
||||
.childDirectory('src')
|
||||
.childDirectory('androidTest')
|
||||
.existsSync()) {
|
||||
return PackageResult.skip('No example with androidTest directory');
|
||||
printError('No androidTest directory found.');
|
||||
return PackageResult.fail(
|
||||
<String>['No tests ran (use --exclude if this is intentional).']);
|
||||
}
|
||||
|
||||
final Directory exampleDirectory = package.childDirectory('example');
|
||||
final Directory androidDirectory =
|
||||
exampleDirectory.childDirectory('android');
|
||||
|
||||
// Ensures that gradle wrapper exists
|
||||
if (!await _ensureGradleWrapperExists(androidDirectory)) {
|
||||
return PackageResult.fail(<String>['Unable to build example apk']);
|
||||
@ -191,6 +193,12 @@ class FirebaseTestLabCommand extends PackageLoopingCommand {
|
||||
errors.add('$testName failed tests');
|
||||
}
|
||||
}
|
||||
|
||||
if (errors.isEmpty && resultsCounter == 0) {
|
||||
printError('No integration tests were run.');
|
||||
errors.add('No tests ran (use --exclude if this is intentional).');
|
||||
}
|
||||
|
||||
return errors.isEmpty
|
||||
? PackageResult.success()
|
||||
: PackageResult.fail(errors);
|
||||
|
Reference in New Issue
Block a user