Restructure android test module, update dependencies
This commit is contained in:
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.jetbrains.kotlin.android.tests"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
<application>
|
||||
<uses-library android:name="android.test.runner" />
|
||||
</application>
|
||||
<!--
|
||||
This declares that this application uses the instrumentation test runner targeting
|
||||
the package of com.example. To execute the tests use the command:
|
||||
"adb shell am instrument -w com.example.tests/android.test.InstrumentationTestRunner"
|
||||
-->
|
||||
<instrumentation android:name="android.test.InstrumentationTestRunner"
|
||||
android:targetPackage="org.jetbrains.kotlin.android.tests"
|
||||
android:label="Tests for org.jetbrains.kotlin.android.tests"/>
|
||||
</manifest>
|
||||
@@ -7,7 +7,7 @@ buildscript {
|
||||
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.0.1'
|
||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
@@ -22,7 +22,7 @@ repositories {
|
||||
|
||||
android {
|
||||
compileSdkVersion 19
|
||||
buildToolsVersion "27.0.3"
|
||||
buildToolsVersion "28.0.3"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "org.jetbrains.kotlin.android.tests"
|
||||
@@ -31,7 +31,7 @@ android {
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
testApplicationId "org.jetbrains.kotlin.android.tests.gradle"
|
||||
testInstrumentationRunner "android.test.InstrumentationTestRunner"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
multiDexEnabled true
|
||||
}
|
||||
buildTypes {
|
||||
@@ -41,20 +41,6 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
manifest.srcFile 'AndroidManifest.xml'
|
||||
java {
|
||||
srcDirs = ['src']
|
||||
}
|
||||
res.srcDirs = ['res']
|
||||
}
|
||||
androidTest {
|
||||
java {
|
||||
srcDirs = ['src']
|
||||
}
|
||||
}
|
||||
}
|
||||
packagingOptions { exclude 'META-INF/build.txt' }
|
||||
|
||||
//TODO run under java 6, cause there is error on implicit 'stream' import in 'asWithMutable' test
|
||||
@@ -72,6 +58,11 @@ android {
|
||||
maxProcessCount 4
|
||||
additionalParameters "--debug"
|
||||
}
|
||||
|
||||
testOptions {
|
||||
resultsDir = "build/test/results"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
task jarTestFolders() {
|
||||
@@ -89,7 +80,8 @@ tasks.withType(JavaCompile) {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
androidTestCompile 'junit:junit:4.12'
|
||||
compile 'com.android.support:multidex:1.0.1'
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
androidTestImplementation 'junit:junit:4.12'
|
||||
implementation 'com.android.support:multidex:1.0.3'
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#don't try to download android specific tools within gradle: licence acceptance will be required
|
||||
android.builder.sdkDownload=false
|
||||
android.enableAapt2=false
|
||||
android.enableD8=false
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.jetbrains.kotlin.android.tests"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
<application>
|
||||
<uses-library android:name="android.test.runner" />
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="">
|
||||
<application>
|
||||
</application>
|
||||
</manifest>
|
||||
+11
-5
@@ -54,6 +54,7 @@ class CodegenTestsOnAndroidRunner private constructor(private val pathManager: P
|
||||
rootSuite.addTest(this)
|
||||
}
|
||||
|
||||
renameReport()
|
||||
enableD8(true)
|
||||
runTestsOnEmulator(gradleRunner, TestSuite("D8")).apply {
|
||||
(0 until this.countTestCases()).forEach {
|
||||
@@ -94,18 +95,23 @@ class CodegenTestsOnAndroidRunner private constructor(private val pathManager: P
|
||||
}
|
||||
|
||||
private fun processReport(suite: TestSuite, resultOutput: String) {
|
||||
val reportFolder = pathManager.tmpFolder + "/build/outputs/androidTest-results/connected"
|
||||
val reportFolder = reportFolder()
|
||||
try {
|
||||
val testCases = parseSingleReportInFolder(reportFolder)
|
||||
testCases.forEach { aCase -> suite.addTest(aCase) }
|
||||
Assert.assertNotEquals("There is no test results in report", 0, testCases.size.toLong())
|
||||
} catch (e: Exception) {
|
||||
throw RuntimeException("Can't parse test results in $reportFolder\n$resultOutput", e)
|
||||
}
|
||||
catch (e: Exception) {
|
||||
throw RuntimeException("Can't parse test results in " + reportFolder + "\n" + resultOutput)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun renameReport() {
|
||||
val reportFolder = File(reportFolder())
|
||||
reportFolder.renameTo(File(reportFolder.parentFile, reportFolder.name + "_dex"))
|
||||
}
|
||||
|
||||
private fun reportFolder() = pathManager.tmpFolder + "/build/test/results/connected/"
|
||||
|
||||
private fun runTestsOnEmulator(gradleRunner: GradleRunner, suite: TestSuite): TestSuite {
|
||||
val platformPrefixProperty = System.setProperty(PlatformUtils.PLATFORM_PREFIX_KEY, "Idea")
|
||||
try {
|
||||
|
||||
+5
-5
@@ -38,11 +38,11 @@ public class SDKDownloader {
|
||||
|
||||
private final PathManager pathManager;
|
||||
|
||||
private static final String PLATFORM_TOOLS = "27.0.1";
|
||||
private static final String SDK_TOOLS = "25.1.6";
|
||||
public static final String BUILD_TOOLS = "27.0.3";
|
||||
private static final String PLATFORM_TOOLS = "28.0.1";
|
||||
private static final String SDK_TOOLS = "25.2.5";
|
||||
public static final String BUILD_TOOLS = "28.0.3";
|
||||
private static final int ANDROID_VERSION = 19;
|
||||
public static final String GRADLE_VERSION = "4.5.1";
|
||||
public static final String GRADLE_VERSION = "4.6";
|
||||
|
||||
|
||||
public SDKDownloader(PathManager pathManager) {
|
||||
@@ -126,7 +126,7 @@ public class SDKDownloader {
|
||||
String buildToolsFolder = buildTools + BUILD_TOOLS + "/";
|
||||
new File(buildToolsFolder).delete();
|
||||
unzip(buildToolsZipPath, buildTools);
|
||||
new File(buildTools + "/android-8.1.0").renameTo(new File(buildToolsFolder));
|
||||
new File(buildTools + "/android-9").renameTo(new File(buildToolsFolder));
|
||||
}
|
||||
|
||||
public void deleteAll() {
|
||||
|
||||
+6
-2
@@ -49,6 +49,7 @@ public class GradleRunner {
|
||||
System.out.println("Building gradle project...");
|
||||
GeneralCommandLine build = generateCommandLine("build");
|
||||
build.addParameter("--stacktrace");
|
||||
build.addParameter("--warn");
|
||||
RunResult result = RunUtils.execute(build);
|
||||
OutputUtils.checkResult(result);
|
||||
}
|
||||
@@ -67,8 +68,11 @@ public class GradleRunner {
|
||||
|
||||
public String connectedDebugAndroidTest() {
|
||||
System.out.println("Starting tests...");
|
||||
RunResult result = RunUtils.execute(generateCommandLine("connectedAndroidTest"));
|
||||
return result.getOutput();
|
||||
GeneralCommandLine test = generateCommandLine("connectedAndroidTest");
|
||||
test.addParameters("--stacktrace");
|
||||
//To avoid problem with discovering tests on Android in multidex build
|
||||
test.addParameters("-Pandroid.testInstrumentationRunnerArguments.class=org.jetbrains.kotlin.android.tests.CodegenTestCaseOnAndroid");
|
||||
return RunUtils.execute(test).getOutput();
|
||||
}
|
||||
|
||||
private GeneralCommandLine generateCommandLine(String taskName) {
|
||||
|
||||
+2
-2
@@ -76,9 +76,9 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
|
||||
private fun generateAndSave() {
|
||||
println("Generating test files...")
|
||||
val testSourceFilePath =
|
||||
pathManager.srcFolderInAndroidTmpFolder + "/" + testClassPackage.replace(".", "/") + "/" + testClassName + ".java"
|
||||
pathManager.srcFolderInAndroidTmpFolder + "/androidTest/java/" + testClassPackage.replace(".", "/") + "/" + testClassName + ".java"
|
||||
|
||||
FileWriter(File(testSourceFilePath)).use {
|
||||
FileWriter(File(testSourceFilePath).also { it.parentFile.mkdirs() }).use {
|
||||
val p = Printer(it)
|
||||
p.print(FileUtil.loadFile(File("license/LICENSE.txt")))
|
||||
p.println(
|
||||
|
||||
Reference in New Issue
Block a user