This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[flutter_plugin_tools] Make firebase-test-lab fail when no tests run #4172
Merged
stuartmorgan-g
merged 6 commits into
flutter:master
from
stuartmorgan-g:firebase-test-lab-fail-on-missing
Jul 21, 2021
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
99c97a8
[flutter_plugin_tools] Make firebase-test-lab fail when no tests run
stuartmorgan-g beed326
Fix, and test, the hang on second calls to _configureFirebaseProject
stuartmorgan-g 0a74919
Exclude everything that currently fails
stuartmorgan-g 4a01207
CHANGELOG update
stuartmorgan-g dc872d9
Add two more to the list
stuartmorgan-g 77ec6d4
Merge branch 'master' into firebase-test-lab-fail-on-missing
stuartmorgan-g File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,85 @@ void main() { | |
])); | ||
}); | ||
|
||
test('only runs gcloud configuration once', () async { | ||
createFakePlugin('plugin1', packagesDir, extraFiles: <String>[ | ||
'test/plugin_test.dart', | ||
'example/integration_test/foo_test.dart', | ||
'example/android/gradlew', | ||
'example/android/app/src/androidTest/MainActivityTest.java', | ||
]); | ||
createFakePlugin('plugin2', packagesDir, extraFiles: <String>[ | ||
'test/plugin_test.dart', | ||
'example/integration_test/bar_test.dart', | ||
'example/android/gradlew', | ||
'example/android/app/src/androidTest/MainActivityTest.java', | ||
]); | ||
|
||
final List<String> output = await runCapturingPrint(runner, <String>[ | ||
'firebase-test-lab', | ||
'--device', | ||
'model=flame,version=29', | ||
'--device', | ||
'model=seoul,version=26', | ||
'--test-run-id', | ||
'testRunId', | ||
'--build-id', | ||
'buildId', | ||
]); | ||
|
||
expect( | ||
output, | ||
containsAllInOrder(<Matcher>[ | ||
contains('Running for plugin1'), | ||
contains('Firebase project configured.'), | ||
contains('Testing example/integration_test/foo_test.dart...'), | ||
contains('Running for plugin2'), | ||
contains('Testing example/integration_test/bar_test.dart...'), | ||
]), | ||
); | ||
|
||
expect( | ||
processRunner.recordedCalls, | ||
orderedEquals(<ProcessCall>[ | ||
ProcessCall( | ||
'gcloud', | ||
'auth activate-service-account --key-file=${Platform.environment['HOME']}/gcloud-service-key.json' | ||
.split(' '), | ||
null), | ||
ProcessCall( | ||
'gcloud', 'config set project flutter-infra'.split(' '), null), | ||
ProcessCall( | ||
'/packages/plugin1/example/android/gradlew', | ||
'app:assembleAndroidTest -Pverbose=true'.split(' '), | ||
'/packages/plugin1/example/android'), | ||
ProcessCall( | ||
'/packages/plugin1/example/android/gradlew', | ||
'app:assembleDebug -Pverbose=true -Ptarget=/packages/plugin1/example/integration_test/foo_test.dart' | ||
.split(' '), | ||
'/packages/plugin1/example/android'), | ||
ProcessCall( | ||
'gcloud', | ||
'firebase test android run --type instrumentation --app build/app/outputs/apk/debug/app-debug.apk --test build/app/outputs/apk/androidTest/debug/app-debug-androidTest.apk --timeout 5m --results-bucket=gs://flutter_firebase_testlab --results-dir=plugins_android_test/plugin1/buildId/testRunId/0/ --device model=flame,version=29 --device model=seoul,version=26' | ||
.split(' '), | ||
'/packages/plugin1/example'), | ||
ProcessCall( | ||
'/packages/plugin2/example/android/gradlew', | ||
'app:assembleAndroidTest -Pverbose=true'.split(' '), | ||
'/packages/plugin2/example/android'), | ||
ProcessCall( | ||
'/packages/plugin2/example/android/gradlew', | ||
'app:assembleDebug -Pverbose=true -Ptarget=/packages/plugin2/example/integration_test/bar_test.dart' | ||
.split(' '), | ||
'/packages/plugin2/example/android'), | ||
ProcessCall( | ||
'gcloud', | ||
'firebase test android run --type instrumentation --app build/app/outputs/apk/debug/app-debug.apk --test build/app/outputs/apk/androidTest/debug/app-debug-androidTest.apk --timeout 5m --results-bucket=gs://flutter_firebase_testlab --results-dir=plugins_android_test/plugin2/buildId/testRunId/0/ --device model=flame,version=29 --device model=seoul,version=26' | ||
.split(' '), | ||
'/packages/plugin2/example'), | ||
]), | ||
); | ||
}); | ||
|
||
test('runs integration tests', () async { | ||
createFakePlugin('plugin', packagesDir, extraFiles: <String>[ | ||
'test/plugin_test.dart', | ||
|
@@ -203,12 +282,87 @@ void main() { | |
); | ||
}); | ||
|
||
test('skips packages with no androidTest directory', () async { | ||
test('fails for packages with no androidTest directory', () async { | ||
createFakePlugin('plugin', packagesDir, extraFiles: <String>[ | ||
'example/integration_test/foo_test.dart', | ||
'example/android/gradlew', | ||
]); | ||
|
||
Error? commandError; | ||
final List<String> output = await runCapturingPrint( | ||
runner, | ||
<String>[ | ||
'firebase-test-lab', | ||
'--device', | ||
'model=flame,version=29', | ||
'--device', | ||
'model=seoul,version=26', | ||
'--test-run-id', | ||
'testRunId', | ||
'--build-id', | ||
'buildId', | ||
], | ||
errorHandler: (Error e) { | ||
commandError = e; | ||
}, | ||
); | ||
|
||
expect(commandError, isA<ToolExit>()); | ||
expect( | ||
output, | ||
containsAllInOrder(<Matcher>[ | ||
contains('Running for plugin'), | ||
contains('No androidTest directory found.'), | ||
contains('The following packages had errors:'), | ||
contains('plugin:\n' | ||
' No tests ran (use --exclude if this is intentional).'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: does it make sense to say where There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It can be useful locally as well; in any scenario where someone sees this message, they are trying to run a failing package, so might want to exclude it. |
||
]), | ||
); | ||
}); | ||
|
||
test('fails for packages with no integration test files', () async { | ||
createFakePlugin('plugin', packagesDir, extraFiles: <String>[ | ||
'example/android/gradlew', | ||
'example/android/app/src/androidTest/MainActivityTest.java', | ||
]); | ||
|
||
Error? commandError; | ||
final List<String> output = await runCapturingPrint( | ||
runner, | ||
<String>[ | ||
'firebase-test-lab', | ||
'--device', | ||
'model=flame,version=29', | ||
'--device', | ||
'model=seoul,version=26', | ||
'--test-run-id', | ||
'testRunId', | ||
'--build-id', | ||
'buildId', | ||
], | ||
errorHandler: (Error e) { | ||
commandError = e; | ||
}, | ||
); | ||
|
||
expect(commandError, isA<ToolExit>()); | ||
expect( | ||
output, | ||
containsAllInOrder(<Matcher>[ | ||
contains('Running for plugin'), | ||
contains('No integration tests were run'), | ||
contains('The following packages had errors:'), | ||
contains('plugin:\n' | ||
' No tests ran (use --exclude if this is intentional).'), | ||
]), | ||
); | ||
}); | ||
|
||
test('skips packages with no android directory', () async { | ||
createFakePackage('package', packagesDir, extraFiles: <String>[ | ||
'example/integration_test/foo_test.dart', | ||
]); | ||
|
||
final List<String> output = await runCapturingPrint(runner, <String>[ | ||
'firebase-test-lab', | ||
'--device', | ||
|
@@ -224,8 +378,8 @@ void main() { | |
expect( | ||
output, | ||
containsAllInOrder(<Matcher>[ | ||
contains('Running for plugin'), | ||
contains('No example with androidTest directory'), | ||
contains('Running for package'), | ||
contains('package/example does not support Android'), | ||
]), | ||
); | ||
expect(output, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the actual fix for the bug, but the
Completer
was needlessly complex so I cleaned it up as well.