Skip to content

Commit 0e402bc

Browse files
authored
Update Android instrumentation runner to be closer to upstream (#43775)
The upstream instrumentation runners don't use runOnMainSync() in the onStart() method, update our runner to do the same and add a bit more logging. Also fixed a small typo in configure.cmake that I happened to notice.
1 parent 0d4448a commit 0e402bc

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

src/libraries/Native/Unix/configure.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ check_c_source_compiles(
684684
HAVE_MKSTEMP)
685685

686686
if (NOT HAVE_MKSTEMPS AND NOT HAVE_MKSTEMP)
687-
message(FATAL_ERROR "Cannot find mkstemp nor mkstemp on this platform.")
687+
message(FATAL_ERROR "Cannot find mkstemps nor mkstemp on this platform.")
688688
endif()
689689

690690
check_c_source_compiles(

tools-local/tasks/mobile.tasks/AndroidAppBuilder/Templates/MonoRunner.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import android.content.pm.PackageManager;
1010
import android.content.res.AssetManager;
1111
import android.os.Bundle;
12+
import android.os.Looper;
1213
import android.util.Log;
1314
import android.view.View;
1415
import android.app.Activity;
@@ -32,6 +33,7 @@ public class MonoRunner extends Instrumentation
3233
}
3334

3435
static String entryPointLibName = "%EntryPointLibName%";
36+
static Bundle result = new Bundle();
3537

3638
@Override
3739
public void onCreate(Bundle arguments) {
@@ -62,33 +64,32 @@ public static int initialize(String entryPointLibName, Context context) {
6264
// unzip libs and test files to filesDir
6365
unzipAssets(context, filesDir, "assets.zip");
6466

65-
Log.i("DOTNET", "initRuntime, entryPointLibName=" + entryPointLibName);
67+
Log.i("DOTNET", "MonoRunner initialize, entryPointLibName=" + entryPointLibName);
6668
return initRuntime(filesDir, cacheDir, docsDir, entryPointLibName);
6769
}
6870

6971
@Override
7072
public void onStart() {
71-
super.onStart();
73+
Looper.prepare();
7274

7375
if (entryPointLibName == "") {
7476
Log.e("DOTNET", "Missing entryPointLibName argument, pass '-e entryPointLibName <name.dll>' to adb to specify which program to run.");
7577
finish(1, null);
7678
return;
7779
}
7880
int retcode = initialize(entryPointLibName, getContext());
79-
runOnMainSync(new Runnable() {
80-
public void run() {
81-
Bundle result = new Bundle();
82-
result.putInt("return-code", retcode);
83-
84-
// Xharness cli expects "test-results-path" with test results
85-
File testResults = new File(getDocsDir(getContext()) + "/testResults.xml");
86-
if (testResults.exists()) {
87-
result.putString("test-results-path", testResults.getAbsolutePath());
88-
}
89-
finish(retcode, result);
90-
}
91-
});
81+
82+
Log.i("DOTNET", "MonoRunner finished, return-code=" + retcode);
83+
result.putInt("return-code", retcode);
84+
85+
// Xharness cli expects "test-results-path" with test results
86+
File testResults = new File(getDocsDir(getContext()) + "/testResults.xml");
87+
if (testResults.exists()) {
88+
Log.i("DOTNET", "MonoRunner finished, test-results-path=" + testResults.getAbsolutePath());
89+
result.putString("test-results-path", testResults.getAbsolutePath());
90+
}
91+
92+
finish(retcode, result);
9293
}
9394

9495
static void unzipAssets(Context context, String toPath, String zipName) {

0 commit comments

Comments
 (0)