-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy
resources.json
for linking (#1177)
The `resources.json` should be copied to the link outputs, so that it can be inspected, cached, and used as a dependency to determine if a link hook needs to rerun. This adds it as a regular dependency for now - we probably rather want to have some custom logic later, which doesn't rerun the link hook if only things like line numbers change. --- <details> <summary>Contribution guidelines:</summary><br> - See our [contributor guide](https://github.com/dart-lang/.github/blob/main/CONTRIBUTING.md) for general expectations for PRs. - Larger or significant changes should be discussed in an issue before creating a PR. - Contributions to our repos should follow the [Dart style guide](https://dart.dev/guides/language/effective-dart) and use `dart format`. - Most changes should add an entry to the changelog and may need to [rev the pubspec package version](https://github.com/dart-lang/sdk/wiki/External-Package-Maintenance#making-a-change). - Changes to packages require [corresponding tests](https://github.com/dart-lang/.github/blob/main/CONTRIBUTING.md#Testing). Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback. </details>
- Loading branch information
Showing
6 changed files
with
80 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
pkgs/native_assets_builder/test/build_runner/resources_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'dart:io'; | ||
|
||
import 'package:test/test.dart'; | ||
|
||
import '../helpers.dart'; | ||
import 'helpers.dart'; | ||
|
||
const Timeout longTimeout = Timeout(Duration(minutes: 5)); | ||
|
||
void main() async { | ||
test( | ||
'simple_link linking', | ||
timeout: longTimeout, | ||
() async { | ||
await inTempDir((tempUri) async { | ||
await copyTestProjects(targetUri: tempUri); | ||
final packageUri = tempUri.resolve('simple_link/'); | ||
|
||
final resourcesUri = tempUri.resolve('treeshaking_info.json'); | ||
await File.fromUri(resourcesUri).create(); | ||
|
||
// First, run `pub get`, we need pub to resolve our dependencies. | ||
await runPubGet( | ||
workingDirectory: packageUri, | ||
logger: logger, | ||
); | ||
|
||
final buildResult = await build( | ||
packageUri, | ||
logger, | ||
dartExecutable, | ||
); | ||
|
||
Iterable<String> buildFiles() => Directory.fromUri( | ||
packageUri.resolve('.dart_tool/native_assets_builder/')) | ||
.listSync(recursive: true) | ||
.map((file) => file.path); | ||
|
||
expect(buildFiles(), isNot(anyElement(endsWith('resources.json')))); | ||
|
||
await link( | ||
packageUri, | ||
logger, | ||
dartExecutable, | ||
buildResult: buildResult, | ||
resourceIdentifiers: resourcesUri, | ||
); | ||
expect(buildFiles(), anyElement(endsWith('resources.json'))); | ||
}); | ||
}, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters