[dartdev] Error on dart compile if native assets build fails

`dart run` and `dart build` already checked.

`dart compile` only checked if there are no native assets. However,
it should also error if native assets builds failed, as there could
have been native assets resulting from those builds.

Change-Id: Id90eb9b58675856421b793b271bf627506effe3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/334223
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
This commit is contained in:
Daco Harkes
2023-11-08 11:13:10 +00:00
committed by Commit Queue
parent cd26ceeab1
commit 72f847f458
4 changed files with 105 additions and 2 deletions
+4 -1
View File
@@ -104,7 +104,10 @@ class DartdevRunner extends CommandRunner<int> {
if (nativeAssetsExperimentEnabled) {
addCommand(BuildCommand(verbose: verbose));
}
addCommand(CompileCommand(verbose: verbose));
addCommand(CompileCommand(
verbose: verbose,
nativeAssetsExperimentEnabled: nativeAssetsExperimentEnabled,
));
addCommand(CreateCommand(verbose: verbose));
addCommand(DebugAdapterCommand(verbose: verbose));
addCommand(DevToolsCommand(verbose: verbose));
+5 -1
View File
@@ -329,7 +329,11 @@ Remove debugging information from the output and save it separately to the speci
return 255;
}
} else {
final (_, assets) = await compileNativeAssetsJit(verbose: verbose);
final (success, assets) = await compileNativeAssetsJit(verbose: verbose);
if (!success) {
stderr.writeln('Native assets build failed.');
return 255;
}
if (assets.isNotEmpty) {
stderr.writeln(
"'dart compile' does currently not support native assets.");
@@ -87,4 +87,33 @@ void main(List<String> args) async {
});
}
}
test('dart build native assets build failure', timeout: longTimeout,
() async {
await nativeAssetsTest('dart_app', (dartAppUri) async {
final buildDotDart = dartAppUri.resolve('../native_add/build.dart');
await File.fromUri(buildDotDart).writeAsString('''
void main(List<String> args) {
throw UnimplementedError();
}
''');
final result = await runDart(
arguments: [
'--enable-experiment=native-assets',
'build',
'bin/dart_app.dart',
],
workingDirectory: dartAppUri,
logger: logger,
expectExitCodeZero: false,
);
expect(
result.stderr,
contains(
'Native assets build failed.',
),
);
expect(result.exitCode, 255);
});
});
}
@@ -0,0 +1,67 @@
// Copyright (c) 2023, 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.
// @dart=2.18
import 'dart:io';
import 'package:test/test.dart';
import '../utils.dart';
import 'helpers.dart';
void main() async {
test('dart compile not supported', timeout: longTimeout, () async {
await nativeAssetsTest('dart_app', (dartAppUri) async {
final result = await runDart(
arguments: [
'--enable-experiment=native-assets',
'compile',
'exe',
'bin/dart_app.dart',
],
workingDirectory: dartAppUri,
logger: logger,
expectExitCodeZero: false,
);
expect(
result.stderr,
contains(
"'dart compile' does currently not support native assets.",
),
);
expect(result.exitCode, 255);
});
});
test('dart compile native assets build failure', timeout: longTimeout,
() async {
await nativeAssetsTest('dart_app', (dartAppUri) async {
final buildDotDart = dartAppUri.resolve('../native_add/build.dart');
await File.fromUri(buildDotDart).writeAsString('''
void main(List<String> args) {
throw UnimplementedError();
}
''');
final result = await runDart(
arguments: [
'--enable-experiment=native-assets',
'compile',
'exe',
'bin/dart_app.dart',
],
workingDirectory: dartAppUri,
logger: logger,
expectExitCodeZero: false,
);
expect(
result.stderr,
contains(
'Native assets build failed.',
),
);
expect(result.exitCode, 255);
});
});
}