From ada19d57d42aac1e69007cfbef14f8c5294e0ef8 Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Wed, 20 Jul 2022 21:58:14 +0200 Subject: [PATCH 1/8] bump kotlin 1.7.10, and language level to 1.7 --- agent/jvm/api/mockk-agent-jvm.api | 8 ++++---- build.gradle | 7 +++---- gradle.properties | 2 +- .../mockk/impl/recording/states/VerifyingState.kt | 14 +++++++++----- .../src/main/kotlin/io/mockk/dependencies/Deps.kt | 2 +- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/agent/jvm/api/mockk-agent-jvm.api b/agent/jvm/api/mockk-agent-jvm.api index b4adb9e50..01c9d9979 100644 --- a/agent/jvm/api/mockk-agent-jvm.api +++ b/agent/jvm/api/mockk-agent-jvm.api @@ -73,7 +73,7 @@ public final class io/mockk/proxy/jvm/advice/jvm/SynchronizedMockHandlersMap : i public final fun containsValue (Ljava/lang/Object;)Z public final fun entrySet ()Ljava/util/Set; public fun get (Ljava/lang/Object;)Lio/mockk/proxy/MockKInvocationHandler; - public final fun get (Ljava/lang/Object;)Ljava/lang/Object; + public synthetic fun get (Ljava/lang/Object;)Ljava/lang/Object; public fun getEntries ()Ljava/util/Set; public fun getKeys ()Ljava/util/Set; public fun getSize ()I @@ -85,7 +85,7 @@ public final class io/mockk/proxy/jvm/advice/jvm/SynchronizedMockHandlersMap : i public synthetic fun put (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; public fun putAll (Ljava/util/Map;)V public fun remove (Ljava/lang/Object;)Lio/mockk/proxy/MockKInvocationHandler; - public final fun remove (Ljava/lang/Object;)Ljava/lang/Object; + public synthetic fun remove (Ljava/lang/Object;)Ljava/lang/Object; public final fun size ()I public final fun values ()Ljava/util/Collection; } @@ -99,7 +99,7 @@ public final class io/mockk/proxy/jvm/advice/jvm/WeakMockHandlersMap : io/mockk/ public final fun containsValue (Ljava/lang/Object;)Z public final fun entrySet ()Ljava/util/Set; public fun get (Ljava/lang/Object;)Lio/mockk/proxy/MockKInvocationHandler; - public final fun get (Ljava/lang/Object;)Ljava/lang/Object; + public synthetic fun get (Ljava/lang/Object;)Ljava/lang/Object; public fun getEntries ()Ljava/util/Set; public fun getKeys ()Ljava/util/Set; public fun getSize ()I @@ -111,7 +111,7 @@ public final class io/mockk/proxy/jvm/advice/jvm/WeakMockHandlersMap : io/mockk/ public synthetic fun put (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; public fun putAll (Ljava/util/Map;)V public fun remove (Ljava/lang/Object;)Lio/mockk/proxy/MockKInvocationHandler; - public final fun remove (Ljava/lang/Object;)Ljava/lang/Object; + public synthetic fun remove (Ljava/lang/Object;)Ljava/lang/Object; public final fun size ()I public final fun values ()Ljava/util/Collection; } diff --git a/build.gradle b/build.gradle index 5748153cd..acadb5bee 100644 --- a/build.gradle +++ b/build.gradle @@ -29,7 +29,7 @@ plugins { subprojects { subProject -> group = 'io.mockk' - ext.kotlin_version = findProperty('kotlin.version')?.toString() ?: '1.6.0' + ext.kotlin_version = findProperty('kotlin.version')?.toString() ?: '1.7.10' ext.kotlin_gradle_version = findProperty('kotlin.version')?.toString() ?: '1.6.0' repositories { @@ -40,9 +40,8 @@ subprojects { subProject -> tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { kotlinOptions { jvmTarget = "1.8" - apiVersion = "1.4" - languageVersion = "1.4" - useIR = findProperty("kotlin.ir.enabled")?.toBoolean() == true + apiVersion = "1.7" + languageVersion = "1.7" } } } diff --git a/gradle.properties b/gradle.properties index 5e0eb4319..22747070c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,4 +4,4 @@ org.gradle.configureondemand=false org.gradle.jvmargs=-XX:MaxMetaspaceSize=768m # localrepo=build/mockk-repo localrepo=/Users/raibaz/.m2/repository -# kotlin.version=1.5.10 +kotlin.version=1.7.10 diff --git a/mockk/common/src/main/kotlin/io/mockk/impl/recording/states/VerifyingState.kt b/mockk/common/src/main/kotlin/io/mockk/impl/recording/states/VerifyingState.kt index a3656bc90..c1eeeb747 100644 --- a/mockk/common/src/main/kotlin/io/mockk/impl/recording/states/VerifyingState.kt +++ b/mockk/common/src/main/kotlin/io/mockk/impl/recording/states/VerifyingState.kt @@ -60,10 +60,12 @@ class VerifyingState( val callsReport = VerificationHelpers.formatCalls(outcome.verifiedCalls) throw AssertionError("Inverse verification failed.\n\nVerified calls:\n$callsReport") } + is VerificationResult.Failure -> {} } } else { when (outcome) { is VerificationResult.Failure -> throw AssertionError("Verification failed: ${outcome.message}") + is VerificationResult.OK -> {} } } } @@ -86,17 +88,19 @@ class VerifyingState( } } - if (!calledStubs.isEmpty()) { + if (calledStubs.isNotEmpty()) { if (calledStubs.size == 1) { val calledStub = calledStubs[0] throw AssertionError(recorder.safeExec { "Verification failed: ${calledStub.toStr()} should not be called:\n" + - calledStub.allRecordedCalls().joinToString("\n") + calledStub.allRecordedCalls().joinToString("\n") }) } else { throw AssertionError(recorder.safeExec { - "Verification failed: ${calledStubs.map { it.toStr() }.joinToString(", ")} should not be called:\n" + - calledStubs.flatMap { it.allRecordedCalls() }.joinToString("\n") + "Verification failed: ${ + calledStubs.map { it.toStr() }.joinToString(", ") + } should not be called:\n" + + calledStubs.flatMap { it.allRecordedCalls() }.joinToString("\n") }) } } @@ -105,4 +109,4 @@ class VerifyingState( companion object { val log = Logger() } -} \ No newline at end of file +} diff --git a/plugins/dependencies/src/main/kotlin/io/mockk/dependencies/Deps.kt b/plugins/dependencies/src/main/kotlin/io/mockk/dependencies/Deps.kt index f1ef78c42..49f06d83d 100644 --- a/plugins/dependencies/src/main/kotlin/io/mockk/dependencies/Deps.kt +++ b/plugins/dependencies/src/main/kotlin/io/mockk/dependencies/Deps.kt @@ -8,7 +8,7 @@ object Deps { object Versions { const val androidTools = "4.1.1" const val dokka = "1.6.0" - const val kotlinDefault = "1.6.0" + const val kotlinDefault = "1.7.10" const val coroutines = "1.3.3" const val slfj = "1.7.32" const val logback = "1.2.10" From 7357c69252ded68de3e74801539c56ab5195fc9e Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Wed, 20 Jul 2022 21:59:42 +0200 Subject: [PATCH 2/8] http -> https in docs URLs --- README.md | 4 ++-- gradle/upload.gradle | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e128a735f..e9887768f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ![mockk](doc/logo-site.png) ![kotlin](doc/kotlin-logo.png) [![Gitter](https://badges.gitter.im/mockk-io/Lobby.svg)](https://gitter.im/mockk-io/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=body_badge) -[![Relase Version](https://img.shields.io/maven-central/v/io.mockk/mockk.svg?label=release)](http://search.maven.org/#search%7Cga%7C1%7Cmockk) +[![Relase Version](https://img.shields.io/maven-central/v/io.mockk/mockk.svg?label=release)](https://search.maven.org/#search%7Cga%7C1%7Cmockk) [![Change log](https://img.shields.io/badge/change%20log-%E2%96%A4-yellow.svg)](https://github.com/mockk/mockk/releases) [![codecov](https://codecov.io/gh/mockk/mockk/branch/master/graph/badge.svg)](https://codecov.io/gh/mockk/mockk) [![Android](https://img.shields.io/badge/android-support-green.svg)](https://mockk.io/ANDROID) @@ -1397,7 +1397,7 @@ This project exists thanks to all the people who contribute. To ask questions, please use Stack Overflow or Gitter. * Chat/Gitter: [https://gitter.im/mockk-io/Lobby](https://gitter.im/mockk-io/Lobby) -* Stack Overflow: [http://stackoverflow.com/questions/tagged/mockk](http://stackoverflow.com/questions/tagged/mockk) +* Stack Overflow: [http://stackoverflow.com/questions/tagged/mockk](https://stackoverflow.com/questions/tagged/mockk) To report bugs, please use the GitHub project. diff --git a/gradle/upload.gradle b/gradle/upload.gradle index 32fce7923..d128b0baf 100644 --- a/gradle/upload.gradle +++ b/gradle/upload.gradle @@ -28,7 +28,7 @@ afterEvaluate { pom { name = mavenName description = mavenDescription - url = 'http://mockk.io' + url = 'https://mockk.io' scm { connection = 'scm:git:git@github.com:mockk/mockk.git' @@ -52,7 +52,7 @@ afterEvaluate { licenses { license { name = 'Apache License, Version 2.0' - url = 'http://www.apache.org/licenses/LICENSE-2.0' + url = 'https://www.apache.org/licenses/LICENSE-2.0' } } } From c23a873b9ca10c8e3c126a7431b37e0d5c3aaa28 Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Wed, 20 Jul 2022 23:51:33 +0200 Subject: [PATCH 3/8] change toUpper/LowerCase() to uppercase() and lowercase() --- dsl/common/src/main/kotlin/io/mockk/MockKSettings.kt | 2 +- .../main/kotlin/io/mockk/impl/recording/PermanentMocker.kt | 4 ++-- .../impl/recording/states/StubbingAwaitingAnswerState.kt | 4 ++-- mockk/jvm/src/main/kotlin/io/mockk/impl/InternalPlatform.kt | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dsl/common/src/main/kotlin/io/mockk/MockKSettings.kt b/dsl/common/src/main/kotlin/io/mockk/MockKSettings.kt index 29eadaa8d..608ae7157 100644 --- a/dsl/common/src/main/kotlin/io/mockk/MockKSettings.kt +++ b/dsl/common/src/main/kotlin/io/mockk/MockKSettings.kt @@ -19,7 +19,7 @@ enum class StackTracesAlignment { fun stackTracesAlignmentValueOf(property: String): StackTracesAlignment { return try { - enumValueOf(property.toUpperCase()) + enumValueOf(property.uppercase()) } catch (e: IllegalArgumentException) { StackTracesAlignment.CENTER } diff --git a/mockk/common/src/main/kotlin/io/mockk/impl/recording/PermanentMocker.kt b/mockk/common/src/main/kotlin/io/mockk/impl/recording/PermanentMocker.kt index af2d31d8a..0601f94d0 100644 --- a/mockk/common/src/main/kotlin/io/mockk/impl/recording/PermanentMocker.kt +++ b/mockk/common/src/main/kotlin/io/mockk/impl/recording/PermanentMocker.kt @@ -138,11 +138,11 @@ class PermanentMocker( args.isEmpty() ) { return prefix + - methodName[3].toLowerCase() + + methodName[3].lowercase() + methodName.substring(4) } return prefix + methodName + "(" + args.joinToString(", ") + ")" } -} \ No newline at end of file +} diff --git a/mockk/common/src/main/kotlin/io/mockk/impl/recording/states/StubbingAwaitingAnswerState.kt b/mockk/common/src/main/kotlin/io/mockk/impl/recording/states/StubbingAwaitingAnswerState.kt index f11e37965..6a0cdb9ee 100644 --- a/mockk/common/src/main/kotlin/io/mockk/impl/recording/states/StubbingAwaitingAnswerState.kt +++ b/mockk/common/src/main/kotlin/io/mockk/impl/recording/states/StubbingAwaitingAnswerState.kt @@ -71,5 +71,5 @@ class StubbingAwaitingAnswerState(recorder: CommonCallRecorder) : CallRecordingS } } - private fun String.toCamelCase() = if (isEmpty()) this else substring(0, 1).toLowerCase() + substring(1) -} \ No newline at end of file + private fun String.toCamelCase() = if (isEmpty()) this else substring(0, 1).lowercase() + substring(1) +} diff --git a/mockk/jvm/src/main/kotlin/io/mockk/impl/InternalPlatform.kt b/mockk/jvm/src/main/kotlin/io/mockk/impl/InternalPlatform.kt index ba6442670..cb586d936 100644 --- a/mockk/jvm/src/main/kotlin/io/mockk/impl/InternalPlatform.kt +++ b/mockk/jvm/src/main/kotlin/io/mockk/impl/InternalPlatform.kt @@ -159,7 +159,7 @@ actual object InternalPlatform { fun isRunningAndroidInstrumentationTest(): Boolean { return System.getProperty("java.vendor", "") - .toLowerCase(Locale.US) + .lowercase(Locale.US) .contains("android") } From 2016d14f4efd1614f5c22afdde69cee64c992b62 Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Wed, 20 Jul 2022 23:53:33 +0200 Subject: [PATCH 4/8] change Kt lang level to 1.5, update GitHub action to remove Kt 1.4 and add 1.7 --- .github/workflows/gradle.yml | 7 +------ build.gradle | 4 ++-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 14cbd8f83..5c3c90b35 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -11,13 +11,8 @@ jobs: strategy: matrix: java-version: [11, 12, 13, 14, 15, 16, 17] - kotlin-version: [1.4.32, 1.5.31, 1.6.0] + kotlin-version: [1.5.31, 1.6.0, 1.7.10] kotlin-ir-enabled: [true, false] - exclude: - - kotlin-version: 1.4.32 - java-version: 16 - - kotlin-version: 1.4.32 - java-version: 17 # in case one JDK fails, we still want to see results from others fail-fast: false runs-on: ubuntu-latest diff --git a/build.gradle b/build.gradle index acadb5bee..b8998b085 100644 --- a/build.gradle +++ b/build.gradle @@ -40,8 +40,8 @@ subprojects { subProject -> tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { kotlinOptions { jvmTarget = "1.8" - apiVersion = "1.7" - languageVersion = "1.7" + apiVersion = "1.5" + languageVersion = "1.5" } } } From 51344b06ba4c030b14c3ed84dc75199929c299b4 Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Thu, 21 Jul 2022 10:35:42 +0200 Subject: [PATCH 5/8] undo formatting + apply IntelliJ suggestion --- .../io/mockk/impl/recording/states/VerifyingState.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mockk/common/src/main/kotlin/io/mockk/impl/recording/states/VerifyingState.kt b/mockk/common/src/main/kotlin/io/mockk/impl/recording/states/VerifyingState.kt index c1eeeb747..59e51f40e 100644 --- a/mockk/common/src/main/kotlin/io/mockk/impl/recording/states/VerifyingState.kt +++ b/mockk/common/src/main/kotlin/io/mockk/impl/recording/states/VerifyingState.kt @@ -92,14 +92,11 @@ class VerifyingState( if (calledStubs.size == 1) { val calledStub = calledStubs[0] throw AssertionError(recorder.safeExec { - "Verification failed: ${calledStub.toStr()} should not be called:\n" + - calledStub.allRecordedCalls().joinToString("\n") + "Verification failed: ${calledStub.toStr()} should not be called:\n" + calledStub.allRecordedCalls().joinToString("\n") }) } else { throw AssertionError(recorder.safeExec { - "Verification failed: ${ - calledStubs.map { it.toStr() }.joinToString(", ") - } should not be called:\n" + + "Verification failed: ${calledStubs.joinToString(", ") { it.toStr() }} should not be called:\n" + calledStubs.flatMap { it.allRecordedCalls() }.joinToString("\n") }) } From 29ac88c27916860953bed52778e07a8104d16161 Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Thu, 21 Jul 2022 10:36:44 +0200 Subject: [PATCH 6/8] minor formatting --- .../io/mockk/impl/recording/states/VerifyingState.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mockk/common/src/main/kotlin/io/mockk/impl/recording/states/VerifyingState.kt b/mockk/common/src/main/kotlin/io/mockk/impl/recording/states/VerifyingState.kt index 59e51f40e..70c24f0ac 100644 --- a/mockk/common/src/main/kotlin/io/mockk/impl/recording/states/VerifyingState.kt +++ b/mockk/common/src/main/kotlin/io/mockk/impl/recording/states/VerifyingState.kt @@ -56,7 +56,7 @@ class VerifyingState( private fun failIfNotPassed(outcome: VerificationResult, inverse: Boolean) { if (inverse) { when (outcome) { - is VerificationResult.OK -> { + is VerificationResult.OK -> { val callsReport = VerificationHelpers.formatCalls(outcome.verifiedCalls) throw AssertionError("Inverse verification failed.\n\nVerified calls:\n$callsReport") } @@ -65,7 +65,7 @@ class VerifyingState( } else { when (outcome) { is VerificationResult.Failure -> throw AssertionError("Verification failed: ${outcome.message}") - is VerificationResult.OK -> {} + is VerificationResult.OK -> {} } } } @@ -92,7 +92,8 @@ class VerifyingState( if (calledStubs.size == 1) { val calledStub = calledStubs[0] throw AssertionError(recorder.safeExec { - "Verification failed: ${calledStub.toStr()} should not be called:\n" + calledStub.allRecordedCalls().joinToString("\n") + "Verification failed: ${calledStub.toStr()} should not be called:\n" + + calledStub.allRecordedCalls().joinToString("\n") }) } else { throw AssertionError(recorder.safeExec { From 2ca2423c65aa76480b724af6e0a3d8dd0fa0fd44 Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Thu, 21 Jul 2022 10:37:39 +0200 Subject: [PATCH 7/8] simplify when statement --- .../impl/recording/states/VerifyingState.kt | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/mockk/common/src/main/kotlin/io/mockk/impl/recording/states/VerifyingState.kt b/mockk/common/src/main/kotlin/io/mockk/impl/recording/states/VerifyingState.kt index 70c24f0ac..b251833d7 100644 --- a/mockk/common/src/main/kotlin/io/mockk/impl/recording/states/VerifyingState.kt +++ b/mockk/common/src/main/kotlin/io/mockk/impl/recording/states/VerifyingState.kt @@ -54,18 +54,13 @@ class VerifyingState( } private fun failIfNotPassed(outcome: VerificationResult, inverse: Boolean) { - if (inverse) { - when (outcome) { - is VerificationResult.OK -> { - val callsReport = VerificationHelpers.formatCalls(outcome.verifiedCalls) - throw AssertionError("Inverse verification failed.\n\nVerified calls:\n$callsReport") - } - is VerificationResult.Failure -> {} + when (outcome) { + is VerificationResult.OK -> if (inverse) { + val callsReport = VerificationHelpers.formatCalls(outcome.verifiedCalls) + throw AssertionError("Inverse verification failed.\n\nVerified calls:\n$callsReport") } - } else { - when (outcome) { - is VerificationResult.Failure -> throw AssertionError("Verification failed: ${outcome.message}") - is VerificationResult.OK -> {} + is VerificationResult.Failure -> if (!inverse) { + throw AssertionError("Verification failed: ${outcome.message}") } } } From f100de48b00b328b6f9936bd4fccfeee967d88d8 Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Thu, 21 Jul 2022 10:43:07 +0200 Subject: [PATCH 8/8] remove unnecessary spread operator --- mockk/common/src/main/kotlin/io/mockk/MockK.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mockk/common/src/main/kotlin/io/mockk/MockK.kt b/mockk/common/src/main/kotlin/io/mockk/MockK.kt index 03925b817..c94315735 100644 --- a/mockk/common/src/main/kotlin/io/mockk/MockK.kt +++ b/mockk/common/src/main/kotlin/io/mockk/MockK.kt @@ -342,7 +342,7 @@ fun clearMocks( MockK.useImpl { MockKDsl.internalClearMocks( firstMock = firstMock, - mocks = *mocks, + mocks = mocks, answers = answers, recordedCalls = recordedCalls, childMocks = childMocks,