Skip to content

Commit 7cf7000

Browse files
aamCommit Queue
authored andcommitted
[vm/dartdev] Pass package_config option to spawned executable.
Fixes #62009 TEST=dartdev/run_test Change-Id: I8fc114268d2f438fc78fa6b32f2d50e4b85cde91 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464660 Reviewed-by: Ryan Macnak <[email protected]> Commit-Queue: Alexander Aprelev <[email protected]> Reviewed-by: Ben Konyi <[email protected]>
1 parent 6d4cfab commit 7cf7000

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

pkg/dartdev/test/commands/run_test.dart

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,33 @@ void residentRun() {
963963
});
964964
});
965965

966+
test('resident compiler invocation has working resolvePackageUri', () async {
967+
p = project(name: 'foo');
968+
p.file('pubspec.yaml', '''
969+
name: foo
970+
environment:
971+
sdk: '>=2.12.0<3.0.0'
972+
973+
dependencies:
974+
path: ^1.9.0
975+
''');
976+
p.file('bin/main.dart', r'''
977+
import 'dart:isolate';
978+
Future<void> main() async {
979+
print(await Isolate.resolvePackageUri(Uri.parse('package:path/')));
980+
}
981+
''');
982+
983+
ProcessResult pubGetResult = await p.run(['pub', 'get']);
984+
expect(pubGetResult.stderr, isEmpty);
985+
expect(pubGetResult.exitCode, 0);
986+
987+
ProcessResult result = await p.run(['run', '--resident', 'bin/main.dart']);
988+
989+
expect(result.stdout, contains('file://'));
990+
expect(result.exitCode, 0);
991+
});
992+
966993
test(
967994
'passing --resident is a prerequisite for passing --resident-compiler-info-file',
968995
() async {

runtime/bin/dartdev.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,9 @@ class DartDev {
642642
} else {
643643
argc_ = argc + num_vm_options + 4;
644644
}
645+
if (package_config_override_ != nullptr) {
646+
argc_++;
647+
}
645648

646649
// Array of arguments to be passed to the script being execed.
647650
argv_ = std::unique_ptr<char*[], void (*)(char**)>(new char*[argc_ + 1],
@@ -687,6 +690,16 @@ class DartDev {
687690
if (mark_main_isolate_as_system_isolate) {
688691
argv_[idx++] = Utils::StrDup("--mark_main_isolate_as_system_isolate");
689692
}
693+
if (package_config_override_ != nullptr) {
694+
#if defined(DART_HOST_OS_WINDOWS)
695+
char* packages_arg =
696+
Utils::SCreate("--packages=%s", package_config_override_);
697+
argv_[idx++] = StringUtilsWin::ArgumentEscape(packages_arg);
698+
free(packages_arg);
699+
#else
700+
argv_[idx++] = Utils::SCreate("--packages=%s", package_config_override_);
701+
#endif
702+
}
690703
// Copy in name of the script to run.
691704
argv_[idx++] = Utils::StrDup(GetArrayItem(message, 1)->value.as_string);
692705
// Copy in the dart options that need to be passed to the script.

0 commit comments

Comments
 (0)