Skip to content

Commit 84eba11

Browse files
authored
[native assets] Add support for pub workspaces (#2484)
Closes: #2483 Tested in `dartdev`: https://dart-review.googlesource.com/c/sdk/+/422080 Packages must opt in to a new version of package test to adopt this fix. (`dartdev` uses the version of `package:test` that's in the users' pubspec, rather than the one that's rolled in the Dart SDK!) In the test for `dartdev` I manually applied the edits to `third_party/pkg/test/pkgs/test_core` and overrode the dependencies.
2 parents 9f9fd77 + ab85097 commit 84eba11

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

pkgs/test_core/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## 0.6.9-wip
22

3+
- Add support for native assets for `dart test` in pub workspaces.
4+
35
## 0.6.8
46

57
* Fix hang when running multiple precompiled browser tests.

pkgs/test_core/lib/src/runner/vm/test_compiler.dart

+14-4
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,22 @@ class _TestCompilerForLanguageVersion {
151151
p.relative(p.dirname(p.dirname(Platform.resolvedExecutable)));
152152
final packageConfigUriAwaited = await packageConfigUri;
153153

154-
// If we have native assets for the host os in JIT mode, they are here.
154+
// If we have native assets for the host os in JIT mode, they are either
155+
// in the `.dart_tool/` in the root package or in the pub workspace.
155156
Uri? nativeAssetsYaml;
156157
if (enabledExperiments.contains('native-assets')) {
157-
nativeAssetsYaml = packageConfigUriAwaited.resolve('native_assets.yaml');
158-
if (!await File.fromUri(nativeAssetsYaml).exists()) {
159-
nativeAssetsYaml = null;
158+
final nativeAssetsYamlRootPackage =
159+
Directory.current.uri.resolve('.dart_tool/native_assets.yaml');
160+
final nativeAssetsYamlWorkspace =
161+
packageConfigUriAwaited.resolve('native_assets.yaml');
162+
for (final potentialNativeAssetsUri in [
163+
nativeAssetsYamlRootPackage,
164+
nativeAssetsYamlWorkspace
165+
]) {
166+
if (await File.fromUri(potentialNativeAssetsUri).exists()) {
167+
nativeAssetsYaml = potentialNativeAssetsUri;
168+
break;
169+
}
160170
}
161171
}
162172

0 commit comments

Comments
 (0)