Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgraded kotlin to 1.9.20 #556

Merged
merged 17 commits into from
Feb 28, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@ kotlin {
macosX64(),
/* macosArm64() */
)
if (project.name == "save-common") {
// additionally, save-common should be available for JS too
kgevorkyan marked this conversation as resolved.
Show resolved Hide resolved
// fixme: shouldn't rely on hardcoded project name here
js(IR).browser()

// store yarn.lock in the root directory
rootProject.extensions.configure<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension> {
lockFileDirectory = rootProject.projectDir
}
}

if (hasProperty("disableRedundantTargets") && (property("disableRedundantTargets") as String?) != "false") {
// with this flag we exclude targets that are present on multiple OS to speed up build
Expand All @@ -58,55 +48,20 @@ kotlin {
}
}

/*
* Common structure for MPP libraries:
nulls marked this conversation as resolved.
Show resolved Hide resolved
* common
* |
* nonJs
* / \
* native JVM
* / | \
* linux mingw macos
*/
sourceSets {
val commonMain by getting
val commonTest by getting {
dependencies {
implementation("io.kotest:kotest-assertions-core:5.8.0")
}
}
val commonNonJsMain by creating {
dependsOn(commonMain)
}
val commonNonJsTest by creating {
dependsOn(commonTest)
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val jvmMain by getting {
dependsOn(commonNonJsMain)
}
val jvmTest by getting {
dependsOn(commonNonJsTest)
dependencies {
implementation(kotlin("test-junit5"))
implementation("org.junit.jupiter:junit-jupiter-engine:5.10.1")
}
}
val nativeMain by creating {
dependsOn(commonNonJsMain)
}
val nativeTest by creating {
dependsOn(commonNonJsTest)
}
nativeTargets.forEach {
getByName("${it.name}Main").dependsOn(nativeMain)
}
nativeTargets.forEach {
getByName("${it.name}Test").dependsOn(nativeTest)
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions diktat-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
configuration:
domainName: com.saveourtool.save
kotlinVersion: 1.6
srcDirectories: "main,nativeMain,commonNonJsMain"
testDirs: "test,nativeTest,commonTest,jvmTest,commonNonJsTest"
srcDirectories: "main,nativeMain,commonMain"
testDirs: "test,nativeTest,commonTest,jvmTest,commonTest"
- name: AVOID_NULL_CHECKS
enabled: false
- name: ENUM_VALUE
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
kotlin = "1.9.10"
kotlin = "1.9.20"
okio = "3.6.0"
serialization = "1.6.0"
diktat = "1.2.5"
Expand Down
5 changes: 0 additions & 5 deletions save-cli/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ kotlin {
val commonMain by getting {
dependencies {
api(libs.okio)
}
}

val commonNonJsMain by getting {
dependencies {
implementation(projects.saveCore)
implementation(projects.saveCommon)
implementation(libs.kotlinx.serialization.properties)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import com.saveourtool.save.cli.ExitCodes
* @param message message to log
* @return nothing, program terminates in this method
*/
@Deprecated("never use this method in save-core as it can lead to a break of save-cloud application")
expect fun logErrorAndExit(exitCode: ExitCodes, message: String): Nothing
internal expect fun logErrorAndExit(exitCode: ExitCodes, message: String): Nothing

/**
* Log result of [messageSupplier] with level WARN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.saveourtool.save.core.logging.logWarn
import kotlin.system.exitProcess

actual fun logErrorAndExit(exitCode: ExitCodes, message: String): Nothing {
internal actual fun logErrorAndExit(exitCode: ExitCodes, message: String): Nothing {
Fixed Show fixed Hide fixed
logError(message)
exitProcess(exitCode.code)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.saveourtool.save.core.logging.logWarn
import kotlin.system.exitProcess

actual fun logErrorAndExit(exitCode: ExitCodes, message: String): Nothing {
internal actual fun logErrorAndExit(exitCode: ExitCodes, message: String): Nothing {
Fixed Show fixed Hide fixed
logError(message)
exitProcess(exitCode.code)
}
Expand Down
2 changes: 1 addition & 1 deletion save-common-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {

kotlin {
sourceSets {
val commonNonJsMain by getting {
val commonMain by getting {
dependencies {
implementation(projects.saveCommon)
api(libs.okio)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@ import okio.FileSystem
import okio.Path
import kotlin.random.Random

/**
* Marks method to be executed before all tests, supported on JVM and Native
*/
expect annotation class BeforeClass

/**
* Marks method to be executed after all tests, supported on JVM and Native
*/
expect annotation class AfterClass

/**
* Create a temporary directory
*
Expand Down
10 changes: 0 additions & 10 deletions save-common-test/src/jvmMain/kotlin/com/saveourtool/save/Utils.kt

This file was deleted.

This file was deleted.

14 changes: 14 additions & 0 deletions save-common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ plugins {
}

kotlin {
js(IR) {
nulls marked this conversation as resolved.
Show resolved Hide resolved
browser()
testRuns.configureEach {
filter {
setExcludePatterns("*")
}
}
}

// store yarn.lock in the root directory
rootProject.extensions.configure<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension> {
lockFileDirectory = rootProject.projectDir
}

sourceSets {
val commonMain by getting {
dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@ package com.saveourtool.save.core.logging
import com.saveourtool.save.core.config.LogType
import com.saveourtool.save.core.config.OutputStreamType
import com.saveourtool.save.core.utils.GenericAtomicReference
import com.saveourtool.save.core.utils.createGenericAtomicReference
import com.saveourtool.save.core.utils.writeToStream

import kotlin.native.concurrent.SharedImmutable
import kotlinx.datetime.Clock
import kotlinx.datetime.TimeZone
import kotlinx.datetime.toLocalDateTime

/**
* Logging mode
*/
@SharedImmutable
val logType: GenericAtomicReference<LogType> = GenericAtomicReference(LogType.WARN)
val logType: GenericAtomicReference<LogType> = createGenericAtomicReference(LogType.WARN)

/**
* Whether to add time stamps to log messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ enum class CurrentOs {
}

/**
* Class that holds value and shares atomic reference to the value (native only)
* Interface that holds value and shares atomic reference to the value (native only)
*
* @param valueToStore value to store
*/
@Suppress("USE_DATA_CLASS")
expect class GenericAtomicReference<T>(valueToStore: T) {
interface GenericAtomicReference<T> {
/**
* @return stored value
*/
Expand All @@ -33,6 +31,12 @@ expect class GenericAtomicReference<T>(valueToStore: T) {
fun set(newValue: T)
}

/**
* @param valueToStore value to store
* @return a new [GenericAtomicReference] with default value [valueToStore]
*/
expect fun <T> createGenericAtomicReference(valueToStore: T): GenericAtomicReference<T>

/**
* Get type of current OS
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@ import okio.Path.Companion.toPath
import kotlinx.datetime.Clock

/**
* A class that is capable of executing processes, specific to different OS and returning their output.
* An interface that is capable of executing processes, specific to different OS and returning their output.
*/
expect class ProcessBuilderInternal(
stdoutFile: Path,
stderrFile: Path,
useInternalRedirections: Boolean,
) {
interface ProcessBuilderInternal {
/**
* Modify execution command according behavior of different OS,
* also stdout and stderr will be redirected to tmp files
Expand Down Expand Up @@ -97,7 +93,7 @@ class ProcessBuilder(private val useInternalRedirections: Boolean, private val f
val stderrFile = tmpDir / "stderr.txt"
logTrace("Creating stderr file of ProcessBuilder: $stderrFile")
// Instance, containing platform-dependent realization of command execution
val processBuilderInternal = ProcessBuilderInternal(stdoutFile, stderrFile, useInternalRedirections)
val processBuilderInternal = createProcessBuilderInternal(stdoutFile, stderrFile, useInternalRedirections)
fs.createDirectories(tmpDir)
fs.createFile(stdoutFile)
fs.createFile(stderrFile)
Expand Down Expand Up @@ -236,3 +232,15 @@ data class ExecutionResult(
val stdout: List<String>,
val stderr: List<String>,
)

/**
* @param stdoutFile
* @param stderrFile
* @param useInternalRedirections
* @return implementation of [ProcessBuilderInternal]
*/
expect fun createProcessBuilderInternal(
stdoutFile: Path,
stderrFile: Path,
useInternalRedirections: Boolean,
): ProcessBuilderInternal
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.saveourtool.save.core.plugin.resolvePlaceholdersFrom
import com.saveourtool.save.core.plugin.splitByNonEscaped

import okio.fakefilesystem.FakeFileSystem
import kotlin.js.JsName

import kotlin.test.Test
import kotlin.test.assertEquals
Expand All @@ -18,6 +19,7 @@ import kotlin.test.assertEquals
)
class ExtraFlagsExtractorTest {
@Test
@JsName("basic_test")
fun `basic test`() {
val extraFlagsExtractor = ExtraFlagsExtractor(
GeneralConfig(runConfigPattern = Regex("""// RUN: (.*[^\\]=.*)""")),
Expand All @@ -41,6 +43,7 @@ class ExtraFlagsExtractorTest {
}

@Test
@JsName("should_resolve_placeholders")
fun `should resolve placeholders`() {
// basic test
checkPlaceholders(
Expand Down Expand Up @@ -80,6 +83,7 @@ class ExtraFlagsExtractorTest {
}

@Test
@JsName("should_join_multiline_directives")
fun `should join multiline directives`() {
checkMultilineDirectives(
Regex("""// RUN: (.*([^\\]=)?.*)\\?"""),
Expand Down Expand Up @@ -130,6 +134,7 @@ class ExtraFlagsExtractorTest {
}

@Test
@JsName("test_for_splitByNonEscaped")
fun `test for splitByNonEscaped`() {
assertEquals(
listOf("this string\\, not split"),
Expand Down
Loading
Loading