Skip to content

Commit a17899b

Browse files
committed
Remove unused test files, update copyright year, and refactor code formatting in HarnessKotest.
1 parent ae2d013 commit a17899b

4 files changed

Lines changed: 23 additions & 2013 deletions

File tree

jvm/selfie-runner-kotest/src/commonTest/kotlin/com/diffplug/selfie/kotest/HarnessKotest.kt

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2023-2025 DiffPlug
2+
* Copyright (C) 2023-2026 DiffPlug
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.
@@ -177,13 +177,13 @@ open class HarnessKotest() : FunSpec() {
177177
fun content() = lines.subList(startInclusive, endInclusive + 1).joinToString("\n")
178178
fun setContent(mustBe: String) {
179179
FS_SYSTEM.write(subprojectFolder.resolve(subpath)) {
180-
for (i in 0 ..< startInclusive) {
180+
for (i in 0..<startInclusive) {
181181
writeUtf8(lines[i])
182182
writeUtf8("\n")
183183
}
184184
writeUtf8(mustBe)
185185
writeUtf8("\n")
186-
for (i in endInclusive + 1 ..< lines.size) {
186+
for (i in endInclusive + 1..<lines.size) {
187187
writeUtf8(lines[i])
188188
writeUtf8("\n")
189189
}
@@ -223,7 +223,25 @@ open class HarnessKotest() : FunSpec() {
223223
return FS_SYSTEM.read(pathStr.toPath()) { AssertionError(readUtf8()) }
224224
}
225225
}
226-
private fun testName() = "UT_${thisClassName()}"
226+
private fun testName(): String {
227+
val simpleClassName = "UT_${thisClassName()}"
228+
val matches =
229+
FS_SYSTEM.listRecursively(subprojectFolder)
230+
.filter { it.name == "$simpleClassName.kt" && !it.toString().contains("build") }
231+
.toList()
232+
if (matches.size == 1) {
233+
FS_SYSTEM.read(matches[0]) {
234+
while (!exhausted()) {
235+
val line = readUtf8Line() ?: break
236+
if (line.startsWith("package ")) {
237+
val pkg = line.removePrefix("package ").trim()
238+
return "$pkg.$simpleClassName"
239+
}
240+
}
241+
}
242+
}
243+
return simpleClassName
244+
}
227245
fun gradleWriteSS() {
228246
gradlew("test", "-PunderTest=true", "-Pselfie=overwrite", "--tests", testName())?.let {
229247
throw AssertionError("Expected write snapshots to succeed, but it failed", it)

jvm/undertest-kotest/src/commonTest/kotlin/kotest/UTStringSpecTest.ss

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

0 commit comments

Comments
 (0)