Skip to content

Commit 9e52249

Browse files
committed
Add test
1 parent 464866d commit 9e52249

File tree

5 files changed

+64
-1
lines changed

5 files changed

+64
-1
lines changed

pkgs/native_assets_builder/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Link hooks are not ordered.
66
- Fix test.
77
- Bump `package:native_assets_cli` to 0.6.0.
8+
- Copy `resources.json` to the build directory.
89

910
## 0.6.0
1011

pkgs/native_assets_builder/test/build_runner/helpers.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Future<LinkResult> link(
7373
List<String>? capturedLogs,
7474
PackageLayout? packageLayout,
7575
required BuildResult buildResult,
76+
Uri? resourceIdentifiers,
7677
}) async =>
7778
await runWithLog(capturedLogs, () async {
7879
final result = await NativeAssetsBuildRunner(
@@ -87,6 +88,7 @@ Future<LinkResult> link(
8788
includeParentEnvironment: includeParentEnvironment,
8889
packageLayout: packageLayout,
8990
buildResult: buildResult,
91+
resourceIdentifiers: resourceIdentifiers,
9092
);
9193

9294
if (result.success) {
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright (c) 2024, 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+
import 'dart:io';
6+
7+
import 'package:test/test.dart';
8+
9+
import '../helpers.dart';
10+
import 'helpers.dart';
11+
12+
const Timeout longTimeout = Timeout(Duration(minutes: 5));
13+
14+
void main() async {
15+
test(
16+
'simple_link linking',
17+
timeout: longTimeout,
18+
() async {
19+
await inTempDir((tempUri) async {
20+
await copyTestProjects(targetUri: tempUri);
21+
final packageUri = tempUri.resolve('simple_link/');
22+
23+
final resourcesUri = tempUri.resolve('treeshaking_info.json');
24+
await File.fromUri(resourcesUri).create();
25+
26+
// First, run `pub get`, we need pub to resolve our dependencies.
27+
await runPubGet(
28+
workingDirectory: packageUri,
29+
logger: logger,
30+
);
31+
32+
final buildResult = await build(
33+
packageUri,
34+
logger,
35+
dartExecutable,
36+
);
37+
38+
Iterable<String> buildFiles() => Directory.fromUri(
39+
packageUri.resolve('.dart_tool/native_assets_builder/'))
40+
.listSync(recursive: true)
41+
.map((file) => file.path);
42+
43+
expect(buildFiles(), isNot(anyElement(endsWith('resources.json'))));
44+
45+
await link(
46+
packageUri,
47+
logger,
48+
dartExecutable,
49+
buildResult: buildResult,
50+
resourceIdentifiers: resourcesUri,
51+
);
52+
expect(buildFiles(), anyElement(endsWith('resources.json')));
53+
});
54+
},
55+
);
56+
}

pkgs/native_assets_cli/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.6.1
2+
3+
- Copy `resources.json` to the build directory.
4+
15
## 0.6.0
26

37
- Add support for `hook/link.dart`.

pkgs/native_assets_cli/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: >-
44
native assets CLI.
55
66
# Note: Bump BuildConfig.version and BuildOutput.version on breaking changes!
7-
version: 0.6.0
7+
version: 0.6.1
88
repository: https://github.com/dart-lang/native/tree/main/pkgs/native_assets_cli
99

1010
topics:

0 commit comments

Comments
 (0)