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

Finish functional tests migration #1117

Merged
merged 21 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Enable --build-cache for all func tests
  • Loading branch information
Goooler committed Jan 10, 2025
commit dfe9062964392ca98316b3c0f97719c2a180822a
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ abstract class BasePluginTest {

fun getDefaultSettingsBuildScript(
startBlock: String = "",
// Use a test-specific build cache directory. This ensures that we'll only use cached outputs generated during
// this test, and we won't accidentally use cached outputs from a different test or a different build.
// https://docs.gradle.org/current/userguide/build_cache.html#sec:build_cache_configure_local
buildCacheBlock: String = "local { directory = file('build-cache') }",
endBlock: String = "rootProject.name = 'shadow'",
): String {
return """
Expand All @@ -118,6 +122,9 @@ abstract class BasePluginTest {
mavenCentral()
}
}
buildCache {
$buildCacheBlock
}
$endBlock
""".trimIndent() + System.lineSeparator()
}
Expand Down Expand Up @@ -323,6 +330,7 @@ abstract class BasePluginTest {
val commonArguments = listOf(
"--warning-mode=fail",
"--configuration-cache",
"--build-cache",
"--stacktrace",
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.github.jengelman.gradle.plugins.shadow.BasePluginTest
import java.nio.file.NoSuchFileException
import java.nio.file.Path
import kotlin.io.path.ExperimentalPathApi
import kotlin.io.path.appendText
import kotlin.io.path.copyToRecursively
import kotlin.io.path.deleteRecursively
import kotlin.io.path.listDirectoryEntries
Expand All @@ -14,29 +13,12 @@ import org.gradle.testkit.runner.TaskOutcome
import org.gradle.testkit.runner.TaskOutcome.FROM_CACHE
import org.gradle.testkit.runner.TaskOutcome.SUCCESS
import org.gradle.testkit.runner.TaskOutcome.UP_TO_DATE
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.io.TempDir

abstract class BaseCachingTest : BasePluginTest() {
@TempDir
lateinit var alternateDir: Path

@BeforeEach
override fun setup() {
super.setup()
// Use a test-specific build cache directory. This ensures that we'll only use cached outputs generated during
// this test, and we won't accidentally use cached outputs from a different test or a different build.
settingsScriptPath.appendText(
"""
buildCache {
local {
directory = file('build-cache')
}
}
""".trimIndent() + System.lineSeparator(),
)
}

@OptIn(ExperimentalPathApi::class)
fun assertShadowJarIsCachedAndRelocatable(
firstOutcome: TaskOutcome = FROM_CACHE,
Expand Down Expand Up @@ -72,7 +54,7 @@ abstract class BaseCachingTest : BasePluginTest() {
expectedOutcome: TaskOutcome,
runnerBlock: (GradleRunner) -> GradleRunner = { it },
) {
val result = run("--build-cache", shadowJarTask, runnerBlock = runnerBlock)
val result = run(shadowJarTask, runnerBlock = runnerBlock)
assertThat(result).taskOutcomeEquals(shadowJarTask, expectedOutcome)
}
}
Loading