Skip to content

Commit 1368988

Browse files
parloughCommit Queue
authored andcommitted
[dartdev] Don't ignore the --define option in dart run
An earlier comment in the source specifies options have to be specified in both places to not be ignored. Fixes #61373 which is a regression in current 3.10 beta and dev releases. TEST=pkg/dartdev/test/commands/run_test.dart Change-Id: Ideae8638dce8ff530f7c46735d6cd7e9cd9a2836 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446681 Commit-Queue: Slava Egorov <[email protected]> Reviewed-by: Ben Konyi <[email protected]> Auto-Submit: Parker Lougheed <[email protected]> Reviewed-by: Slava Egorov <[email protected]>
1 parent c667238 commit 1368988

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

pkg/dartdev/test/commands/run_test.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,31 @@ void main(List<String> args) => print("$b $args");
383383
], onData3);
384384
});
385385

386+
test('with VM environment declaration options specified', () async {
387+
p = project(mainSrc: r'''
388+
void main() {
389+
print(const bool.fromEnvironment('key'));
390+
}
391+
''');
392+
393+
final result =
394+
await p.run(['run', '--define=key=true', p.relativeFilePath]);
395+
396+
expect(result.stderr, isEmpty);
397+
expect(result.stdout, contains('true'));
398+
expect(result.exitCode, 0);
399+
400+
final abbreviationResult = await p.run([
401+
'run',
402+
'-Dkey=true',
403+
p.relativeFilePath,
404+
]);
405+
406+
expect(abbreviationResult.stderr, isEmpty);
407+
expect(abbreviationResult.stdout, contains('true'));
408+
expect(abbreviationResult.exitCode, 0);
409+
});
410+
386411
test('with accepted VM flags related to the timeline', () async {
387412
p = project(
388413
mainSrc: 'import "dart:developer";'

runtime/bin/dartdev_options.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ bool Options::ProcessVMOptions(const char* arg,
118118
V("--disable-service-auth-codes", arg) \
119119
V("--write-service-info", arg) \
120120
V("--enable-service-port-fallback", arg) \
121+
V("--define", arg) \
122+
V("-D", arg) \
121123
V("--disable-service-auth-codes", arg) \
122124
V("--serve-observatory", arg) \
123125
V("--print-dtd", arg) \

0 commit comments

Comments
 (0)