diff --git a/dev/devicelab/lib/tasks/build_test_task.dart b/dev/devicelab/lib/tasks/build_test_task.dart index 14840078c2..2405763fd1 100644 --- a/dev/devicelab/lib/tasks/build_test_task.dart +++ b/dev/devicelab/lib/tasks/build_test_task.dart @@ -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 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 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(); } diff --git a/dev/devicelab/lib/tasks/gallery.dart b/dev/devicelab/lib/tasks/gallery.dart index 4c24622cbb..4ded70b98b 100644 --- a/dev/devicelab/lib/tasks/gallery.dart +++ b/dev/devicelab/lib/tasks/gallery.dart @@ -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 getBuildArgs(DeviceOperatingSystem deviceOperatingSystem) { return [ @@ -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'; diff --git a/dev/devicelab/test/tasks/build_test_task_test.dart b/dev/devicelab/test/tasks/build_test_task_test.dart index 70bb86b5b6..251fc70073 100644 --- a/dev/devicelab/test/tasks/build_test_task_test.dart +++ b/dev/devicelab/test/tasks/build_test_task_test.dart @@ -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: ['--build', '--application-binary-path=test.apk'], + taskArgs: ['--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'); }); }