|
| 1 | +// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file |
| 2 | +// for details. All rights reserved. Use of this source code is governed by a |
| 3 | +// BSD-style license that can be found in the LICENSE file. |
| 4 | + |
| 5 | +// Regression test for https://github.com/flutter/flutter/issues/169921. |
| 6 | + |
| 7 | +// OtherResources=regress_flutter169921_program.dart |
| 8 | +// OtherResources=regress_flutter169921_deferred.dart |
| 9 | + |
| 10 | +import "dart:io"; |
| 11 | + |
| 12 | +import 'package:expect/expect.dart'; |
| 13 | +import 'package:path/path.dart' as path; |
| 14 | + |
| 15 | +import 'use_flag_test_helper.dart'; |
| 16 | + |
| 17 | +main(List<String> args) async { |
| 18 | + if (!isAOTRuntime) { |
| 19 | + return; // Running in JIT: AOT binaries not available. |
| 20 | + } |
| 21 | + |
| 22 | + if (Platform.isAndroid) { |
| 23 | + return; // SDK tree not available on the test device. |
| 24 | + } |
| 25 | + |
| 26 | + // These are the tools we need to be available to run on a given platform: |
| 27 | + if (!File(platformDill).existsSync()) { |
| 28 | + throw "Cannot run test as $platformDill does not exist"; |
| 29 | + } |
| 30 | + if (!await testExecutable(genSnapshot)) { |
| 31 | + throw "Cannot run test as $genSnapshot not available"; |
| 32 | + } |
| 33 | + |
| 34 | + await withTempDir('regress_flutter169921_test', (String tempDir) async { |
| 35 | + final cwDir = path.dirname(Platform.script.toFilePath()); |
| 36 | + final script = path.join(cwDir, 'regress_flutter169921_program.dart'); |
| 37 | + final scriptDill = path.join(tempDir, 'regress_flutter169921_program.dill'); |
| 38 | + |
| 39 | + await run(genKernel, <String>[ |
| 40 | + '--aot', |
| 41 | + '--platform=$platformDill', |
| 42 | + '-o', |
| 43 | + scriptDill, |
| 44 | + script, |
| 45 | + ]); |
| 46 | + |
| 47 | + final manifest = path.join(tempDir, 'manifest.json'); |
| 48 | + final profile = path.join(tempDir, 'profile.json'); |
| 49 | + final snapshot = path.join(tempDir, 'snapshot.so'); |
| 50 | + await run(genSnapshot, <String>[ |
| 51 | + '--snapshot-kind=app-aot-elf', |
| 52 | + '--elf=$snapshot', |
| 53 | + '--loading-unit-manifest=$manifest', |
| 54 | + '--write-v8-snapshot-profile-to=$profile', |
| 55 | + scriptDill, |
| 56 | + ]); |
| 57 | + |
| 58 | + await runError(dartPrecompiledRuntime, [snapshot], printStderr: true); |
| 59 | + }); |
| 60 | +} |
0 commit comments