Unverified Commit 80278423 authored by keyonghan's avatar keyonghan Committed by GitHub

Copy artifacts to `applicationBinaryPath` when specified for build+test separation (#109879)

parent 6d655510
...@@ -59,6 +59,7 @@ abstract class BuildTestTask { ...@@ -59,6 +59,7 @@ abstract class BuildTestTask {
} }
section('BUILDING APPLICATION'); section('BUILDING APPLICATION');
await flutter('build', options: getBuildArgs(deviceOperatingSystem)); await flutter('build', options: getBuildArgs(deviceOperatingSystem));
copyArtifacts();
}); });
} }
...@@ -83,6 +84,11 @@ abstract class BuildTestTask { ...@@ -83,6 +84,11 @@ abstract class BuildTestTask {
/// Args passed to flutter drive to test the built application. /// Args passed to flutter drive to test the built application.
List<String> getTestArgs(DeviceOperatingSystem deviceOperatingSystem, String deviceId) => throw UnimplementedError('getTestArgs is not implemented'); 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. /// Logic to construct [TaskResult] from this test's results.
Future<TaskResult> parseTaskResult() => throw UnimplementedError('parseTaskResult is not implemented'); Future<TaskResult> parseTaskResult() => throw UnimplementedError('parseTaskResult is not implemented');
...@@ -100,10 +106,6 @@ abstract class BuildTestTask { ...@@ -100,10 +106,6 @@ abstract class BuildTestTask {
throw Exception('Both build and test should not be passed. Pass only one.'); 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) { if (!testOnly) {
await build(); await build();
} }
......
...@@ -212,6 +212,16 @@ class GalleryTransitionBuildTest extends BuildTestTask { ...@@ -212,6 +212,16 @@ class GalleryTransitionBuildTest extends BuildTestTask {
final String testOutputDirectory = Platform.environment['FLUTTER_TEST_OUTPUTS_DIR'] ?? '${galleryDirectory.path}/build'; 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 @override
List<String> getBuildArgs(DeviceOperatingSystem deviceOperatingSystem) { List<String> getBuildArgs(DeviceOperatingSystem deviceOperatingSystem) {
return <String>[ return <String>[
...@@ -310,7 +320,7 @@ class GalleryTransitionBuildTest extends BuildTestTask { ...@@ -310,7 +320,7 @@ class GalleryTransitionBuildTest extends BuildTestTask {
@override @override
String getApplicationBinaryPath() { String getApplicationBinaryPath() {
if (applicationBinaryPath != null) { if (applicationBinaryPath != null) {
return applicationBinaryPath!; return '${applicationBinaryPath!}/app-profile.apk';
} }
return 'build/app/outputs/flutter-apk/app-profile.apk'; return 'build/app/outputs/flutter-apk/app-profile.apk';
......
...@@ -78,13 +78,13 @@ void main() { ...@@ -78,13 +78,13 @@ void main() {
expect(result.message, 'Task failed: Exception: Both build and test should not be passed. Pass only one.'); 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( final TaskResult result = await runTask(
'smoke_test_build_test', 'smoke_test_build_test',
taskArgs: <String>['--build', '--application-binary-path=test.apk'], taskArgs: <String>['--build', '--application-binary-path=test'],
deviceId: 'FAKE_SUCCESS', deviceId: 'FAKE_SUCCESS',
isolateParams: isolateParams, isolateParams: isolateParams,
); );
expect(result.message, 'Task failed: Exception: Application binary path is only used for tests'); expect(result.message, 'No tests run');
}); });
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment