forked from square/okio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is currently completely manual. In a follow-up it would be nice to get this running in CI. On a Pixel 3A emulator running Android 30 I observed test crashes in the following tests: selectSpanningMultipleSegments readLargeNioBufferOnlyReadsOneSegment gzipSink gzipSource I needed to rename BufferedSourceTest to BufferedSourceJavaTest, and similarly for BufferedSinkJavaTest and ByteStringJavaTest. We were seeing simple name collisions in these tests which I believe were previously preventing these tests from being executed.
- Loading branch information
1 parent
137d44f
commit f14edb7
Showing
18 changed files
with
165 additions
and
19 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
Android Test | ||
============ | ||
|
||
This module runs Okio's test suite on a connected Android emulator or device. It requires the same | ||
set-up as [OkHttp's android-test module][okhttp_android_test]. | ||
|
||
In brief, configure the Android SDK and PATH: | ||
|
||
``` | ||
export ANDROID_SDK_ROOT=/Users/$USER/Library/Android/sdk | ||
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin:$ANDROID_SDK_ROOT/platform-tools | ||
``` | ||
|
||
Use `logcat` to stream test logs: | ||
|
||
``` | ||
adb logcat '*:E' TestRunner:D TaskRunner:D GnssHAL_GnssInterface:F DeviceStateChecker:F memtrack:F | ||
``` | ||
|
||
Then run the tests: | ||
|
||
``` | ||
./gradlew :android-test:connectedCheck | ||
``` | ||
|
||
|
||
### Watch Out For Crashing Failures | ||
|
||
Some of Okio's tests can cause the test process to crash. The test will be reported as a failure | ||
with a message like this: | ||
|
||
> Test failed to run to completion. Reason: 'Instrumentation run failed due to 'Process crashed.''. | ||
> Check device logcat for details | ||
When this happens, it's possible that tests are missing from the test run! One workaround is to | ||
exclude the crashing test and re-run the rest. You can confirm that the test run completed normally | ||
if a `run finished` line is printed in the logcat logs: | ||
|
||
``` | ||
01-01 00:00:00.000 12345 23456 I TestRunner: run finished: 2976 tests, 0 failed, 3 ignored | ||
``` | ||
|
||
|
||
[okhttp_android_test]: https://github.com/square/okhttp/tree/master/android-test |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
apply plugin: 'com.android.library' | ||
apply plugin: 'org.jetbrains.kotlin.android' | ||
|
||
buildscript { | ||
repositories { | ||
mavenCentral() | ||
gradlePluginPortal() | ||
google() | ||
} | ||
} | ||
|
||
def isIDE = properties.containsKey('android.injected.invoked.from.ide') || | ||
(System.getenv("XPC_SERVICE_NAME") ?: "").contains("intellij") || | ||
System.getenv("IDEA_INITIAL_DIRECTORY") != null | ||
|
||
android { | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_7 | ||
targetCompatibility JavaVersion.VERSION_1_7 | ||
} | ||
|
||
kotlinOptions { | ||
freeCompilerArgs += "-Xmulti-platform" | ||
} | ||
|
||
compileSdkVersion 30 | ||
|
||
defaultConfig { | ||
minSdkVersion 15 | ||
targetSdkVersion 30 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
if (!isIDE) { | ||
sourceSets { | ||
named("androidTest") { | ||
it.java.srcDirs += [ | ||
project.file("../okio-testing/src/commonMain/kotlin"), | ||
project.file("../okio/src/commonMain/kotlin"), | ||
project.file("../okio/src/commonTest/java"), | ||
project.file("../okio/src/commonTest/kotlin"), | ||
project.file("../okio/src/hashFunctions/kotlin"), | ||
project.file("../okio/src/jvmMain/kotlin"), | ||
project.file("../okio/src/jvmTest/java"), | ||
project.file("../okio/src/jvmTest/kotlin"), | ||
] | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
dependencies { | ||
androidTestImplementation deps.androidx.testExtJunit | ||
androidTestImplementation deps.androidx.testRunner | ||
androidTestImplementation deps.animalSniffer.annotations | ||
androidTestImplementation deps.kotlin.stdLib.common | ||
androidTestImplementation deps.kotlin.test.annotations | ||
androidTestImplementation deps.kotlin.test.common | ||
androidTestImplementation deps.kotlin.test.jdk | ||
androidTestImplementation deps.kotlin.time | ||
androidTestImplementation deps.test.assertj | ||
androidTestImplementation deps.test.junit | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="okio.android.test"> | ||
<application | ||
android:usesCleartextTraffic="true" /> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
</manifest> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<resources> | ||
<string name="app_name">android-test</string> | ||
</resources> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<network-security-config> | ||
<base-config cleartextTrafficPermitted="false"> | ||
</base-config> | ||
</network-security-config> |
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
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
File renamed without changes.
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
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
rootProject.name = 'okio-parent' | ||
|
||
include ':okio' | ||
include ':okio-testing' | ||
include ':okio:jvm:japicmp' | ||
include ':okio:jvm:jmh' | ||
include ':samples' | ||
|
||
enableFeaturePreview("GRADLE_METADATA") | ||
|
||
// The Android test module doesn't work in IntelliJ. Use Android Studio or the command line. | ||
if (properties.containsKey('android.injected.invoked.from.ide') || | ||
System.getenv('ANDROID_SDK_ROOT') != null) { | ||
include ':android-test' | ||
} |