[ DartDev ] Fixed issue where flags passed after the script name when

using 'dart run' would be interpreted by the 'dart run' argument parser

Fixes https://github.com/dart-lang/sdk/issues/42941

Change-Id: I46d7654d62b4575f0684f7faae51d972ac5f7f8c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157542
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
This commit is contained in:
Ben Konyi 2020-08-06 19:49:02 +00:00 committed by commit-bot@chromium.org
parent c59246d8ad
commit 507ffcfdaf
2 changed files with 8 additions and 5 deletions

View file

@ -26,7 +26,10 @@ class RunCommand extends DartdevCommand<int> {
// provided before any command and to provide a more consistent help message
// with the rest of the tool.
@override
final ArgParser argParser = ArgParser();
final ArgParser argParser = ArgParser(
// Don't parse flags after script name.
allowTrailingOptions: false,
);
@override
final bool verbose;

View file

@ -108,12 +108,12 @@ void run() {
final result = p.runSync('run', [
'--enable-experiment=non-nullable',
name,
'argument1',
'--argument1',
'argument2',
]);
// --enable-experiment and main.dart should not be passed.
expect(result.stdout, equals('[argument1, argument2]\n'));
expect(result.stdout, equals('[--argument1, argument2]\n'));
expect(result.stderr, isEmpty);
expect(result.exitCode, 0);
});
@ -126,12 +126,12 @@ void run() {
final result = p.runSync('run', [
'--enable-experiment=non-nullable',
Uri.file(name).toString(),
'argument1',
'--argument1',
'argument2',
]);
// --enable-experiment and main.dart should not be passed.
expect(result.stdout, equals('[argument1, argument2]\n'));
expect(result.stdout, equals('[--argument1, argument2]\n'));
expect(result.stderr, isEmpty);
expect(result.exitCode, 0);
});