Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont print exceptions thrown by getExecutableForCommand #4377

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions lib/src/entrypoint.dart
Original file line number Diff line number Diff line change
Expand Up @@ -678,13 +678,11 @@ To update `$lockFilePath` run `$topLevelProgram pub get`$suffix without
}) async {
await log.progress('Building package executable', () async {
ensureDir(p.dirname(pathOfSnapshot(executable)));
return waitAndPrintErrors([
_precompileExecutable(
executable,
additionalSources: additionalSources,
nativeAssets: nativeAssets,
),
]);
return await _precompileExecutable(
executable,
additionalSources: additionalSources,
nativeAssets: nativeAssets,
);
});
}

Expand Down
14 changes: 7 additions & 7 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ packages:
dependency: transitive
description:
name: _fe_analyzer_shared
sha256: "45cfa8471b89fb6643fe9bf51bd7931a76b8f5ec2d65de4fb176dba8d4f22c77"
sha256: f6dbf021f4b214d85c79822912c5fcd142a2c4869f01222ad371bc51f9f1c356
url: "https://pub.dev"
source: hosted
version: "73.0.0"
version: "74.0.0"
_macros:
dependency: transitive
description: dart
source: sdk
version: "0.3.2"
version: "0.3.3"
analyzer:
dependency: "direct main"
description:
name: analyzer
sha256: "4959fec185fe70cce007c57e9ab6983101dbe593d2bf8bbfb4453aaec0cf470a"
sha256: f7e8caf82f2d3190881d81012606effdf8a38e6c1ab9e30947149733065f817c
url: "https://pub.dev"
source: hosted
version: "6.8.0"
version: "6.9.0"
args:
dependency: "direct main"
description:
Expand Down Expand Up @@ -194,10 +194,10 @@ packages:
dependency: transitive
description:
name: macros
sha256: "0acaed5d6b7eab89f63350bccd82119e6c602df0f391260d0e32b5e23db79536"
sha256: "1d9e801cd66f7ea3663c45fc708450db1fa57f988142c64289142c9b7ee80656"
url: "https://pub.dev"
source: hosted
version: "0.1.2-main.4"
version: "0.1.3-main.0"
matcher:
dependency: transitive
description:
Expand Down
14 changes: 14 additions & 0 deletions test/embedding/embedding_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,20 @@ main() {
);
});

testWithGolden('Compilation errors are only printed once', (context) async {
await servePackages();
await d.dir(appPath, [
d.appPubspec(),
d.dir('bin', [d.file('syntax_error.dart', 'main() => print("hi")')]),
]).create();
await context.runEmbedding(
['run', ':syntax_error'],
environment: getPubTestEnvironment(),
workingDirectory: d.path(appPath),
exitCode: isNot(0),
);
});

test('`embedding run` does `pub get` if sdk updated', () async {
await d.dir(appPath, [
d.pubspec({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# GENERATED BY: test/embedding/embedding_test.dart

$ tool/test-bin/pub_command_runner.dart run :syntax_error
[E] Failed to build myapp:syntax_error:
[E] bin/syntax_error.dart:1:21: Error: Expected ';' after this.
[E] main() => print("hi")
[E] ^
[E] bin/syntax_error.dart:1:22: Error: Unexpected token ''.
[E] main() => print("hi")
[E] ^...

8 changes: 7 additions & 1 deletion tool/test-bin/pub_command_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,13 @@ class RunCommand extends Command<int> {

@override
Future<int> run() async {
final executable = await getExecutableForCommand(argResults!.rest.first);
final DartExecutableWithPackageConfig executable;
try {
executable = await getExecutableForCommand(argResults!.rest.first);
} on CommandResolutionFailedException catch (e) {
log.error(e.message);
return -1;
}
final packageConfig = executable.packageConfig;
final process = await Process.start(
Platform.executable,
Expand Down