Skip to content

Commit b693194

Browse files
dcharkesCommit Queue
authored andcommitted
[native assets] Don't fail early on invalid package config
Bug: #59992 Change-Id: If7aff2aeecbab347f5bcb997e6fd6043e8818e1b Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-arm64-try,pkg-win-release-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406280 Commit-Queue: Daco Harkes <[email protected]> Reviewed-by: Ben Konyi <[email protected]>
1 parent 6e33c95 commit b693194

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

pkg/dartdev/lib/src/native_assets.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,19 @@ class DartNativeAssetsBuilder {
114114
'Package(s) $packageNames require the native assets feature to be enabled. '
115115
'Enable native assets with `--enable-experiment=native-assets`.',
116116
);
117+
return true;
117118
} on FormatException catch (e) {
118119
// This can be thrown if the package_config.json is malformed or has
119120
// duplicate entries.
120121
log.stderr(
121-
'Error encountered while parsing package_config.json: ${e.message}',
122+
'Error encountered while parsing '
123+
'${packageConfigUri.toFilePath()}: ${e.message}.',
122124
);
125+
// If the package config cannot be read, don't fail here. The dartdev
126+
// command invoking this function can fail if it requires to have a valid
127+
// package config.
128+
return false;
123129
}
124-
return true;
125130
}
126131

127132
Future<BuildResult?> _buildNativeAssetsShared({

pkg/dartdev/test/commands/run_test.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -589,11 +589,17 @@ void main(List<String> args) => print("$b $args");
589589
expect(result.stdout, isEmpty);
590590
expect(
591591
result.stderr,
592-
contains(
593-
'Error encountered while parsing package_config.json: Duplicate package name',
592+
stringContainsInOrder(
593+
[
594+
'Error encountered while parsing ',
595+
'package_config.json:',
596+
' Duplicate package name',
597+
],
594598
),
595599
);
596-
expect(result.exitCode, 255);
600+
printOnFailure(result.stderr);
601+
const int compileErrorExitCode = 254;
602+
expect(result.exitCode, compileErrorExitCode);
597603
});
598604

599605
test('workspace', () async {

0 commit comments

Comments
 (0)