artifacts_test.dart 22.9 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5
import 'package:file/memory.dart';
6
import 'package:flutter_tools/src/artifacts.dart';
7
import 'package:flutter_tools/src/base/file_system.dart';
8 9
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
10 11 12
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart';

13
import '../src/common.dart';
14
import '../src/context.dart';
15
import '../src/fakes.dart';
16 17

void main() {
18
  group('CachedArtifacts', () {
19 20 21 22
    late CachedArtifacts artifacts;
    late Cache cache;
    late FileSystem fileSystem;
    late Platform platform;
23 24

    setUp(() {
25
      fileSystem = MemoryFileSystem.test();
26 27
      final Directory cacheRoot = fileSystem.directory('root')
        ..createSync();
28
      platform = FakePlatform();
29 30 31 32
      cache = Cache(
        rootOverride: cacheRoot,
        fileSystem: fileSystem,
        platform: platform,
33
        logger: BufferLogger.test(),
34
        osUtils: FakeOperatingSystemUtils(),
35
        artifacts: <ArtifactSet>[],
36 37 38 39 40
      );
      artifacts = CachedArtifacts(
        fileSystem: fileSystem,
        cache: cache,
        platform: platform,
41
        operatingSystemUtils: FakeOperatingSystemUtils(),
42
      );
43 44
    });

45
    testWithoutContext('getArtifactPath', () {
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
      final String xcframeworkPath = artifacts.getArtifactPath(
        Artifact.flutterXcframework,
        platform: TargetPlatform.ios,
        mode: BuildMode.release,
      );
      expect(
        xcframeworkPath,
        fileSystem.path.join(
          'root',
          'bin',
          'cache',
          'artifacts',
          'engine',
          'ios-release',
          'Flutter.xcframework',
        ),
      );
63
      expect(
64 65 66 67 68 69 70 71
        () => artifacts.getArtifactPath(
          Artifact.flutterFramework,
          platform: TargetPlatform.ios,
          mode: BuildMode.release,
          environmentType: EnvironmentType.simulator,
        ),
        throwsToolExit(
            message:
72
                'No xcframework found at $xcframeworkPath.'),
73 74 75 76 77 78 79 80 81 82 83 84 85 86
      );
      fileSystem.directory(xcframeworkPath).createSync(recursive: true);
      expect(
        () => artifacts.getArtifactPath(
          Artifact.flutterFramework,
          platform: TargetPlatform.ios,
          mode: BuildMode.release,
          environmentType: EnvironmentType.simulator,
        ),
        throwsToolExit(message: 'No iOS frameworks found in $xcframeworkPath'),
      );

      fileSystem
          .directory(xcframeworkPath)
87
          .childDirectory('ios-arm64_x86_64-simulator')
88 89
          .childDirectory('Flutter.framework')
          .createSync(recursive: true);
90 91 92 93 94 95 96
      fileSystem
          .directory(xcframeworkPath)
          .childDirectory('ios-arm64')
          .childDirectory('Flutter.framework')
          .createSync(recursive: true);

      // TODO(jmagman): Remove ios-arm64_armv7 checks when armv7 engine artifacts are removed.
97 98
      fileSystem
          .directory(xcframeworkPath)
99
          .childDirectory('ios-arm64_armv7')
100 101 102 103 104 105 106 107
          .childDirectory('Flutter.framework')
          .createSync(recursive: true);
      expect(
        artifacts.getArtifactPath(Artifact.flutterFramework,
            platform: TargetPlatform.ios,
            mode: BuildMode.release,
            environmentType: EnvironmentType.simulator),
        fileSystem.path
108
            .join(xcframeworkPath, 'ios-arm64_x86_64-simulator', 'Flutter.framework'),
109
      );
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
      final String actualReleaseFrameworkArtifact = artifacts.getArtifactPath(
        Artifact.flutterFramework,
        platform: TargetPlatform.ios,
        mode: BuildMode.release,
        environmentType: EnvironmentType.physical,
      );
      final String expectedArm64ReleaseFrameworkArtifact = fileSystem.path.join(
        xcframeworkPath,
        'ios-arm64',
        'Flutter.framework',
      );
      final String expectedArmv7ReleaseFrameworkArtifact = fileSystem.path.join(
        xcframeworkPath,
        'ios-arm64_armv7',
        'Flutter.framework',
      );

      // TODO(jmagman): Replace with expect(actualReleaseFrameworkArtifact, expectedArm64ReleaseFrameworkArtifact) when armv7 engine artifacts are removed.
128
      expect(
129 130
        actualReleaseFrameworkArtifact,
        anyOf(expectedArm64ReleaseFrameworkArtifact, expectedArmv7ReleaseFrameworkArtifact),
131
      );
132 133 134 135
      expect(
        artifacts.getArtifactPath(Artifact.flutterXcframework, platform: TargetPlatform.ios, mode: BuildMode.release),
        fileSystem.path.join('root', 'bin', 'cache', 'artifacts', 'engine', 'ios-release', 'Flutter.xcframework'),
      );
136 137 138 139
      expect(
        artifacts.getArtifactPath(Artifact.flutterTester),
        fileSystem.path.join('root', 'bin', 'cache', 'artifacts', 'engine', 'linux-x64', 'flutter_tester'),
      );
140 141 142 143
      expect(
        artifacts.getArtifactPath(Artifact.flutterTester, platform: TargetPlatform.linux_arm64),
        fileSystem.path.join('root', 'bin', 'cache', 'artifacts', 'engine', 'linux-arm64', 'flutter_tester'),
      );
144 145
      expect(
        artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk),
146 147
        fileSystem.path.join('root', 'bin', 'cache', 'dart-sdk', 'bin',
          'snapshots', 'frontend_server_aot.dart.snapshot')
148
      );
149 150
    });

151
    testWithoutContext('Precompiled web AMD module system artifact paths are correct', () {
152
      expect(
153
        artifacts.getHostArtifact(HostArtifact.webPrecompiledAmdSdk).path,
154 155 156
        'root/bin/cache/flutter_web_sdk/kernel/amd/dart_sdk.js',
      );
      expect(
157
        artifacts.getHostArtifact(HostArtifact.webPrecompiledAmdSdkSourcemaps).path,
158 159 160
        'root/bin/cache/flutter_web_sdk/kernel/amd/dart_sdk.js.map',
      );
      expect(
161
        artifacts.getHostArtifact(HostArtifact.webPrecompiledAmdCanvaskitSdk).path,
162 163 164
        'root/bin/cache/flutter_web_sdk/kernel/amd-canvaskit/dart_sdk.js',
      );
      expect(
165
        artifacts.getHostArtifact(HostArtifact.webPrecompiledAmdCanvaskitSdkSourcemaps).path,
166 167
        'root/bin/cache/flutter_web_sdk/kernel/amd-canvaskit/dart_sdk.js.map',
      );
168
      expect(
169
        artifacts.getHostArtifact(HostArtifact.webPrecompiledAmdSoundSdk).path,
170 171 172
        'root/bin/cache/flutter_web_sdk/kernel/amd-sound/dart_sdk.js',
      );
      expect(
173
        artifacts.getHostArtifact(HostArtifact.webPrecompiledAmdSoundSdkSourcemaps).path,
174 175 176
        'root/bin/cache/flutter_web_sdk/kernel/amd-sound/dart_sdk.js.map',
      );
      expect(
177
        artifacts.getHostArtifact(HostArtifact.webPrecompiledAmdCanvaskitSoundSdk).path,
178 179 180
        'root/bin/cache/flutter_web_sdk/kernel/amd-canvaskit-sound/dart_sdk.js',
      );
      expect(
181
        artifacts.getHostArtifact(HostArtifact.webPrecompiledAmdCanvaskitSoundSdkSourcemaps).path,
182 183 184 185
        'root/bin/cache/flutter_web_sdk/kernel/amd-canvaskit-sound/dart_sdk.js.map',
      );
    });

186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
     testWithoutContext('Precompiled web DDC module system artifact paths are correct', () {
      expect(
        artifacts.getHostArtifact(HostArtifact.webPrecompiledDdcSdk).path,
        'root/bin/cache/flutter_web_sdk/kernel/ddc/dart_sdk.js',
      );
      expect(
        artifacts.getHostArtifact(HostArtifact.webPrecompiledDdcSdkSourcemaps).path,
        'root/bin/cache/flutter_web_sdk/kernel/ddc/dart_sdk.js.map',
      );
      expect(
        artifacts.getHostArtifact(HostArtifact.webPrecompiledDdcCanvaskitSdk).path,
        'root/bin/cache/flutter_web_sdk/kernel/ddc-canvaskit/dart_sdk.js',
      );
      expect(
        artifacts.getHostArtifact(HostArtifact.webPrecompiledDdcCanvaskitSdkSourcemaps).path,
        'root/bin/cache/flutter_web_sdk/kernel/ddc-canvaskit/dart_sdk.js.map',
      );
      expect(
        artifacts.getHostArtifact(HostArtifact.webPrecompiledDdcSoundSdk).path,
        'root/bin/cache/flutter_web_sdk/kernel/ddc-sound/dart_sdk.js',
      );
      expect(
        artifacts.getHostArtifact(HostArtifact.webPrecompiledDdcSoundSdkSourcemaps).path,
        'root/bin/cache/flutter_web_sdk/kernel/ddc-sound/dart_sdk.js.map',
      );
      expect(
        artifacts.getHostArtifact(HostArtifact.webPrecompiledDdcCanvaskitSoundSdk).path,
        'root/bin/cache/flutter_web_sdk/kernel/ddc-canvaskit-sound/dart_sdk.js',
      );
      expect(
        artifacts.getHostArtifact(HostArtifact.webPrecompiledDdcCanvaskitSoundSdkSourcemaps).path,
        'root/bin/cache/flutter_web_sdk/kernel/ddc-canvaskit-sound/dart_sdk.js.map',
      );
    });

221 222 223 224 225 226 227 228 229 230
    testWithoutContext('getEngineType', () {
      expect(
        artifacts.getEngineType(TargetPlatform.android_arm, BuildMode.debug),
        'android-arm',
      );
      expect(
        artifacts.getEngineType(TargetPlatform.ios, BuildMode.release),
        'ios-release',
      );
      expect(
231
        artifacts.getEngineType(TargetPlatform.darwin),
232 233
        'darwin-x64',
      );
234
    });
235
  });
236

237
  group('LocalEngineArtifacts', () {
238
    late Artifacts artifacts;
239 240 241
    late Cache cache;
    late FileSystem fileSystem;
    late Platform platform;
242

243
    setUp(() {
244
      fileSystem = MemoryFileSystem.test();
245 246
      final Directory cacheRoot = fileSystem.directory('root')
        ..createSync();
247
      platform = FakePlatform();
248 249 250 251
      cache = Cache(
        rootOverride: cacheRoot,
        fileSystem: fileSystem,
        platform: platform,
252
        logger: BufferLogger.test(),
253
        osUtils: FakeOperatingSystemUtils(),
254
        artifacts: <ArtifactSet>[],
255
      );
256 257 258 259 260 261 262 263 264 265 266
      artifacts = CachedLocalWebSdkArtifacts(
        parent: CachedLocalEngineArtifacts(
          fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'host_debug_unopt'),
          engineOutPath: fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'android_debug_unopt'),
          cache: cache,
          fileSystem: fileSystem,
          platform: platform,
          processManager: FakeProcessManager.any(),
          operatingSystemUtils: FakeOperatingSystemUtils(),
        ),
        webSdkPath: fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'wasm_release'),
267 268
        fileSystem: fileSystem,
        platform: platform,
269
        operatingSystemUtils: FakeOperatingSystemUtils());
270
    });
271

272
    testWithoutContext('getArtifactPath', () {
273 274 275 276 277
      final String xcframeworkPath = artifacts.getArtifactPath(
        Artifact.flutterXcframework,
        platform: TargetPlatform.ios,
        mode: BuildMode.release,
      );
278
      expect(
279 280 281
        xcframeworkPath,
        fileSystem.path
            .join('/out', 'android_debug_unopt', 'Flutter.xcframework'),
282
      );
283
      expect(
284 285 286 287 288 289 290 291
        () => artifacts.getArtifactPath(
          Artifact.flutterFramework,
          platform: TargetPlatform.ios,
          mode: BuildMode.release,
          environmentType: EnvironmentType.simulator,
        ),
        throwsToolExit(
            message:
292
                'No xcframework found at /out/android_debug_unopt/Flutter.xcframework'),
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308
      );
      fileSystem.directory(xcframeworkPath).createSync(recursive: true);
      expect(
        () => artifacts.getArtifactPath(
          Artifact.flutterFramework,
          platform: TargetPlatform.ios,
          mode: BuildMode.release,
          environmentType: EnvironmentType.simulator,
        ),
        throwsToolExit(
            message:
                'No iOS frameworks found in /out/android_debug_unopt/Flutter.xcframework'),
      );

      fileSystem
          .directory(xcframeworkPath)
309
          .childDirectory('ios-arm64_x86_64-simulator')
310 311 312 313
          .childDirectory('Flutter.framework')
          .createSync(recursive: true);
      fileSystem
          .directory(xcframeworkPath)
314
          .childDirectory('ios-arm64_armv7')
315 316
          .childDirectory('Flutter.framework')
          .createSync(recursive: true);
317 318 319 320 321 322 323
      fileSystem
          .directory('out')
          .childDirectory('host_debug_unopt')
          .childDirectory('dart-sdk')
          .childDirectory('bin')
          .createSync(recursive: true);

324 325 326 327 328 329 330 331
      expect(
        artifacts.getArtifactPath(
          Artifact.flutterFramework,
          platform: TargetPlatform.ios,
          mode: BuildMode.release,
          environmentType: EnvironmentType.simulator,
        ),
        fileSystem.path
332
            .join(xcframeworkPath, 'ios-arm64_x86_64-simulator', 'Flutter.framework'),
333 334 335 336 337 338 339 340 341
      );
      expect(
        artifacts.getArtifactPath(
          Artifact.flutterFramework,
          platform: TargetPlatform.ios,
          mode: BuildMode.release,
          environmentType: EnvironmentType.physical,
        ),
        fileSystem.path
342
            .join(xcframeworkPath, 'ios-arm64_armv7', 'Flutter.framework'),
343 344 345 346 347 348 349 350 351
      );
      expect(
        artifacts.getArtifactPath(
          Artifact.flutterXcframework,
          platform: TargetPlatform.ios,
          mode: BuildMode.release,
        ),
        fileSystem.path
            .join('/out', 'android_debug_unopt', 'Flutter.xcframework'),
352
      );
353 354 355 356 357
      expect(
        artifacts.getArtifactPath(Artifact.flutterTester),
        fileSystem.path.join('/out', 'android_debug_unopt', 'flutter_tester'),
      );
      expect(
358
        artifacts.getArtifactPath(Artifact.engineDartSdkPath),
359 360
        fileSystem.path.join('/out', 'host_debug_unopt', 'dart-sdk'),
      );
361 362 363
      expect(
        artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk),
        fileSystem.path.join('/out', 'host_debug_unopt', 'dart-sdk', 'bin',
364
          'snapshots', 'frontend_server_aot.dart.snapshot')
365
      );
366

367 368 369 370 371 372 373 374
      expect(
        artifacts.getArtifactPath(
          Artifact.flutterPreviewDevice,
          platform: TargetPlatform.windows_x64,
        ),
        fileSystem.path.join('root', 'bin', 'cache', 'artifacts',
          'flutter_preview', 'flutter_preview.exe'),
      );
375 376 377 378 379 380

      fileSystem.file(fileSystem.path.join('/out', 'host_debug_unopt', 'impellerc'))
        .createSync(recursive: true);
      fileSystem.file(fileSystem.path.join('/out', 'host_debug_unopt', 'libtessellator.so'))
        .createSync(recursive: true);

381 382 383 384 385 386 387 388
      expect(
        artifacts.getHostArtifact(HostArtifact.impellerc).path,
        fileSystem.path.join('/out', 'host_debug_unopt', 'impellerc'),
      );
      expect(
        artifacts.getHostArtifact(HostArtifact.libtessellator).path,
        fileSystem.path.join('/out', 'host_debug_unopt', 'libtessellator.so'),
      );
389
    });
390

391 392 393 394 395 396 397 398 399 400 401
    testWithoutContext('falls back to bundled impeller artifacts if the files do not exist in the local engine', () {
      expect(
        artifacts.getHostArtifact(HostArtifact.impellerc).path,
        fileSystem.path.join('root', 'bin', 'cache', 'artifacts', 'engine', 'linux-x64', 'impellerc'),
      );
      expect(
        artifacts.getHostArtifact(HostArtifact.libtessellator).path,
        fileSystem.path.join('root', 'bin', 'cache', 'artifacts', 'engine', 'linux-x64', 'libtessellator.so'),
      );
    });

402 403
    testWithoutContext('uses prebuilt dart sdk for web platform', () {
      final String failureMessage = 'Unable to find a prebuilt dart sdk at:'
404 405 406
          ' "${fileSystem.path.join('/flutter', 'prebuilts', 'linux-x64', 'dart-sdk')}"';

      expect(
407 408 409
        () => artifacts.getArtifactPath(
          Artifact.frontendServerSnapshotForEngineDartSdk,
          platform: TargetPlatform.web_javascript),
410 411 412
        throwsToolExit(message: failureMessage),
      );
      expect(
413 414 415
        () => artifacts.getArtifactPath(
          Artifact.engineDartSdkPath,
          platform: TargetPlatform.web_javascript),
416 417 418
        throwsToolExit(message: failureMessage),
      );
      expect(
419 420 421
        () => artifacts.getArtifactPath(
          Artifact.engineDartBinary,
          platform: TargetPlatform.web_javascript),
422 423 424
        throwsToolExit(message: failureMessage),
      );
      expect(
425 426 427
        () => artifacts.getArtifactPath(
          Artifact.dart2jsSnapshot,
          platform: TargetPlatform.web_javascript),
428 429 430 431 432 433 434 435 436 437 438 439
        throwsToolExit(message: failureMessage),
      );

      fileSystem
          .directory('flutter')
          .childDirectory('prebuilts')
          .childDirectory('linux-x64')
          .childDirectory('dart-sdk')
          .childDirectory('bin')
          .createSync(recursive: true);

      expect(
440 441 442
        artifacts.getArtifactPath(
          Artifact.frontendServerSnapshotForEngineDartSdk,
          platform: TargetPlatform.web_javascript),
443
        fileSystem.path.join('/flutter', 'prebuilts', 'linux-x64', 'dart-sdk', 'bin',
444
          'snapshots', 'frontend_server_aot.dart.snapshot'),
445 446
      );
      expect(
447 448 449
        artifacts.getArtifactPath(
          Artifact.engineDartSdkPath,
          platform: TargetPlatform.web_javascript),
450 451 452
        fileSystem.path.join('/flutter', 'prebuilts', 'linux-x64', 'dart-sdk'),
      );
      expect(
453 454 455
        artifacts.getArtifactPath(
          Artifact.engineDartBinary,
          platform: TargetPlatform.web_javascript),
456 457 458
        fileSystem.path.join('/flutter', 'prebuilts', 'linux-x64', 'dart-sdk', 'bin', 'dart'),
      );
      expect(
459 460 461
        artifacts.getArtifactPath(
          Artifact.dart2jsSnapshot,
          platform: TargetPlatform.web_javascript),
462 463 464 465 466
        fileSystem.path.join('/flutter', 'prebuilts', 'linux-x64', 'dart-sdk',
            'bin', 'snapshots', 'dart2js.dart.snapshot'),
      );
    });

467 468 469 470 471 472 473 474 475 476
    testWithoutContext('getEngineType', () {
      expect(
        artifacts.getEngineType(TargetPlatform.android_arm, BuildMode.debug),
        'android_debug_unopt',
      );
      expect(
        artifacts.getEngineType(TargetPlatform.ios, BuildMode.release),
        'android_debug_unopt',
      );
      expect(
477
        artifacts.getEngineType(TargetPlatform.darwin),
478 479 480
        'android_debug_unopt',
      );
    });
481

482
    testWithoutContext('Looks up dart.exe on windows platforms', () async {
483 484 485 486 487 488 489 490 491 492 493
      artifacts = CachedLocalWebSdkArtifacts(
        parent: CachedLocalEngineArtifacts(
          fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'host_debug_unopt'),
          engineOutPath: fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'android_debug_unopt'),
          cache: cache,
          fileSystem: fileSystem,
          platform: FakePlatform(operatingSystem: 'windows'),
          processManager: FakeProcessManager.any(),
          operatingSystemUtils: FakeOperatingSystemUtils(),
        ),
        webSdkPath: fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'wasm_release'),
494 495
        fileSystem: fileSystem,
        platform: FakePlatform(operatingSystem: 'windows'),
496
        operatingSystemUtils: FakeOperatingSystemUtils());
497

498 499 500 501 502 503 504 505
      fileSystem
          .directory('out')
          .childDirectory('host_debug_unopt')
          .childDirectory('dart-sdk')
          .childDirectory('bin')
          .createSync(recursive: true);

      expect(
506
        artifacts.getArtifactPath(Artifact.engineDartBinary),
507 508
        fileSystem.path.join('/out', 'host_debug_unopt', 'dart-sdk', 'bin', 'dart.exe'),
      );
509
    });
510

511
    testWithoutContext('Looks up dart on linux platforms', () async {
512 513 514 515 516 517 518 519
      fileSystem
          .directory('/out')
          .childDirectory('host_debug_unopt')
          .childDirectory('dart-sdk')
          .childDirectory('bin')
          .createSync(recursive: true);

      expect(
520
        artifacts.getArtifactPath(Artifact.engineDartBinary),
521 522 523 524
        fileSystem.path.join('/out', 'host_debug_unopt', 'dart-sdk', 'bin', 'dart'),
      );
    });

525 526 527 528 529 530 531 532 533 534 535 536
    testWithoutContext('Finds dart-sdk in windows prebuilts for web platform', () async {
      artifacts = CachedLocalWebSdkArtifacts(
        parent: CachedLocalEngineArtifacts(
          fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'host_debug_unopt'),
          engineOutPath: fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'android_debug_unopt'),
          cache: cache,
          fileSystem: fileSystem,
          platform: FakePlatform(operatingSystem: 'windows'),
          processManager: FakeProcessManager.any(),
          operatingSystemUtils: FakeOperatingSystemUtils(),
        ),
        webSdkPath: fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'wasm_release'),
537 538
        fileSystem: fileSystem,
        platform: FakePlatform(operatingSystem: 'windows'),
539
        operatingSystemUtils: FakeOperatingSystemUtils());
540 541 542 543 544 545 546 547 548 549

      fileSystem
          .directory('/flutter')
          .childDirectory('prebuilts')
          .childDirectory('windows-x64')
          .childDirectory('dart-sdk')
          .childDirectory('bin')
          .createSync(recursive: true);

      expect(
550
        artifacts.getArtifactPath(Artifact.engineDartBinary, platform: TargetPlatform.web_javascript),
551 552 553 554
        fileSystem.path.join('/flutter', 'prebuilts', 'windows-x64', 'dart-sdk', 'bin', 'dart.exe'),
      );
    });

555 556 557 558 559 560 561 562 563 564 565 566
    testWithoutContext('Finds dart-sdk in macos prebuilts for web platform', () async {
      artifacts = CachedLocalWebSdkArtifacts(
        parent: CachedLocalEngineArtifacts(
          fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'host_debug_unopt'),
          engineOutPath: fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'android_debug_unopt'),
          cache: cache,
          fileSystem: fileSystem,
          platform: FakePlatform(operatingSystem: 'macos'),
          processManager: FakeProcessManager.any(),
          operatingSystemUtils: FakeOperatingSystemUtils(),
        ),
        webSdkPath: fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'wasm_release'),
567 568
        fileSystem: fileSystem,
        platform: FakePlatform(operatingSystem: 'macos'),
569
        operatingSystemUtils: FakeOperatingSystemUtils());
570 571 572 573 574 575 576 577 578 579

      fileSystem
          .directory('/flutter')
          .childDirectory('prebuilts')
          .childDirectory('macos-x64')
          .childDirectory('dart-sdk')
          .childDirectory('bin')
          .createSync(recursive: true);

      expect(
580
        artifacts.getArtifactPath(Artifact.engineDartBinary, platform: TargetPlatform.web_javascript),
581 582
        fileSystem.path.join('/flutter', 'prebuilts', 'macos-x64', 'dart-sdk', 'bin', 'dart'),
      );
583 584
    });
  });
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617

  group('LocalEngineInfo', () {
    late FileSystem fileSystem;
    late LocalEngineInfo localEngineInfo;

    setUp(() {
      fileSystem = MemoryFileSystem.test();
    });

    testUsingContext('determines the target device name from the path', () {
      localEngineInfo = LocalEngineInfo(
        targetOutPath: fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'android_debug_unopt'),
        hostOutPath: fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'host_debug_unopt'),
      );

      expect(localEngineInfo.localTargetName, 'android_debug_unopt');
    }, overrides: <Type, Generator>{
      FileSystem: () => fileSystem,
      ProcessManager: () => FakeProcessManager.any(),
    });

    testUsingContext('determines the target device name from the path when using a custom engine path', () {
      localEngineInfo = LocalEngineInfo(
        targetOutPath: fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'android_debug_unopt'),
        hostOutPath: fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'host_debug_unopt'),
      );

      expect(localEngineInfo.localHostName, 'host_debug_unopt');
    }, overrides: <Type, Generator>{
      FileSystem: () => fileSystem,
      ProcessManager: () => FakeProcessManager.any(),
    });
  });
618
}