Copy artifacts to applicationBinaryPath
when specified for build+test separation (#109879)
This commit is contained in:
parent
6d65551060
commit
8027842393
@ -59,6 +59,7 @@ abstract class BuildTestTask {
|
||||
}
|
||||
section('BUILDING APPLICATION');
|
||||
await flutter('build', options: getBuildArgs(deviceOperatingSystem));
|
||||
copyArtifacts();
|
||||
});
|
||||
|
||||
}
|
||||
@ -83,6 +84,11 @@ abstract class BuildTestTask {
|
||||
/// Args passed to flutter drive to test the built application.
|
||||
List<String> getTestArgs(DeviceOperatingSystem deviceOperatingSystem, String deviceId) => throw UnimplementedError('getTestArgs is not implemented');
|
||||
|
||||
/// Copy artifacts to [applicationBinaryPath] if specified.
|
||||
///
|
||||
/// This is needed when running from CI, so that LUCI recipes know where to locate and upload artifacts to GCS.
|
||||
void copyArtifacts() => throw UnimplementedError('copyArtifacts is not implemented');
|
||||
|
||||
/// Logic to construct [TaskResult] from this test's results.
|
||||
Future<TaskResult> parseTaskResult() => throw UnimplementedError('parseTaskResult is not implemented');
|
||||
|
||||
@ -100,10 +106,6 @@ abstract class BuildTestTask {
|
||||
throw Exception('Both build and test should not be passed. Pass only one.');
|
||||
}
|
||||
|
||||
if (buildOnly && applicationBinaryPath != null) {
|
||||
throw Exception('Application binary path is only used for tests');
|
||||
}
|
||||
|
||||
if (!testOnly) {
|
||||
await build();
|
||||
}
|
||||
|
@ -212,6 +212,16 @@ class GalleryTransitionBuildTest extends BuildTestTask {
|
||||
|
||||
final String testOutputDirectory = Platform.environment['FLUTTER_TEST_OUTPUTS_DIR'] ?? '${galleryDirectory.path}/build';
|
||||
|
||||
@override
|
||||
void copyArtifacts() {
|
||||
if(applicationBinaryPath != null) {
|
||||
copy(
|
||||
file('${galleryDirectory.path}/build/app/outputs/flutter-apk/app-profile.apk'),
|
||||
Directory(applicationBinaryPath!),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
List<String> getBuildArgs(DeviceOperatingSystem deviceOperatingSystem) {
|
||||
return <String>[
|
||||
@ -310,7 +320,7 @@ class GalleryTransitionBuildTest extends BuildTestTask {
|
||||
@override
|
||||
String getApplicationBinaryPath() {
|
||||
if (applicationBinaryPath != null) {
|
||||
return applicationBinaryPath!;
|
||||
return '${applicationBinaryPath!}/app-profile.apk';
|
||||
}
|
||||
|
||||
return 'build/app/outputs/flutter-apk/app-profile.apk';
|
||||
|
@ -78,13 +78,13 @@ void main() {
|
||||
expect(result.message, 'Task failed: Exception: Both build and test should not be passed. Pass only one.');
|
||||
});
|
||||
|
||||
test('throws exception when build and application binary arg are given', () async {
|
||||
test('copies artifacts when build and application binary arg are given', () async {
|
||||
final TaskResult result = await runTask(
|
||||
'smoke_test_build_test',
|
||||
taskArgs: <String>['--build', '--application-binary-path=test.apk'],
|
||||
taskArgs: <String>['--build', '--application-binary-path=test'],
|
||||
deviceId: 'FAKE_SUCCESS',
|
||||
isolateParams: isolateParams,
|
||||
);
|
||||
expect(result.message, 'Task failed: Exception: Application binary path is only used for tests');
|
||||
expect(result.message, 'No tests run');
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user