Last active
July 14, 2017 09:38
-
-
Save joakim-noah/348edc378d47fb90e32708be19286a2e to your computer and use it in GitHub Desktop.
Android/ARM support for druntime, for ldc release-1.3.x branch 2.073
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/test_runner.d b/src/test_runner.d | |
index 0fddcc22..18684a10 100644 | |
--- a/src/test_runner.d | |
+++ b/src/test_runner.d | |
@@ -1,7 +1,11 @@ | |
+module test_runner; | |
import core.runtime, core.time : MonoTime; | |
import core.stdc.stdio; | |
+version(apk) import android.log, std.file: append; | |
+import std.stdio: File; | |
+import std.file: exists, isFile; | |
-ModuleInfo* getModuleInfo(string name) | |
+ModuleInfo* getModuleInfo(char[] name) | |
{ | |
foreach (m; ModuleInfo) | |
if (m.name == name) return m; | |
@@ -10,7 +14,8 @@ ModuleInfo* getModuleInfo(string name) | |
bool tester() | |
{ | |
- return Runtime.args.length > 1 ? testModules() : testAll(); | |
+ //return Runtime.args.length > 1 ? testModules() : testAll(); | |
+ return testModules(); | |
} | |
string mode; | |
@@ -18,8 +23,14 @@ string mode; | |
bool testModules() | |
{ | |
+ string testList = "test.list"; | |
+ if(!testList.exists() || !testList.isFile) { | |
+ testList = "/sdcard/" ~ testList; | |
+ if(!testList.exists() || !testList.isFile) | |
+ return false; | |
+ } | |
bool ret = true; | |
- foreach(name; Runtime.args[1..$]) | |
+ foreach(name; File(testList).byLine()) | |
{ | |
immutable pkg = ".package"; | |
immutable pkgLen = pkg.length; | |
@@ -50,24 +61,39 @@ void doTest(ModuleInfo* moduleInfo, ref bool ret) | |
if (auto fp = moduleInfo.unitTest) | |
{ | |
auto name = moduleInfo.name; | |
+ version(apk) string output; | |
try | |
{ | |
immutable t0 = MonoTime.currTime; | |
fp(); | |
+ version(apk) { | |
+ char[11] time; | |
+ int timelen = snprintf(time.ptr, 11, "%.3f", (MonoTime.currTime - t0).total!"msecs" / 1000.0); | |
+ output ~= time[0 .. timelen] ~ "s PASS " ~ name ~ "\n"; | |
+ } else { | |
printf("%.3fs PASS %.*s %.*s\n", | |
(MonoTime.currTime - t0).total!"msecs" / 1000.0, | |
cast(uint)mode.length, mode.ptr, | |
cast(uint)name.length, name.ptr); | |
+ } | |
} | |
catch (Throwable e) | |
{ | |
auto msg = e.toString(); | |
+ version(apk) | |
+ output ~= "****** FAIL " ~ name ~ "\n" ~ msg ~ "\n"; | |
+ else { | |
printf("****** FAIL %.*s %.*s\n%.*s\n", | |
cast(uint)mode.length, mode.ptr, | |
cast(uint)name.length, name.ptr, | |
cast(uint)msg.length, msg.ptr); | |
- ret = false; | |
+ //ret = false; | |
+ } | |
} | |
+ version(apk){ | |
+ __android_log_print(android_LogPriority.ANDROID_LOG_INFO, "test_runner", output.ptr); | |
+ append("/sdcard/test.log", output); | |
+ } | |
} | |
} | |
@@ -88,6 +114,6 @@ shared static this() | |
else static assert(0, "You must be from the future!"); | |
} | |
-void main() | |
+version(apk) {} else void main() | |
{ | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment