-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If an artifact that completely matches the attributes is not found in the dependency, then a random artifact is taken, the processing of which can lead to unpredictable errors. An additional check of the dependency resolution is needed to exclude such a situation. Fixes #478
- Loading branch information
Showing
33 changed files
with
534 additions
and
2 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...ctionalTest/kotlin/kotlinx/kover/gradle/plugin/test/functional/cases/NoDependencyTests.kt
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,39 @@ | ||
package kotlinx.kover.gradle.plugin.test.functional.cases | ||
|
||
import kotlinx.kover.gradle.plugin.test.functional.framework.runner.buildFromTemplate | ||
import kotlinx.kover.gradle.plugin.test.functional.framework.runner.runWithParams | ||
import org.junit.jupiter.api.Test | ||
import kotlin.test.assertContains | ||
import kotlin.test.assertFalse | ||
|
||
/** | ||
* Tests on dependency check https://github.com/Kotlin/kotlinx-kover/issues/478. | ||
*/ | ||
class NoDependencyTests { | ||
@Test | ||
fun testJvmNotApplied() { | ||
val buildSource = buildFromTemplate("no-dependency-jvm") | ||
val build = buildSource.generate() | ||
val buildResult = build.runWithParams( "koverHtmlReport") | ||
assertFalse(buildResult.isSuccessful) | ||
assertContains(buildResult.output, "Kover plugin is not applied") | ||
} | ||
|
||
@Test | ||
fun testAndroidNotApplied() { | ||
val buildSource = buildFromTemplate("no-dependency-android") | ||
val build = buildSource.generate() | ||
val buildResult = build.runWithParams( ":app:koverHtmlReportDebug") | ||
assertFalse(buildResult.isSuccessful) | ||
assertContains(buildResult.output, "Kover plugin is not applied") | ||
} | ||
|
||
@Test | ||
fun testAndroidNoVariant() { | ||
val buildSource = buildFromTemplate("no-dependency-variant-android") | ||
val build = buildSource.generate() | ||
val buildResult = build.runWithParams( ":app-extra:koverHtmlReportExtra") | ||
assertFalse(buildResult.isSuccessful) | ||
assertContains(buildResult.output, "Kover android variant 'extra' was not matched with any variant from dependency") | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...dle-plugin/src/functionalTest/templates/builds/no-dependency-android/app/build.gradle.kts
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,47 @@ | ||
plugins { | ||
id ("org.jetbrains.kotlinx.kover") | ||
id ("com.android.application") | ||
id ("org.jetbrains.kotlin.android") | ||
} | ||
|
||
android { | ||
namespace = "kotlinx.kover.test.android" | ||
compileSdk = 32 | ||
|
||
defaultConfig { | ||
applicationId = "kotlinx.kover.test.android" | ||
minSdk = 21 | ||
targetSdk = 31 | ||
versionCode = 1 | ||
versionName = "1.0" | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = true | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
buildFeatures { | ||
viewBinding = true | ||
} | ||
} | ||
|
||
dependencies { | ||
// error dependency | ||
kover(project(":subproject")) | ||
|
||
implementation("androidx.core:core-ktx:1.8.0") | ||
implementation("androidx.appcompat:appcompat:1.5.0") | ||
implementation("com.google.android.material:material:1.6.1") | ||
implementation("androidx.constraintlayout:constraintlayout:2.1.4") | ||
testImplementation("junit:junit:4.13.2") | ||
} |
24 changes: 24 additions & 0 deletions
24
...rc/functionalTest/templates/builds/no-dependency-android/app/src/main/AndroidManifest.xml
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,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<application android:label="@string/app_name"> | ||
<uses-library android:name="com.google.android.things" android:required="false" /> | ||
|
||
<activity android:name=".MainActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
<!-- Make this the first activity that is displayed when the device boots. --> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.HOME" /> | ||
<category android:name="android.intent.category.DEFAULT" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
7 changes: 7 additions & 0 deletions
7
...es/builds/no-dependency-android/app/src/main/java/kotlinx/kover/test/android/DebugUtil.kt
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,7 @@ | ||
package kotlinx.kover.test.android | ||
|
||
object DebugUtil { | ||
fun log(message: String) { | ||
println("DEBUG: $message") | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...builds/no-dependency-android/app/src/main/java/kotlinx/kover/test/android/MainActivity.kt
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,13 @@ | ||
package kotlinx.kover.test.android | ||
|
||
import android.os.Bundle | ||
import android.app.Activity | ||
|
||
class MainActivity : Activity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
...plates/builds/no-dependency-android/app/src/main/java/kotlinx/kover/test/android/Maths.kt
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,13 @@ | ||
package kotlinx.kover.test.android | ||
|
||
object Maths { | ||
fun sum(a: Int, b: Int): Int { | ||
DebugUtil.log("invoked sum") | ||
return a + b | ||
} | ||
|
||
fun sub(a: Int, b: Int): Int { | ||
DebugUtil.log("invoked sub") | ||
return a - b | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...onalTest/templates/builds/no-dependency-android/app/src/main/res/layout/activity_main.xml
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,36 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".MainActivity"> | ||
|
||
<TextView | ||
android:id="@+id/main_label" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="104dp" | ||
android:layout_marginTop="28dp" | ||
android:text="SERIALIZATION TEST" | ||
android:textSize="20sp" | ||
android:textStyle="bold" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<EditText | ||
android:id="@+id/encoded_text" | ||
android:layout_width="373dp" | ||
android:layout_height="411dp" | ||
android:layout_marginStart="16dp" | ||
android:layout_marginTop="16dp" | ||
android:editable="false" | ||
android:ems="10" | ||
android:gravity="start|top" | ||
android:inputType="textMultiLine" | ||
android:textAlignment="viewStart" | ||
android:textSize="12sp" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/main_label" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
10 changes: 10 additions & 0 deletions
10
.../functionalTest/templates/builds/no-dependency-android/app/src/main/res/values/colors.xml
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,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="purple_200">#FFBB86FC</color> | ||
<color name="purple_500">#FF6200EE</color> | ||
<color name="purple_700">#FF3700B3</color> | ||
<color name="teal_200">#FF03DAC5</color> | ||
<color name="teal_700">#FF018786</color> | ||
<color name="black">#FF000000</color> | ||
<color name="white">#FFFFFFFF</color> | ||
</resources> |
3 changes: 3 additions & 0 deletions
3
...functionalTest/templates/builds/no-dependency-android/app/src/main/res/values/strings.xml
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> |
4 changes: 4 additions & 0 deletions
4
.../functionalTest/templates/builds/no-dependency-android/app/src/main/res/values/themes.xml
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,4 @@ | ||
<resources> | ||
|
||
<style name="Theme.App" parent="android:Theme.Material.Light.DarkActionBar" /> | ||
</resources> |
13 changes: 13 additions & 0 deletions
13
...s/builds/no-dependency-android/app/src/test/java/kotlinx/kover/test/android/LocalTests.kt
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,13 @@ | ||
package kotlinx.kover.test.android | ||
|
||
import org.junit.Test | ||
|
||
import org.junit.Assert.* | ||
|
||
|
||
class LocalTests { | ||
@Test | ||
fun testDebugUtils() { | ||
assertEquals(3, Maths.sum(1, 2)) | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...-gradle-plugin/src/functionalTest/templates/builds/no-dependency-android/build.gradle.kts
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 @@ | ||
plugins { | ||
id("com.android.application") version "7.4.0" apply false | ||
id("com.android.library") version "7.4.0" apply false | ||
id("org.jetbrains.kotlin.android") version "1.8.20" apply false | ||
id("org.jetbrains.kotlinx.kover") version "0.7.1" apply false | ||
} |
23 changes: 23 additions & 0 deletions
23
...gradle-plugin/src/functionalTest/templates/builds/no-dependency-android/gradle.properties
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,23 @@ | ||
# Project-wide Gradle settings. | ||
# IDE (e.g. Android Studio) users: | ||
# Gradle settings configured through the IDE *will override* | ||
# any settings specified in this file. | ||
# For more details on how to configure your build environment visit | ||
# http://www.gradle.org/docs/current/userguide/build_environment.html | ||
# Specifies the JVM arguments used for the daemon process. | ||
# The setting is particularly useful for tweaking memory settings. | ||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 | ||
# When configured, Gradle will run in incubating parallel mode. | ||
# This option should only be used with decoupled projects. More details, visit | ||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects | ||
# org.gradle.parallel=true | ||
# AndroidX package structure to make it clearer which packages are bundled with the | ||
# Android operating system, and which are packaged with your app's APK | ||
# https://developer.android.com/topic/libraries/support-library/androidx-rn | ||
android.useAndroidX=true | ||
# Kotlin code style for this project: "official" or "obsolete": | ||
kotlin.code.style=official | ||
# Enables namespacing of each library's R class so that its R class includes only the | ||
# resources declared in the library itself and none from the library's dependencies, | ||
# thereby reducing the size of the R class for that library | ||
android.nonTransitiveRClass=true |
19 changes: 19 additions & 0 deletions
19
...adle-plugin/src/functionalTest/templates/builds/no-dependency-android/settings.gradle.kts
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,19 @@ | ||
pluginManagement { | ||
repositories { | ||
google() | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
} | ||
|
||
dependencyResolutionManagement { | ||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) | ||
repositories { | ||
google() | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
} | ||
|
||
rootProject.name = "android_kts" | ||
include(":app", ":subproject") |
3 changes: 3 additions & 0 deletions
3
...gin/src/functionalTest/templates/builds/no-dependency-android/subproject/build.gradle.kts
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 @@ | ||
plugins { | ||
kotlin("jvm") | ||
} |
12 changes: 12 additions & 0 deletions
12
kover-gradle-plugin/src/functionalTest/templates/builds/no-dependency-jvm/build.gradle.kts
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,12 @@ | ||
plugins { | ||
kotlin("jvm") version "1.8.20" | ||
id("org.jetbrains.kotlinx.kover") | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
kover(project(":subproject")) | ||
} |
10 changes: 10 additions & 0 deletions
10
...r-gradle-plugin/src/functionalTest/templates/builds/no-dependency-jvm/settings.gradle.kts
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,10 @@ | ||
pluginManagement { | ||
repositories { | ||
gradlePluginPortal() | ||
mavenCentral() | ||
} | ||
} | ||
|
||
rootProject.name = "no-dependency-jvm" | ||
|
||
include(":subproject") |
7 changes: 7 additions & 0 deletions
7
...-plugin/src/functionalTest/templates/builds/no-dependency-jvm/subproject/build.gradle.kts
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,7 @@ | ||
plugins { | ||
kotlin("jvm") | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} |
45 changes: 45 additions & 0 deletions
45
.../functionalTest/templates/builds/no-dependency-variant-android/app-extra/build.gradle.kts
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,45 @@ | ||
plugins { | ||
id ("org.jetbrains.kotlinx.kover") | ||
id ("com.android.application") | ||
id ("org.jetbrains.kotlin.android") | ||
} | ||
|
||
android { | ||
namespace = "kotlinx.kover.test.android.extra" | ||
compileSdk = 32 | ||
|
||
defaultConfig { | ||
applicationId = "kotlinx.kover.test.android.extra" | ||
minSdk = 21 | ||
targetSdk = 31 | ||
versionCode = 1 | ||
versionName = "1.0" | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
create("extra") | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
buildFeatures { | ||
viewBinding = true | ||
} | ||
} | ||
|
||
dependencies { | ||
// error dependency | ||
kover(project(":app")) | ||
|
||
implementation("androidx.core:core-ktx:1.8.0") | ||
implementation("androidx.appcompat:appcompat:1.5.0") | ||
implementation("com.google.android.material:material:1.6.1") | ||
implementation("androidx.constraintlayout:constraintlayout:2.1.4") | ||
testImplementation("junit:junit:4.13.2") | ||
} |
24 changes: 24 additions & 0 deletions
24
...est/templates/builds/no-dependency-variant-android/app-extra/src/main/AndroidManifest.xml
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,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<application android:label="@string/app_name"> | ||
<uses-library android:name="com.google.android.things" android:required="false" /> | ||
|
||
<activity android:name=".MainActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
<!-- Make this the first activity that is displayed when the device boots. --> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.HOME" /> | ||
<category android:name="android.intent.category.DEFAULT" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
7 changes: 7 additions & 0 deletions
7
...ependency-variant-android/app-extra/src/main/java/kotlinx/kover/test/android/ExtraUtil.kt
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,7 @@ | ||
package kotlinx.kover.test.android | ||
|
||
object ExtraUtil { | ||
fun log(message: String) { | ||
println("Extra: $message") | ||
} | ||
} |
Oops, something went wrong.