Skip to content

Commit

Permalink
merge tests into single source set
Browse files Browse the repository at this point in the history
  • Loading branch information
whyoleg committed Jan 18, 2025
1 parent e8fee9a commit 7bfbc64
Show file tree
Hide file tree
Showing 30 changed files with 27 additions and 55 deletions.
50 changes: 11 additions & 39 deletions sweetspi-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@

@file:Suppress("UnstableApiUsage", "HasPlatformType")

import org.jetbrains.kotlin.gradle.*
import sweetbuild.*

plugins {
`jvm-test-suite`
id("sweetbuild.kotlin-base")
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.plugin.powerAssert)
Expand All @@ -22,9 +20,9 @@ kotlin {
}

dependencies {
api(gradleTestKit())
api(kotlin("test-junit5"))
api(libs.junit.params)
testImplementation(gradleTestKit())
testImplementation(kotlin("test-junit5"))
testImplementation(libs.junit.params)
}

// Dev artifacts for tests resolution - inspired by https://github.com/adamko-dev/dev-publish-plugin
Expand All @@ -43,43 +41,17 @@ dependencies {
devArtifacts(projects.sweetspiGradlePlugin)
}

@OptIn(ExperimentalKotlinGradlePluginApi::class)
powerAssert {
includedSourceSets.addAll(
"testRuntime",
"testProcessor",
"testPlugin"
tasks.test {
useJUnitPlatform()
jvmArgumentProviders.add(
TestsArgumentProvider(
devArtifactsDirectories = devArtifactsResolver.incoming.files,
testKitDirectory = layout.buildDirectory.dir("test-kit"),
projectVersion = provider { project.version.toString() }
)
)
}

testing.suites {
register<JvmTestSuite>("testRuntime")
register<JvmTestSuite>("testProcessor")
register<JvmTestSuite>("testPlugin")

withType<JvmTestSuite>().configureEach {
useJUnitJupiter()
dependencies {
implementation(project())
}
targets.configureEach {
this.testTask.configure {
jvmArgumentProviders.add(
TestsArgumentProvider(
devArtifactsDirectories = devArtifactsResolver.incoming.files,
testKitDirectory = layout.buildDirectory.dir("test-kit"),
projectVersion = provider { project.version.toString() }
)
)
}
}
}
}

tasks.check {
dependsOn(testing.suites)
}

class TestsArgumentProvider(
private val devArtifactsDirectories: FileCollection,
private val testKitDirectory: Provider<Directory>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
* Copyright (c) 2024-2025 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
*/

package dev.whyoleg.sweetspi.tests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
* Copyright (c) 2024-2025 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
*/

package dev.whyoleg.sweetspi.tests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
* Copyright (c) 2024-2025 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
*/

package dev.whyoleg.sweetspi.tests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
* Copyright (c) 2024-2025 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
*/

package dev.whyoleg.sweetspi.tests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
* Copyright (c) 2024-2025 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
*/

package dev.whyoleg.sweetspi.tests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
* Copyright (c) 2024-2025 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
*/

package dev.whyoleg.sweetspi.tests
Expand All @@ -11,7 +11,7 @@ class TestTemplate private constructor(path: String) {
val templatePath: Path = templates.resolve(path)

companion object {
private val templates = Path("src/templates")
private val templates = Path("src/test/templates")

val MULTIPLATFORM = TestTemplate("multiplatform")
val MULTIPLATFORM_MULTIMODULE = TestTemplate("multiplatform-multimodule")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
* Copyright (c) 2024-2025 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
*/

import dev.whyoleg.sweetspi.gradle.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2024 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
# Copyright (c) 2024-2025 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
#

org.gradle.parallel=true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
* Copyright (c) 2024-2025 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
*/

pluginManagement {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
* Copyright (c) 2024-2025 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
*/

plugins {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2024 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
# Copyright (c) 2024-2025 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
#

org.gradle.parallel=true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
* Copyright (c) 2024-2025 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
*/

pluginManagement {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
* Copyright (c) 2024-2025 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
*/

import dev.whyoleg.sweetspi.gradle.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2024 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
# Copyright (c) 2024-2025 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
#

org.gradle.parallel=true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
* Copyright (c) 2024-2025 Oleg Yukhnevich. Use of this source code is governed by the Apache 2.0 license.
*/

pluginManagement {
Expand Down

0 comments on commit 7bfbc64

Please sign in to comment.