Skip to content

Commit 8d6d30f

Browse files
authored
Merge pull request #207 from nstdio/restructure-tests
test: Restructure tests.
2 parents 624325e + e7891e1 commit 8d6d30f

34 files changed

+259
-669
lines changed

buildSrc/build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2022 Edgar Asatryan
2+
* Copyright (C) 2022, 2025 Edgar Asatryan
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,7 +26,6 @@ dependencies {
2626
implementation("org.gradlex:extra-java-module-info:1.4.1")
2727
implementation("io.github.gradle-nexus:publish-plugin:1.3.0")
2828
implementation("net.researchgate:gradle-release:3.0.2")
29-
implementation("com.github.dpaukov:combinatoricslib3:3.4.0")
3029
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:2.1.0")
3130
implementation("me.champeau.jmh:jmh-gradle-plugin:0.7.2")
3231
implementation("se.bjurr.gitchangelog:git-changelog-gradle-plugin:2.1.0") {

buildSrc/src/main/kotlin/io.github.nstdio.http.ext.test-conventions.gradle.kts

Lines changed: 4 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -17,50 +17,23 @@
1717
@file:Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
1818

1919
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
20-
import org.gradle.configurationcache.extensions.capitalized
2120
import org.gradle.kotlin.dsl.invoke
2221
import org.gradle.nativeplatform.OperatingSystemFamily.LINUX
2322
import org.gradle.nativeplatform.OperatingSystemFamily.MACOS
2423
import org.gradle.nativeplatform.OperatingSystemFamily.WINDOWS
2524
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.getCurrentArchitecture
2625
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.getCurrentOperatingSystem
2726
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
28-
import org.paukov.combinatorics3.Generator
2927
import java.lang.Boolean
3028
import kotlin.Suppress
31-
import kotlin.to
3229

3330
plugins {
3431
`java-library`
35-
idea
3632
id("org.gradlex.extra-java-module-info")
3733
}
3834

3935
val isCI = System.getenv("CI").toBoolean()
4036

41-
java {
42-
sourceSets {
43-
create("spiTest") {
44-
val output = sourceSets.main.get().output
45-
compileClasspath += output
46-
runtimeClasspath += output
47-
}
48-
}
49-
}
50-
val sourceSetsSpiTest by sourceSets.named("spiTest")
51-
val spiTestImplementation by configurations
52-
53-
idea.module {
54-
testSourceDirs.addAll(sourceSetsSpiTest.allSource.srcDirs)
55-
}
56-
57-
mapOf(
58-
"spiTestImplementation" to "testImplementation",
59-
"spiTestRuntimeOnly" to "testRuntimeOnly",
60-
).forEach { (t, u) ->
61-
configurations.getByName(t) { extendsFrom(configurations.getByName(u)) }
62-
}
63-
6437
val junitVersion = "5.11.4"
6538
val assertJVersion = "3.27.3"
6639
val kotestAssertionsVersion = "5.9.1"
@@ -75,12 +48,7 @@ val gsonVersion = "2.11.0"
7548
val equalsverifierVersion = "3.18.1"
7649
val coroutinesVersion = "1.10.1"
7750

78-
val jsonLibs = mapOf(
79-
"jackson" to "com.fasterxml.jackson.core",
80-
"gson" to "gson-$gsonVersion"
81-
)
82-
83-
val spiDeps = listOf(
51+
val optionalDeps = listOf(
8452
"org.brotli:dec:$brotliOrgVersion",
8553
"com.aayushatharva.brotli4j:brotli4j:$brotli4JVersion",
8654
"com.github.luben:zstd-jni:$zstdJniVersion",
@@ -89,7 +57,7 @@ val spiDeps = listOf(
8957
)
9058

9159
dependencies {
92-
spiDeps.forEach { compileOnly(it) }
60+
optionalDeps.forEach { compileOnly(it) }
9361

9462
testImplementation(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:$coroutinesVersion"))
9563

@@ -115,29 +83,10 @@ dependencies {
11583
/** Kotlin Coroutines */
11684
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-core")
11785

118-
spiDeps.forEach { spiTestImplementation(it) }
119-
spiTestImplementation("com.aayushatharva.brotli4j:native-${arch()}:$brotli4JVersion")
86+
optionalDeps.forEach { testImplementation(it) }
87+
testImplementation("com.aayushatharva.brotli4j:native-${arch()}:$brotli4JVersion")
12088
}
12189

122-
Generator.subset(jsonLibs.keys)
123-
.simple()
124-
.stream()
125-
.forEach { it ->
126-
val postFix = it.joinToString("And") { it.capitalized() }
127-
val taskName = if (postFix.isEmpty()) "spiTest" else "spiTestWithout${postFix}"
128-
tasks.create<Test>(taskName) {
129-
description = "Run SPI tests"
130-
group = "verification"
131-
testClassesDirs = sourceSetsSpiTest.output.classesDirs
132-
classpath = sourceSetsSpiTest.runtimeClasspath
133-
134-
doFirst {
135-
val toExclude = classpath.filter { file -> it?.any { file.absolutePath.contains(it) } ?: false }
136-
classpath -= toExclude
137-
}
138-
}
139-
}
140-
14190
tasks {
14291
withType<Test> {
14392
useJUnitPlatform()
@@ -150,26 +99,12 @@ tasks {
15099
}
151100
}
152101

153-
create<Task>("spiMatrixTest") {
154-
description = "The aggregator task for all tests"
155-
group = "verification"
156-
dependsOn(filter { it.name.startsWith("spiTest") })
157-
}
158-
159102
withType<KotlinCompile> {
160103
kotlinOptions {
161104
languageVersion = "2.0"
162105
jvmTarget = JavaVersion.VERSION_11.toString()
163106
}
164107
}
165-
166-
check {
167-
dependsOn("spiMatrixTest")
168-
}
169-
170-
build {
171-
dependsOn("spiMatrixTest")
172-
}
173108
}
174109

175110
configurations.names

src/main/java/io/github/nstdio/http/ext/spi/Classpath.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,16 @@
1717
package io.github.nstdio.http.ext.spi;
1818

1919
public class Classpath {
20-
private static final boolean JACKSON = isPresent("com.fasterxml.jackson.databind.ObjectMapper");
21-
private static final boolean GSON = isPresent("com.google.gson.Gson");
2220

2321
private Classpath() {
2422
}
2523

2624
public static boolean isJacksonPresent() {
27-
return JACKSON;
25+
return isPresent("com.fasterxml.jackson.databind.ObjectMapper");
2826
}
2927

3028
public static boolean isGsonPresent() {
31-
return GSON;
29+
return isPresent("com.google.gson.Gson");
3230
}
3331

3432
public static boolean isOrgBrotliPresent() {

src/spiTest/java/io/github/nstdio/http/ext/jupiter/DisabledIfOnClasspath.java

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/spiTest/java/io/github/nstdio/http/ext/jupiter/DisabledIfOnClasspathCondition.java

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/spiTest/java/io/github/nstdio/http/ext/jupiter/EnabledIfOnClasspath.java

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/spiTest/java/io/github/nstdio/http/ext/jupiter/EnabledIfOnClasspathCondition.java

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/spiTest/java/io/github/nstdio/http/ext/jupiter/IfOnClasspathCondition.java

Lines changed: 0 additions & 78 deletions
This file was deleted.

0 commit comments

Comments
 (0)