Version 2.13.0-190.0.dev

Merge commit 'e70690e4159169a70810f2c4cad6011a4ec60fba' into 'dev'
diff --git a/runtime/bin/loader.cc b/runtime/bin/loader.cc
index e855baf..df166696 100644
--- a/runtime/bin/loader.cc
+++ b/runtime/bin/loader.cc
@@ -79,7 +79,8 @@
 
   char* lib_path = NULL;
   if (strncmp(lib_uri_str, "file://", 7) == 0) {
-    lib_path = DartUtils::DirName(lib_uri_str + 7);
+    auto path = File::UriToPath(lib_uri_str);
+    lib_path = DartUtils::DirName(path.get());
   } else {
     lib_path = Utils::StrDup(lib_uri_str);
   }
@@ -125,7 +126,8 @@
 
     char* lib_path = NULL;
     if (strncmp(lib_uri, "file://", 7) == 0) {
-      lib_path = DartUtils::DirName(DartUtils::RemoveScheme(lib_uri));
+      auto path = File::UriToPath(lib_uri);
+      lib_path = DartUtils::DirName(path.get());
     } else {
       lib_path = Utils::StrDup(lib_uri);
     }
diff --git a/samples/sample_extension/test/sample_extension_test_helper.dart b/samples/sample_extension/test/sample_extension_test_helper.dart
index d4cae3d..a4a78ce 100644
--- a/samples/sample_extension/test/sample_extension_test_helper.dart
+++ b/samples/sample_extension/test/sample_extension_test_helper.dart
@@ -44,6 +44,30 @@
   }
 }
 
+Future runTests(
+    String program, String testDirectory, String? snapshotKind) async {
+  for (var test in [
+    'test_sample_synchronous_extension.dart',
+    'test_sample_asynchronous_extension.dart'
+  ]) {
+    String script = join(testDirectory, test);
+    String snapshot;
+    if (snapshotKind == null) {
+      snapshot = script;
+    } else {
+      snapshot = join(testDirectory, "$test.snapshot");
+      await run(Platform.executable, <String>[
+        ...Platform.executableArguments,
+        '--snapshot=$snapshot',
+        '--snapshot-kind=$snapshotKind',
+        script
+      ]);
+    }
+
+    await run(program, <String>[...Platform.executableArguments, snapshot]);
+  }
+}
+
 Future testNativeExtensions(String? snapshotKind) async {
   String buildDirectory = dirname(Platform.executable);
   Directory tempDirectory =
@@ -63,27 +87,27 @@
       await copyFileToDirectory(join(sourceDirectory, file), testDirectory);
     }
 
-    for (var test in [
-      'test_sample_synchronous_extension.dart',
-      'test_sample_asynchronous_extension.dart'
-    ]) {
-      String script = join(testDirectory, test);
-      String snapshot;
-      if (snapshotKind == null) {
-        snapshot = script;
-      } else {
-        snapshot = join(testDirectory, "$test.snapshot");
-        List<String> args = new List<String>.from(Platform.executableArguments);
-        args.add('--snapshot=$snapshot');
-        args.add('--snapshot-kind=$snapshotKind');
-        args.add(script);
-        await run(Platform.executable, args);
-      }
+    // Test native library resolution when it's next to the binary
+    await runTests(Platform.executable, testDirectory, snapshotKind);
 
-      List<String> args = new List<String>.from(Platform.executableArguments);
-      args.add(snapshot);
-      await run(Platform.executable, args);
-    }
+    // Test native library resolution when it's next to the source
+    await copyFileToDirectory(
+        join(
+            buildDirectory,
+            (Platform.isWindows ? '' : 'lib') +
+                'sample_extension' +
+                (Platform.isWindows
+                    ? '.dll'
+                    : Platform.isMacOS
+                        ? '.dylib'
+                        : '.so')),
+        testDirectory);
+    Directory tempBinDirectory = Directory(join(tempDirectory.path, 'dart-bin'))
+      ..createSync();
+    await copyFileToDirectory(Platform.executable, tempBinDirectory.path);
+    String copyPlatformExecutable =
+        join(tempBinDirectory.path, basename(Platform.executable));
+    await runTests(copyPlatformExecutable, testDirectory, snapshotKind);
   } finally {
     tempDirectory.deleteSync(recursive: true);
   }
diff --git a/samples_2/sample_extension/test/sample_extension_test_helper.dart b/samples_2/sample_extension/test/sample_extension_test_helper.dart
index 9c701bf..cabbb28 100644
--- a/samples_2/sample_extension/test/sample_extension_test_helper.dart
+++ b/samples_2/sample_extension/test/sample_extension_test_helper.dart
@@ -26,7 +26,7 @@
       result = await Process.run('cmd.exe', ['/C', 'copy $src $dst']);
       break;
     default:
-      Expect.fail('Unknown operating system ${Platform.operatingSystem}');
+      throw 'Unknown operating system ${Platform.operatingSystem}';
   }
   if (result.exitCode != 0) {
     print(result.stdout);
@@ -46,6 +46,30 @@
   }
 }
 
+Future runTests(
+    String program, String testDirectory, String snapshotKind) async {
+  for (var test in [
+    'test_sample_synchronous_extension.dart',
+    'test_sample_asynchronous_extension.dart'
+  ]) {
+    String script = join(testDirectory, test);
+    String snapshot;
+    if (snapshotKind == null) {
+      snapshot = script;
+    } else {
+      snapshot = join(testDirectory, "$test.snapshot");
+      await run(Platform.executable, <String>[
+        ...Platform.executableArguments,
+        '--snapshot=$snapshot',
+        '--snapshot-kind=$snapshotKind',
+        script
+      ]);
+    }
+
+    await run(program, <String>[...Platform.executableArguments, snapshot]);
+  }
+}
+
 Future testNativeExtensions(String snapshotKind) async {
   String buildDirectory = dirname(Platform.executable);
   Directory tempDirectory =
@@ -65,27 +89,27 @@
       await copyFileToDirectory(join(sourceDirectory, file), testDirectory);
     }
 
-    for (var test in [
-      'test_sample_synchronous_extension.dart',
-      'test_sample_asynchronous_extension.dart'
-    ]) {
-      String script = join(testDirectory, test);
-      String snapshot;
-      if (snapshotKind == null) {
-        snapshot = script;
-      } else {
-        snapshot = join(testDirectory, "$test.snapshot");
-        List<String> args = new List<String>.from(Platform.executableArguments);
-        args.add('--snapshot=$snapshot');
-        args.add('--snapshot-kind=$snapshotKind');
-        args.add(script);
-        await run(Platform.executable, args);
-      }
+    // Test native library resolution when it's next to the binary
+    await runTests(Platform.executable, testDirectory, snapshotKind);
 
-      List<String> args = new List<String>.from(Platform.executableArguments);
-      args.add(snapshot);
-      await run(Platform.executable, args);
-    }
+    // Test native library resolution when it's next to the source
+    await copyFileToDirectory(
+        join(
+            buildDirectory,
+            (Platform.isWindows ? '' : 'lib') +
+                'sample_extension' +
+                (Platform.isWindows
+                    ? '.dll'
+                    : Platform.isMacOS
+                        ? '.dylib'
+                        : '.so')),
+        testDirectory);
+    Directory tempBinDirectory = Directory(join(tempDirectory.path, 'dart-bin'))
+      ..createSync();
+    await copyFileToDirectory(Platform.executable, tempBinDirectory.path);
+    String copyPlatformExecutable =
+        join(tempBinDirectory.path, basename(Platform.executable));
+    await runTests(copyPlatformExecutable, testDirectory, snapshotKind);
   } finally {
     tempDirectory.deleteSync(recursive: true);
   }
diff --git a/tools/VERSION b/tools/VERSION
index 27132aa..7d7fd15 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 13
 PATCH 0
-PRERELEASE 189
+PRERELEASE 190
 PRERELEASE_PATCH 0
\ No newline at end of file