diff --git a/packages/artifact_proxy/pubspec.lock b/packages/artifact_proxy/pubspec.lock index efcae040a..0e883c387 100644 --- a/packages/artifact_proxy/pubspec.lock +++ b/packages/artifact_proxy/pubspec.lock @@ -578,4 +578,4 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.4.0 <4.0.0" + dart: ">=3.4.0-256.0.dev <4.0.0" diff --git a/packages/discord_gcp_alerts/pubspec.lock b/packages/discord_gcp_alerts/pubspec.lock index a5a5daa19..679da24b9 100644 --- a/packages/discord_gcp_alerts/pubspec.lock +++ b/packages/discord_gcp_alerts/pubspec.lock @@ -570,4 +570,4 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.4.0 <4.0.0" + dart: ">=3.4.0-256.0.dev <4.0.0" diff --git a/packages/shorebird_cli/bin/shorebird.dart b/packages/shorebird_cli/bin/shorebird.dart index c7c29d465..01870ebbc 100644 --- a/packages/shorebird_cli/bin/shorebird.dart +++ b/packages/shorebird_cli/bin/shorebird.dart @@ -66,7 +66,6 @@ Future main(List args) async { shorebirdToolsRef, shorebirdValidatorRef, shorebirdVersionRef, - updaterToolsRef, xcodeBuildRef, }, ), diff --git a/packages/shorebird_cli/lib/src/artifact_manager.dart b/packages/shorebird_cli/lib/src/artifact_manager.dart index 40f9f15dd..55b17b151 100644 --- a/packages/shorebird_cli/lib/src/artifact_manager.dart +++ b/packages/shorebird_cli/lib/src/artifact_manager.dart @@ -21,41 +21,33 @@ class ArtifactManager { /// Generates a binary diff between two files and returns the path to the /// output diff file. Future createDiff({ - required File releaseArtifact, - required File patchArtifact, + required String releaseArtifactPath, + required String patchArtifactPath, }) async { - if (!releaseArtifact.existsSync()) { + if (!File(releaseArtifactPath).existsSync()) { throw FileSystemException( 'Release artifact does not exist', - releaseArtifact.path, + releaseArtifactPath, ); } - if (!patchArtifact.existsSync()) { + if (!File(patchArtifactPath).existsSync()) { throw FileSystemException( 'Patch artifact does not exist', - patchArtifact.path, + patchArtifactPath, ); } final tempDir = await Directory.systemTemp.createTemp(); - final outputFile = File(p.join(tempDir.path, 'diff.patch')); - final updaterToolsFile = File(updaterTools.path); - if (updaterToolsFile.existsSync()) { - await updaterTools.createDiff( - releaseArtifact: releaseArtifact, - patchArtifact: patchArtifact, - outputFile: outputFile, - ); - } else { - await patchExecutable.run( - releaseArtifactPath: releaseArtifact.path, - patchArtifactPath: patchArtifact.path, - diffPath: outputFile.path, - ); - } + final diffPath = p.join(tempDir.path, 'diff.patch'); + + await patchExecutable.run( + releaseArtifactPath: releaseArtifactPath, + patchArtifactPath: patchArtifactPath, + diffPath: diffPath, + ); - return outputFile.path; + return diffPath; } /// Downloads the file at the given [uri] to a temporary directory and returns diff --git a/packages/shorebird_cli/lib/src/cache.dart b/packages/shorebird_cli/lib/src/cache.dart index 3ec94bba0..6cc63e657 100644 --- a/packages/shorebird_cli/lib/src/cache.dart +++ b/packages/shorebird_cli/lib/src/cache.dart @@ -47,7 +47,6 @@ class Cache { registerArtifact(BundleToolArtifact(cache: this, platform: platform)); registerArtifact(AotToolsDillArtifact(cache: this, platform: platform)); registerArtifact(AotToolsExeArtifact(cache: this, platform: platform)); - registerArtifact(UpdaterToolsArtifact(cache: this, platform: platform)); } void registerArtifact(CachedArtifact artifact) => _artifacts.add(artifact); @@ -298,34 +297,3 @@ class BundleToolArtifact extends CachedArtifact { return 'https://github.com/google/bundletool/releases/download/1.15.6/bundletool-all-1.15.6.jar'; } } - -/// {@template updater_tools_artifact} -/// Tools used to package patch artifacts for use by the Updater. -/// {@endtemplate} -class UpdaterToolsArtifact extends CachedArtifact { - /// {@macro updater_tools_artifact} - UpdaterToolsArtifact({required super.cache, required super.platform}); - - @override - String get name => 'updater-tools.dill'; - - @override - bool get isExecutable => false; - - /// Updater tools was introduced in release 1.1.7. - // TODO(bryanoltman): add engine rev and flutter version once this is nailed down - @override - bool get required => false; - - @override - Directory get location => Directory( - p.join( - cache.getArtifactDirectory(name).path, - shorebirdEnv.shorebirdEngineRevision, - ), - ); - - @override - String get storageUrl => - '${cache.storageBaseUrl}/${cache.storageBucket}/shorebird/${shorebirdEnv.shorebirdEngineRevision}/$name'; -} diff --git a/packages/shorebird_cli/lib/src/commands/patch/aar_patcher.dart b/packages/shorebird_cli/lib/src/commands/patch/aar_patcher.dart index dbb32b016..40cf58ce7 100644 --- a/packages/shorebird_cli/lib/src/commands/patch/aar_patcher.dart +++ b/packages/shorebird_cli/lib/src/commands/patch/aar_patcher.dart @@ -141,8 +141,8 @@ class AarPatcher extends Patcher { final hash = sha256.convert(await patchArtifact.readAsBytes()).toString(); try { final diffPath = await artifactManager.createDiff( - releaseArtifact: File(releaseArtifactPath.value), - patchArtifact: patchArtifact, + releaseArtifactPath: releaseArtifactPath.value, + patchArtifactPath: artifactPath, ); patchArtifactBundles[arch] = PatchArtifactBundle( arch: arch.arch, diff --git a/packages/shorebird_cli/lib/src/commands/patch/android_patcher.dart b/packages/shorebird_cli/lib/src/commands/patch/android_patcher.dart index e67d669f7..634e779d3 100644 --- a/packages/shorebird_cli/lib/src/commands/patch/android_patcher.dart +++ b/packages/shorebird_cli/lib/src/commands/patch/android_patcher.dart @@ -150,8 +150,8 @@ Looked in: final hash = sha256.convert(await patchArtifact.readAsBytes()).toString(); try { final diffPath = await artifactManager.createDiff( - releaseArtifact: File(releaseArtifactPath.value), - patchArtifact: patchArtifact, + releaseArtifactPath: releaseArtifactPath.value, + patchArtifactPath: patchArtifactPath, ); patchArtifactBundles[releaseArtifactPath.key] = PatchArtifactBundle( arch: arch.arch, diff --git a/packages/shorebird_cli/lib/src/commands/patch/ios_framework_patcher.dart b/packages/shorebird_cli/lib/src/commands/patch/ios_framework_patcher.dart index 15a93db30..be0117ad3 100644 --- a/packages/shorebird_cli/lib/src/commands/patch/ios_framework_patcher.dart +++ b/packages/shorebird_cli/lib/src/commands/patch/ios_framework_patcher.dart @@ -180,8 +180,8 @@ class IosFrameworkPatcher extends Patcher { patchFile = File( await artifactManager.createDiff( - releaseArtifact: patchBaseFile, - patchArtifact: patchBuildFile, + releaseArtifactPath: patchBaseFile.path, + patchArtifactPath: patchBuildFile.path, ), ); } else { diff --git a/packages/shorebird_cli/lib/src/commands/patch/ios_patcher.dart b/packages/shorebird_cli/lib/src/commands/patch/ios_patcher.dart index bfe7312dd..d8bcb1eb0 100644 --- a/packages/shorebird_cli/lib/src/commands/patch/ios_patcher.dart +++ b/packages/shorebird_cli/lib/src/commands/patch/ios_patcher.dart @@ -201,8 +201,8 @@ class IosPatcher extends Patcher { patchFile = File( await artifactManager.createDiff( - releaseArtifact: patchBaseFile, - patchArtifact: patchBuildFile, + releaseArtifactPath: patchBaseFile.path, + patchArtifactPath: patchBuildFile.path, ), ); } else { diff --git a/packages/shorebird_cli/lib/src/executables/aot_tools.dart b/packages/shorebird_cli/lib/src/executables/aot_tools.dart index c9f0aa4b1..a30415057 100644 --- a/packages/shorebird_cli/lib/src/executables/aot_tools.dart +++ b/packages/shorebird_cli/lib/src/executables/aot_tools.dart @@ -169,7 +169,7 @@ class AotTools { workingDirectory: workingDirectory, ); - if (result.exitCode != ExitCode.success.code) { + if (result.exitCode != 0) { throw Exception('Failed to link: ${result.stderr}'); } diff --git a/packages/shorebird_cli/lib/src/executables/executables.dart b/packages/shorebird_cli/lib/src/executables/executables.dart index 733eb84ae..6f2a65a37 100644 --- a/packages/shorebird_cli/lib/src/executables/executables.dart +++ b/packages/shorebird_cli/lib/src/executables/executables.dart @@ -9,5 +9,4 @@ export 'ios_deploy.dart'; export 'java.dart'; export 'patch_executable.dart'; export 'shorebird_tools.dart'; -export 'updater_tools.dart'; export 'xcodebuild.dart'; diff --git a/packages/shorebird_cli/lib/src/executables/patch_executable.dart b/packages/shorebird_cli/lib/src/executables/patch_executable.dart index 4c414f0fc..763c9b881 100644 --- a/packages/shorebird_cli/lib/src/executables/patch_executable.dart +++ b/packages/shorebird_cli/lib/src/executables/patch_executable.dart @@ -29,24 +29,22 @@ class PatchFailedException implements Exception { /// /// Throws [PatchFailedException] if the patch command exits with non-zero code. class PatchExecutable { - /// The path to the `patch` executable. - String get path => p.join( - cache.getArtifactDirectory('patch').path, - 'patch', - ); - Future run({ required String releaseArtifactPath, required String patchArtifactPath, required String diffPath, }) async { + final diffExecutable = p.join( + cache.getArtifactDirectory('patch').path, + 'patch', + ); final diffArguments = [ releaseArtifactPath, patchArtifactPath, diffPath, ]; - final result = await process.run(path, diffArguments); + final result = await process.run(diffExecutable, diffArguments); if (result.exitCode != ExitCode.success.code) { throw PatchFailedException( diff --git a/packages/shorebird_cli/lib/src/executables/updater_tools.dart b/packages/shorebird_cli/lib/src/executables/updater_tools.dart deleted file mode 100644 index 1bfa299bd..000000000 --- a/packages/shorebird_cli/lib/src/executables/updater_tools.dart +++ /dev/null @@ -1,65 +0,0 @@ -import 'package:mason_logger/mason_logger.dart'; -import 'package:scoped_deps/scoped_deps.dart'; -import 'package:shorebird_cli/src/executables/patch_executable.dart'; -import 'package:shorebird_cli/src/shorebird_artifacts.dart'; -import 'package:shorebird_cli/src/shorebird_env.dart'; -import 'package:shorebird_cli/src/shorebird_process.dart'; -import 'package:shorebird_cli/src/third_party/flutter_tools/lib/flutter_tools.dart'; - -/// A reference to a [UpdaterTools] instance. -final updaterToolsRef = create(UpdaterTools.new); - -/// The [UpdaterTools] instance available in the current zone. -UpdaterTools get updaterTools => read(updaterToolsRef); - -class UpdaterTools { - /// Path to the updater tools .dill file. - String get path => shorebirdArtifacts.getArtifactPath( - artifact: ShorebirdArtifact.updaterTools, - ); - - Future _exec( - List command, { - String? workingDirectory, - }) async { - // local engine versions use .dart and we distribute aot-tools as a .dill - return process.run( - shorebirdEnv.dartBinaryFile.path, - ['run', path, ...command], - workingDirectory: workingDirectory, - ); - } - - /// Create a binary diff between a release artifact and a patch artifact. - Future createDiff({ - required File releaseArtifact, - required File patchArtifact, - required File outputFile, - }) async { - if (!releaseArtifact.existsSync()) { - throw FileSystemException( - 'Release artifact does not exist', - releaseArtifact.path, - ); - } - - if (!patchArtifact.existsSync()) { - throw FileSystemException( - 'Patch artifact does not exist', - patchArtifact.path, - ); - } - - final result = await _exec([ - 'diff', - '--release=${releaseArtifact.path}', - '--patch=${patchArtifact.path}', - '--patch-executable=${patchExecutable.path}', - '--output=${outputFile.path}', - ]); - - if (result.exitCode != ExitCode.success.code) { - throw Exception('Failed to create diff: ${result.stderr}'); - } - } -} diff --git a/packages/shorebird_cli/lib/src/shorebird_artifacts.dart b/packages/shorebird_cli/lib/src/shorebird_artifacts.dart index 26bd136ce..220fa9e0e 100644 --- a/packages/shorebird_cli/lib/src/shorebird_artifacts.dart +++ b/packages/shorebird_cli/lib/src/shorebird_artifacts.dart @@ -18,9 +18,6 @@ enum ShorebirdArtifact { /// The gen_snapshot executable. genSnapshot, - - /// The updater_tools kernel file. - updaterTools, } /// A reference to a [ShorebirdArtifacts] instance. @@ -57,8 +54,6 @@ class ShorebirdCachedArtifacts implements ShorebirdArtifacts { return _aotToolsFile.path; case ShorebirdArtifact.genSnapshot: return _genSnapshotFile.path; - case ShorebirdArtifact.updaterTools: - return _updaterToolsFile.path; } } @@ -113,16 +108,6 @@ class ShorebirdCachedArtifacts implements ShorebirdArtifacts { ), ); } - - File get _updaterToolsFile { - return File( - p.join( - cache.getArtifactDirectory('updater-tools').path, - shorebirdEnv.shorebirdEngineRevision, - 'updater-tools.dill', - ), - ); - } } /// {@template shorebird_local_engine_artifacts} @@ -141,8 +126,6 @@ class ShorebirdLocalEngineArtifacts implements ShorebirdArtifacts { return _aotToolsFile.path; case ShorebirdArtifact.genSnapshot: return _genSnapshotFile.path; - case ShorebirdArtifact.updaterTools: - return _updaterToolsFile.path; } } @@ -183,17 +166,4 @@ class ShorebirdLocalEngineArtifacts implements ShorebirdArtifacts { ), ); } - - File get _updaterToolsFile { - return File( - p.join( - engineConfig.localEngineSrcPath!, - 'third_party', - 'updater', - 'updater_tools', - 'bin', - 'updater_tools.dart', - ), - ); - } } diff --git a/packages/shorebird_cli/pubspec.lock b/packages/shorebird_cli/pubspec.lock index 8709f29b0..d44624890 100644 --- a/packages/shorebird_cli/pubspec.lock +++ b/packages/shorebird_cli/pubspec.lock @@ -561,10 +561,10 @@ packages: dependency: "direct main" description: name: scoped_deps - sha256: bc54cece4fed785157dc53b7554d31107f574897f4b2d1196db905a38c084e31 + sha256: "7416a9026f3b457dda634a8e83c8e47d7ece33bef360ffba114c2d89255166ae" url: "https://pub.dev" source: hosted - version: "0.1.0+2" + version: "0.1.0+1" shelf: dependency: transitive description: diff --git a/packages/shorebird_cli/test/src/artifact_manager_test.dart b/packages/shorebird_cli/test/src/artifact_manager_test.dart index 3377b2b16..059e2a80e 100644 --- a/packages/shorebird_cli/test/src/artifact_manager_test.dart +++ b/packages/shorebird_cli/test/src/artifact_manager_test.dart @@ -18,6 +18,7 @@ import 'mocks.dart'; void main() { group(ArtifactManager, () { + late ArtifactManager artifactManager; late Cache cache; late Directory cacheArtifactDirectory; late http.Client httpClient; @@ -26,8 +27,6 @@ void main() { late ShorebirdLogger logger; late ShorebirdEnv shorebirdEnv; late ShorebirdProcess shorebirdProcess; - late UpdaterTools updaterTools; - late ArtifactManager artifactManager; R runWithOverrides(R Function() body) { return runScoped( @@ -39,13 +38,11 @@ void main() { patchExecutableRef.overrideWith(() => patchExecutable), processRef.overrideWith(() => shorebirdProcess), shorebirdEnvRef.overrideWith(() => shorebirdEnv), - updaterToolsRef.overrideWith(() => updaterTools), }, ); } setUpAll(() { - registerFallbackValue(File('')); registerFallbackValue(FakeBaseRequest()); }); @@ -54,11 +51,9 @@ void main() { cache = MockCache(); httpClient = MockHttpClient(); logger = MockShorebirdLogger(); - patchExecutable = MockPatchExecutable(); projectRoot = Directory.systemTemp.createTempSync(); shorebirdProcess = MockShorebirdProcess(); shorebirdEnv = MockShorebirdEnv(); - updaterTools = MockUpdaterTools(); when(() => cache.getArtifactDirectory(any())) .thenReturn(cacheArtifactDirectory); @@ -68,6 +63,12 @@ void main() { (_) async => http.StreamedResponse(const Stream.empty(), HttpStatus.ok), ); + when(() => shorebirdEnv.getShorebirdProjectRoot()) + .thenReturn(projectRoot); + + artifactManager = ArtifactManager(); + + patchExecutable = MockPatchExecutable(); when( () => patchExecutable.run( releaseArtifactPath: any( @@ -83,13 +84,6 @@ void main() { ).thenAnswer( (_) async {}, ); - - when(() => shorebirdEnv.getShorebirdProjectRoot()) - .thenReturn(projectRoot); - - when(() => updaterTools.path).thenReturn('updater_tools'); - - artifactManager = ArtifactManager(); }); group('createDiff', () { @@ -102,22 +96,14 @@ void main() { ..createSync(recursive: true); patchArtifactFile = File(p.join(tmpDir.path, 'patch_artifact')) ..createSync(recursive: true); - - when( - () => updaterTools.createDiff( - releaseArtifact: any(named: 'releaseArtifact'), - patchArtifact: any(named: 'patchArtifact'), - outputFile: any(named: 'outputFile'), - ), - ).thenAnswer((_) async => {}); }); test('throws error when release artifact file does not exist', () async { await expectLater( () => runWithOverrides( () async => artifactManager.createDiff( - releaseArtifact: File('not/a/real/file'), - patchArtifact: patchArtifactFile, + releaseArtifactPath: 'not/a/real/file', + patchArtifactPath: patchArtifactFile.path, ), ), throwsA( @@ -140,8 +126,8 @@ void main() { await expectLater( () => runWithOverrides( () async => artifactManager.createDiff( - releaseArtifact: releaseArtifactFile, - patchArtifact: File('not/a/real/file'), + releaseArtifactPath: releaseArtifactFile.path, + patchArtifactPath: 'not/a/real/file', ), ), throwsA( @@ -174,8 +160,8 @@ void main() { await expectLater( () => runWithOverrides( () async => artifactManager.createDiff( - releaseArtifact: releaseArtifactFile, - patchArtifact: patchArtifactFile, + releaseArtifactPath: releaseArtifactFile.path, + patchArtifactPath: patchArtifactFile.path, ), ), throwsA( @@ -191,8 +177,8 @@ void main() { test('returns diff path when creating diff succeeds', () async { final diffPath = await runWithOverrides( () => artifactManager.createDiff( - releaseArtifact: releaseArtifactFile, - patchArtifact: patchArtifactFile, + releaseArtifactPath: releaseArtifactFile.path, + patchArtifactPath: patchArtifactFile.path, ), ); @@ -205,40 +191,6 @@ void main() { ), ).called(1); }); - - group('when updater-tools is present', () { - setUp(() { - final tempDir = Directory.systemTemp.createTempSync(); - final updaterToolsFile = File(p.join(tempDir.path, 'updater_tools')) - ..createSync(); - when(() => updaterTools.path).thenReturn(updaterToolsFile.path); - }); - - test('uses updater-tools instead of patch to create diff', () async { - await runWithOverrides( - () => artifactManager.createDiff( - releaseArtifact: releaseArtifactFile, - patchArtifact: patchArtifactFile, - ), - ); - - verify( - () => updaterTools.createDiff( - releaseArtifact: releaseArtifactFile, - patchArtifact: patchArtifactFile, - outputFile: any(named: 'outputFile'), - ), - ).called(1); - - verifyNever( - () => patchExecutable.run( - releaseArtifactPath: any(named: 'releaseArtifactPath'), - patchArtifactPath: any(named: 'patchArtifactPath'), - diffPath: any(named: 'diffPath'), - ), - ); - }); - }); }); group('downloadFile', () { diff --git a/packages/shorebird_cli/test/src/cache_test.dart b/packages/shorebird_cli/test/src/cache_test.dart index 8d324b4c8..dca8ec916 100644 --- a/packages/shorebird_cli/test/src/cache_test.dart +++ b/packages/shorebird_cli/test/src/cache_test.dart @@ -235,8 +235,7 @@ void main() { final request = invocation.positionalArguments.first as http.BaseRequest; final fileName = p.basename(request.url.path); - if (fileName.startsWith('aot-tools') || - fileName.startsWith('updater-tools')) { + if (fileName.startsWith('aot-tools')) { return http.StreamedResponse( const Stream.empty(), HttpStatus.notFound, @@ -263,11 +262,6 @@ void main() { '''[cache] optional artifact: "aot-tools" was not found, skipping...''', ), ).called(1); - verify( - () => logger.detail( - '''[cache] optional artifact: "updater-tools.dill" was not found, skipping...''', - ), - ).called(1); }); test('downloads correct artifacts', () async { @@ -297,7 +291,6 @@ void main() { perEngine('patch-darwin-x64.zip'), 'https://github.com/google/bundletool/releases/download/1.15.6/bundletool-all-1.15.6.jar', perEngine('aot-tools.dill'), - perEngine('updater-tools.dill'), ].map(Uri.parse).toList(); expect(requests, equals(expected)); @@ -342,7 +335,6 @@ void main() { // Requests the .dill, fails and falls back to executable: perEngine('aot-tools.dill'), perEngine('aot-tools-darwin-x64'), - perEngine('updater-tools.dill'), ].map(Uri.parse).toList(); expect(requests, equals(expected)); @@ -393,7 +385,6 @@ void main() { perEngine('patch-windows-x64.zip'), 'https://github.com/google/bundletool/releases/download/1.15.6/bundletool-all-1.15.6.jar', perEngine('aot-tools.dill'), - perEngine('updater-tools.dill'), ].map(Uri.parse).toList(); expect(requests, equals(expected)); @@ -417,7 +408,6 @@ void main() { perEngine('patch-linux-x64.zip'), 'https://github.com/google/bundletool/releases/download/1.15.6/bundletool-all-1.15.6.jar', perEngine('aot-tools.dill'), - perEngine('updater-tools.dill'), ].map(Uri.parse).toList(); expect(requests, equals(expected)); diff --git a/packages/shorebird_cli/test/src/commands/patch/aar_patcher_test.dart b/packages/shorebird_cli/test/src/commands/patch/aar_patcher_test.dart index 0270d5157..285cca159 100644 --- a/packages/shorebird_cli/test/src/commands/patch/aar_patcher_test.dart +++ b/packages/shorebird_cli/test/src/commands/patch/aar_patcher_test.dart @@ -81,7 +81,6 @@ void main() { setUpAll(() { registerFallbackValue(Directory('')); - registerFallbackValue(File('')); registerFallbackValue(ReleasePlatform.android); registerFallbackValue(Uri.parse('https://example.com')); setExitFunctionForTests(); @@ -380,8 +379,8 @@ void main() { when( () => artifactManager.createDiff( - patchArtifact: any(named: 'patchArtifact'), - releaseArtifact: any(named: 'releaseArtifact'), + patchArtifactPath: any(named: 'patchArtifactPath'), + releaseArtifactPath: any(named: 'releaseArtifactPath'), ), ).thenAnswer((_) async { final diffPath = @@ -417,8 +416,8 @@ void main() { setUp(() { when( () => artifactManager.createDiff( - releaseArtifact: any(named: 'releaseArtifact'), - patchArtifact: any(named: 'patchArtifact'), + releaseArtifactPath: any(named: 'releaseArtifactPath'), + patchArtifactPath: any(named: 'patchArtifactPath'), ), ).thenThrow(Exception('error')); }); diff --git a/packages/shorebird_cli/test/src/commands/patch/android_patcher_test.dart b/packages/shorebird_cli/test/src/commands/patch/android_patcher_test.dart index ab980faa1..a6fe6a241 100644 --- a/packages/shorebird_cli/test/src/commands/patch/android_patcher_test.dart +++ b/packages/shorebird_cli/test/src/commands/patch/android_patcher_test.dart @@ -90,7 +90,6 @@ void main() { setUpAll(() { registerFallbackValue(Directory('')); - registerFallbackValue(File('')); registerFallbackValue(ReleasePlatform.android); registerFallbackValue(Uri.parse('https://example.com')); setExitFunctionForTests(); @@ -387,8 +386,8 @@ Looked in: when( () => artifactManager.createDiff( - releaseArtifact: any(named: 'releaseArtifact'), - patchArtifact: any(named: 'patchArtifact'), + releaseArtifactPath: any(named: 'releaseArtifactPath'), + patchArtifactPath: any(named: 'patchArtifactPath'), ), ).thenThrow(Exception('error')); }); @@ -414,8 +413,8 @@ Looked in: setUpProjectRootArtifacts(); when( () => artifactManager.createDiff( - releaseArtifact: any(named: 'releaseArtifact'), - patchArtifact: any(named: 'patchArtifact'), + releaseArtifactPath: any(named: 'releaseArtifactPath'), + patchArtifactPath: any(named: 'patchArtifactPath'), ), ).thenAnswer((_) async { final tempDir = Directory.systemTemp.createTempSync(); diff --git a/packages/shorebird_cli/test/src/commands/patch/ios_framework_patcher_test.dart b/packages/shorebird_cli/test/src/commands/patch/ios_framework_patcher_test.dart index 846a3dd05..c76c8e3d3 100644 --- a/packages/shorebird_cli/test/src/commands/patch/ios_framework_patcher_test.dart +++ b/packages/shorebird_cli/test/src/commands/patch/ios_framework_patcher_test.dart @@ -669,8 +669,8 @@ void main() { setUp(() { when( () => artifactManager.createDiff( - releaseArtifact: any(named: 'releaseArtifact'), - patchArtifact: any(named: 'patchArtifact'), + releaseArtifactPath: any(named: 'releaseArtifactPath'), + patchArtifactPath: any(named: 'patchArtifactPath'), ), ).thenAnswer((_) async => diffPath); setUpProjectRootArtifacts(); diff --git a/packages/shorebird_cli/test/src/commands/patch/ios_patcher_test.dart b/packages/shorebird_cli/test/src/commands/patch/ios_patcher_test.dart index dc2c1da32..7d4448894 100644 --- a/packages/shorebird_cli/test/src/commands/patch/ios_patcher_test.dart +++ b/packages/shorebird_cli/test/src/commands/patch/ios_patcher_test.dart @@ -839,8 +839,8 @@ void main() { setUp(() { when( () => artifactManager.createDiff( - releaseArtifact: any(named: 'releaseArtifact'), - patchArtifact: any(named: 'patchArtifact'), + releaseArtifactPath: any(named: 'releaseArtifactPath'), + patchArtifactPath: any(named: 'patchArtifactPath'), ), ).thenAnswer((_) async => diffPath); setUpProjectRootArtifacts(); diff --git a/packages/shorebird_cli/test/src/executables/updater_tools_test.dart b/packages/shorebird_cli/test/src/executables/updater_tools_test.dart deleted file mode 100644 index 2f1bea0f1..000000000 --- a/packages/shorebird_cli/test/src/executables/updater_tools_test.dart +++ /dev/null @@ -1,169 +0,0 @@ -import 'dart:io'; - -import 'package:mocktail/mocktail.dart'; -import 'package:scoped_deps/scoped_deps.dart'; -import 'package:shorebird_cli/src/executables/executables.dart'; -import 'package:shorebird_cli/src/shorebird_artifacts.dart'; -import 'package:shorebird_cli/src/shorebird_env.dart'; -import 'package:shorebird_cli/src/shorebird_process.dart'; -import 'package:test/test.dart'; - -import '../mocks.dart'; - -void main() { - group(UpdaterTools, () { - late File releaseArtifact; - late File patchArtifact; - late File outputFile; - late PatchExecutable patchExecutable; - late ShorebirdArtifacts shorebirdArtifacts; - late ShorebirdEnv shorebirdEnv; - late ShorebirdProcess shorebirdProcess; - - late UpdaterTools updaterTools; - - R runWithOverrides(R Function() body) { - return runScoped( - body, - values: { - patchExecutableRef.overrideWith(() => patchExecutable), - processRef.overrideWith(() => shorebirdProcess), - shorebirdArtifactsRef.overrideWith(() => shorebirdArtifacts), - shorebirdEnvRef.overrideWith(() => shorebirdEnv), - }, - ); - } - - setUp(() { - patchExecutable = MockPatchExecutable(); - shorebirdArtifacts = MockShorebirdArtifacts(); - shorebirdEnv = MockShorebirdEnv(); - shorebirdProcess = MockShorebirdProcess(); - - final tempDir = Directory.systemTemp.createTempSync(); - releaseArtifact = File('${tempDir.path}/release')..createSync(); - patchArtifact = File('${tempDir.path}/patch')..createSync(); - outputFile = File('${tempDir.path}/output')..createSync(); - - when(() => patchExecutable.path).thenReturn('patch_executable'); - - when( - () => shorebirdArtifacts.getArtifactPath( - artifact: ShorebirdArtifact.updaterTools, - ), - ).thenReturn('updater_tools'); - - when(() => shorebirdEnv.dartBinaryFile).thenReturn(File('dart')); - - updaterTools = UpdaterTools(); - }); - - group('createDiff', () { - test('throws FileSystemException if release artifact does not exist', - () async { - await expectLater( - runWithOverrides( - () => updaterTools.createDiff( - releaseArtifact: File('non_existent_file'), - patchArtifact: patchArtifact, - outputFile: outputFile, - ), - ), - throwsA(isA()), - ); - }); - - test('throws FileSystemException if patch artifact does not exist', - () async { - await expectLater( - runWithOverrides( - () => updaterTools.createDiff( - releaseArtifact: releaseArtifact, - patchArtifact: File('non_existent_file'), - outputFile: outputFile, - ), - ), - throwsA(isA()), - ); - }); - - group('when diff exits with non-zero code', () { - setUp(() { - when( - () => shorebirdProcess.run( - any(), - any(), - workingDirectory: any(named: 'workingDirectory'), - ), - ).thenAnswer( - (_) async => const ShorebirdProcessResult( - exitCode: 1, - stdout: '', - stderr: '', - ), - ); - }); - - test('throws exception', () { - expect( - () => runWithOverrides( - () => updaterTools.createDiff( - releaseArtifact: releaseArtifact, - patchArtifact: patchArtifact, - outputFile: outputFile, - ), - ), - throwsA(isA()), - ); - }); - }); - - group('when diff exits successfully', () { - setUp(() { - when( - () => shorebirdProcess.run( - any(), - any(), - workingDirectory: any(named: 'workingDirectory'), - ), - ).thenAnswer( - (_) async => const ShorebirdProcessResult( - exitCode: 0, - stdout: '', - stderr: '', - ), - ); - }); - - test('completes', () { - expect( - () => runWithOverrides( - () => updaterTools.createDiff( - releaseArtifact: releaseArtifact, - patchArtifact: patchArtifact, - outputFile: outputFile, - ), - ), - returnsNormally, - ); - - verify( - () => shorebirdProcess.run( - 'dart', - [ - 'run', - 'updater_tools', - 'diff', - '--release=${releaseArtifact.path}', - '--patch=${patchArtifact.path}', - '--patch-executable=${patchExecutable.path}', - '--output=${outputFile.path}', - ], - workingDirectory: any(named: 'workingDirectory'), - ), - ).called(1); - }); - }); - }); - }); -} diff --git a/packages/shorebird_cli/test/src/mocks.dart b/packages/shorebird_cli/test/src/mocks.dart index 02503af72..c602b167b 100644 --- a/packages/shorebird_cli/test/src/mocks.dart +++ b/packages/shorebird_cli/test/src/mocks.dart @@ -162,8 +162,6 @@ class MockShorebirdYaml extends Mock implements ShorebirdYaml {} class MockStdin extends Mock implements Stdin {} -class MockUpdaterTools extends Mock implements UpdaterTools {} - class MockValidator extends Mock implements Validator {} class MockXcodeBuild extends Mock implements XcodeBuild {} diff --git a/packages/shorebird_cli/test/src/shorebird_artifacts_test.dart b/packages/shorebird_cli/test/src/shorebird_artifacts_test.dart index e23331f30..8b4e03ba9 100644 --- a/packages/shorebird_cli/test/src/shorebird_artifacts_test.dart +++ b/packages/shorebird_cli/test/src/shorebird_artifacts_test.dart @@ -104,69 +104,46 @@ void main() { }); }); - group('gen_snapshot', () { - test('returns correct path', () { - expect( - runWithOverrides( - () => artifacts.getArtifactPath( - artifact: ShorebirdArtifact.genSnapshot, - ), - ), - equals( - p.join( - flutterDirectory.path, - 'bin', - 'cache', - 'artifacts', - 'engine', - 'ios-release', - 'gen_snapshot_arm64', - ), - ), - ); - }); - }); - - group('analyze_snapshot', () { - test('returns correct path', () { - expect( - runWithOverrides( - () => artifacts.getArtifactPath( - artifact: ShorebirdArtifact.analyzeSnapshot, - ), + test('returns correct path for gen_snapshot', () { + expect( + runWithOverrides( + () => artifacts.getArtifactPath( + artifact: ShorebirdArtifact.genSnapshot, ), - equals( - p.join( - flutterDirectory.path, - 'bin', - 'cache', - 'artifacts', - 'engine', - 'ios-release', - 'analyze_snapshot_arm64', - ), + ), + equals( + p.join( + flutterDirectory.path, + 'bin', + 'cache', + 'artifacts', + 'engine', + 'ios-release', + 'gen_snapshot_arm64', ), - ); - }); + ), + ); }); - group('updater_tools', () { - test('returns correct path', () { - expect( - runWithOverrides( - () => artifacts.getArtifactPath( - artifact: ShorebirdArtifact.updaterTools, - ), + test('returns correct path for analyze_snapshot', () { + expect( + runWithOverrides( + () => artifacts.getArtifactPath( + artifact: ShorebirdArtifact.analyzeSnapshot, ), - equals( - p.join( - artifactDirectory.path, - engineRevision, - 'updater-tools.dill', - ), + ), + equals( + p.join( + flutterDirectory.path, + 'bin', + 'cache', + 'artifacts', + 'engine', + 'ios-release', + 'analyze_snapshot_arm64', ), - ); - }); + ), + ); }); }); }); @@ -201,91 +178,63 @@ void main() { }); group('getArtifactPath', () { - group('aot-tools', () { - test('returns correct path', () { - expect( - runWithOverrides( - () => artifacts.getArtifactPath( - artifact: ShorebirdArtifact.aotTools, - ), + test('returns correct path for aot tools', () { + expect( + runWithOverrides( + () => artifacts.getArtifactPath( + artifact: ShorebirdArtifact.aotTools, ), - equals( - p.join( - localEngineSrcPath, - 'third_party', - 'dart', - 'pkg', - 'aot_tools', - 'bin', - 'aot_tools.dart', - ), + ), + equals( + p.join( + localEngineSrcPath, + 'third_party', + 'dart', + 'pkg', + 'aot_tools', + 'bin', + 'aot_tools.dart', ), - ); - }); + ), + ); }); - group('gen_snapshot', () { - test('returns correct path', () { - expect( - runWithOverrides( - () => artifacts.getArtifactPath( - artifact: ShorebirdArtifact.genSnapshot, - ), + test('returns correct path for gen_snapshot', () { + expect( + runWithOverrides( + () => artifacts.getArtifactPath( + artifact: ShorebirdArtifact.genSnapshot, ), - equals( - p.join( - localEngineSrcPath, - 'out', - localEngine, - 'clang_x64', - 'gen_snapshot_arm64', - ), + ), + equals( + p.join( + localEngineSrcPath, + 'out', + localEngine, + 'clang_x64', + 'gen_snapshot_arm64', ), - ); - }); + ), + ); }); - group('analyze_snapshot', () { - test('returns correct path', () { - expect( - runWithOverrides( - () => artifacts.getArtifactPath( - artifact: ShorebirdArtifact.analyzeSnapshot, - ), + test('returns correct path for analyze_snapshot', () { + expect( + runWithOverrides( + () => artifacts.getArtifactPath( + artifact: ShorebirdArtifact.analyzeSnapshot, ), - equals( - p.join( - localEngineSrcPath, - 'out', - localEngine, - 'clang_x64', - 'analyze_snapshot_arm64', - ), + ), + equals( + p.join( + localEngineSrcPath, + 'out', + localEngine, + 'clang_x64', + 'analyze_snapshot_arm64', ), - ); - }); - - group('updater-tools', () { - test('returns correct path', () { - expect( - runWithOverrides( - () => artifacts.getArtifactPath( - artifact: ShorebirdArtifact.updaterTools, - ), - ), - equals( - p.join( - localEngineSrcPath, - 'third_party', - 'updater', - 'updater_tools', - 'bin', - 'updater_tools.dart', - ), - ), - ); - }); - }); + ), + ); }); }); });