Index: runtime/vm/unit_test.cc |
diff --git a/runtime/vm/unit_test.cc b/runtime/vm/unit_test.cc |
index 1cb7ccf98f4d9aca476f68ce1e42fdad463d100f..672215112e79654058948352b5e7d3634159fcdb 100644 |
--- a/runtime/vm/unit_test.cc |
+++ b/runtime/vm/unit_test.cc |
@@ -48,6 +48,23 @@ void TestCaseBase::RunAll() { |
} |
} |
+static const char* kPackageScheme = "package:"; |
+ |
+static bool IsPackageSchemeURL(const char* url_name) { |
+ static const intptr_t kPackageSchemeLen = strlen(kPackageScheme); |
+ return (strncmp(url_name, kPackageScheme, kPackageSchemeLen) == 0); |
+} |
+ |
+static Dart_Handle ResolvePackageUri(Dart_Handle builtin_lib, |
+ const char* uri_chars) { |
+ const int kNumArgs = 1; |
+ Dart_Handle dart_args[kNumArgs]; |
+ dart_args[0] = DartUtils::NewString(uri_chars); |
+ return Dart_Invoke(builtin_lib, |
+ DartUtils::NewString("_filePathFromUri"), |
+ kNumArgs, |
+ dart_args); |
+} |
static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag, |
Dart_Handle library, |
@@ -108,6 +125,15 @@ static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag, |
url_chars), |
0, 0); |
} |
+ if (IsPackageSchemeURL(url_chars)) { |
+ Dart_Handle resolved_uri = ResolvePackageUri(builtin_lib, url_chars); |
+ DART_CHECK_VALID(resolved_uri); |
+ url_chars = NULL; |
+ Dart_Handle result = Dart_StringToCString(resolved_uri, &url_chars); |
+ if (Dart_IsError(result)) { |
+ return Dart_NewApiError("accessing url characters failed"); |
+ } |
+ } |
// Do sync loading since unit_test doesn't support async. |
Dart_Handle source = DartUtils::ReadStringFromFile(url_chars); |
EXPECT_VALID(source); |