diff --git a/pkg/dartdev/test/commands/run_test.dart b/pkg/dartdev/test/commands/run_test.dart index bf932f159d8..a20abed353a 100644 --- a/pkg/dartdev/test/commands/run_test.dart +++ b/pkg/dartdev/test/commands/run_test.dart @@ -107,6 +107,39 @@ void run() { expect(result.exitCode, 255); }); + test('experiments are enabled correctly', () async { + // TODO(bkonyi): find a more robust way to test experiments by exposing + // enabled experiments for an isolate (e.g., through dart:developer or the + // VM service). + // + // See https://github.com/dart-lang/sdk/issues/50230 + p = project(); + p.file('main.dart', 'void main(args) { print("Record: \${(1, 2)}"); }'); + ProcessResult result = await p.run([ + 'run', + '--enable-experiment=records', + 'main.dart', + ]); + + // The records experiment should be enabled. + expect(result.stdout, contains('Record: ')); + expect(result.stderr, isEmpty); + expect(result.exitCode, 0); + + // Run again with the experiment disabled to make sure the test is actually + // working as expected. + result = await p.run([ + 'run', + 'main.dart', + ]); + + // The records experiment should not be enabled and the program should fail + // to run. + expect(result.stdout, isEmpty); + expect(result.stderr, isNotEmpty); + expect(result.exitCode, 254); + }); + test('arguments are properly passed', () async { p = project(); p.file('main.dart', 'void main(args) { print(args); }'); diff --git a/runtime/bin/main_options.cc b/runtime/bin/main_options.cc index f561942c8f6..e18df71efd1 100644 --- a/runtime/bin/main_options.cc +++ b/runtime/bin/main_options.cc @@ -415,7 +415,8 @@ bool Options::ProcessVMDebuggingOptions(const char* arg, V("--pause-isolates-on-unhandled-exception", arg) \ V("--no-pause-isolates-on-unhandled-exception", arg) \ V("--warn-on-pause-with-no-debugger", arg) \ - V("--no-warn-on-pause-with-no-debugger", arg) + V("--no-warn-on-pause-with-no-debugger", arg) \ + V("--enable-experiment", arg) HANDLE_DARTDEV_VM_DEBUG_OPTIONS(IS_DEBUG_OPTION, arg); #undef IS_DEBUG_OPTION