Issue #1094: Runtime executable mode checks moved to Utils/Expect, Language/Libraries_and_Scripts/Scripts, LibTest/io/Process tests corrected.
diff --git a/Language/Libraries_and_Scripts/Scripts/top_level_main_t01.dart b/Language/Libraries_and_Scripts/Scripts/top_level_main_t01.dart
index bf059ef..fc26d1f 100644
--- a/Language/Libraries_and_Scripts/Scripts/top_level_main_t01.dart
+++ b/Language/Libraries_and_Scripts/Scripts/top_level_main_t01.dart
@@ -10,12 +10,13 @@
// OtherResources=top_level_main_t01_lib.dart
import "../../../Utils/expect.dart";
+import "../../../Utils/test_mode_check.dart";
import "dart:io";
run_main() async {
String executable = Platform.resolvedExecutable;
String eScript = Platform.script.toString().replaceAll(".dart", "_lib.dart");
- if (!executable.endsWith(Platform.pathSeparator + "dart")) {
+ if (isAOT) {
// This is the case of AOT configuration
executable = executable.replaceRange(
executable.lastIndexOf(Platform.pathSeparator) + 1, null, "dart");
diff --git a/Language/Libraries_and_Scripts/Scripts/top_level_main_t06.dart b/Language/Libraries_and_Scripts/Scripts/top_level_main_t06.dart
index 9ce3fdf..689e9c2 100644
--- a/Language/Libraries_and_Scripts/Scripts/top_level_main_t06.dart
+++ b/Language/Libraries_and_Scripts/Scripts/top_level_main_t06.dart
@@ -10,12 +10,13 @@
// OtherResources=top_level_main_t06_lib.dart
import "../../../Utils/expect.dart";
+import "../../../Utils/test_mode_check.dart";
import "dart:io";
run_main() async {
String executable = Platform.resolvedExecutable;
String eScript = Platform.script.toString().replaceAll(".dart", "_lib.dart");
- if (!executable.endsWith(Platform.pathSeparator + "dart")) {
+ if (isAOT) {
// This is the case of AOT configuration
executable = executable.replaceRange(
executable.lastIndexOf(Platform.pathSeparator) + 1, null, "dart");
diff --git a/LibTest/io/Process/run_A01_t03.dart b/LibTest/io/Process/run_A01_t03.dart
index b185058..4e96de8 100644
--- a/LibTest/io/Process/run_A01_t03.dart
+++ b/LibTest/io/Process/run_A01_t03.dart
@@ -36,14 +36,7 @@
import "dart:io";
import "../../../Utils/expect.dart";
-
-bool get isDartkp {
- var parts = Uri.file(Platform.resolvedExecutable).pathSegments;
- String basename = parts[parts.length - 1];
- var pos = basename.lastIndexOf('.');
- String result = (pos != -1) ? basename.substring(0, pos) : basename;
- return result == "dart_precompiled_runtime";
-}
+import "../../../Utils/test_mode_check.dart";
main() {
String executable = Platform.resolvedExecutable;
diff --git a/Utils/test_mode_check.dart b/Utils/test_mode_check.dart
new file mode 100644
index 0000000..a4ce513
--- /dev/null
+++ b/Utils/test_mode_check.dart
@@ -0,0 +1,22 @@
+// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library test_mode_check;
+import "dart:io";
+
+typedef check = bool Function(String);
+
+bool checkMode(check ret) {
+ var parts = Uri.file(Platform.resolvedExecutable).pathSegments;
+ String basename = parts[parts.length - 1];
+ var pos = basename.lastIndexOf('.');
+ String result = (pos != -1) ? basename.substring(0, pos) : basename;
+ return ret(result);
+}
+
+// Checks that application runs in dart precompiled runtime mode.
+bool get isDartkp => checkMode(((String s) => s == "dart_precompiled_runtime"));
+
+// Checks that application runs in AOT mode.
+bool get isAOT => checkMode(((String s) => s != "dart"));