Skip to content

Commit

Permalink
Test: Tune tests to support MS Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
pan3793 committed Jul 16, 2024
1 parent 6141deb commit 22e97e1
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import xenon.clickhouse.spec.NodeSpec

import java.nio.file.{Path, Paths}

import scala.collection.JavaConverters._

trait ClickHouseSingleMixIn extends AnyFunSuite with ForAllTestContainer {
// format: off
val CLICKHOUSE_IMAGE: String = Utils.load("CLICKHOUSE_IMAGE", "clickhouse/clickhouse-server:23.8")
Expand All @@ -43,13 +45,16 @@ trait ClickHouseSingleMixIn extends AnyFunSuite with ForAllTestContainer {
protected val rootProjectDir: Path = {
val thisClassURI = this.getClass.getProtectionDomain.getCodeSource.getLocation.toURI
val currentPath = Paths.get(thisClassURI).toAbsolutePath.normalize
val coreModuleIndex = currentPath.toString.indexOf("/clickhouse-core")
val eachFolder = currentPath.iterator().asScala.toIndexedSeq
val coreModuleIndex = eachFolder.indexWhere(_.toString.startsWith("clickhouse-core"))
val sparkModuleIndex = eachFolder.indexWhere(_.toString.startsWith("clickhouse-spark"))
require(coreModuleIndex > 0 || sparkModuleIndex > 0, s"illegal path: $currentPath")
if (coreModuleIndex > 0) {
Paths.get(currentPath.toString.substring(0, coreModuleIndex))
} else {
val sparkModuleIndex = currentPath.toString.indexOf("/clickhouse-spark")
require(sparkModuleIndex > 0, s"illegal path: $currentPath")
Paths.get(currentPath.toString.substring(0, sparkModuleIndex)).getParent
eachFolder.take(coreModuleIndex).reduce((acc, i) => acc.resolve(i))
} else if (sparkModuleIndex > 0) {
eachFolder.take(sparkModuleIndex).dropRight(1).reduce((acc, i) => acc.resolve(i))
} else { // unreachable code
throw new IllegalArgumentException(s"illegal path: $currentPath")
}
}

Expand Down

0 comments on commit 22e97e1

Please sign in to comment.