Skip to content

Commit

Permalink
use new slash syntax in test
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Oct 6, 2024
1 parent 3d99317 commit d1b5c25
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 38 deletions.
4 changes: 2 additions & 2 deletions bak/play-twirl/test.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ checkFileContents := {
checkFile("views/main.scala.html")

def checkFile(name: String) = {
val actualPath = (scalaSource.in(Compile).value / name).toString
val expectedPath = (scalaSource.in(Compile).value / (name + "_expected")).toString
val actualPath = (Compile / scalaSource).value / name).toString
val expectedPath = (Compile / scalaSource).value / (name + "_expected")).toString

val actual = scala.io.Source.fromFile(actualPath).mkString
val expected = scala.io.Source.fromFile(expectedPath).mkString
Expand Down
4 changes: 2 additions & 2 deletions src/sbt-test/sbt-header/auto-detection-end-year/test.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ checkFileContents := {
checkFile("HasNoHeader.scala")

def checkFile(name: String) = {
val actualPath = (scalaSource.in(Compile).value / name).toString
val expectedPath = (resourceDirectory.in(Compile).value / s"${name}_expected").toString
val actualPath = ((Compile / scalaSource).value / name).toString
val expectedPath = ((Compile / resourceDirectory).value / s"${name}_expected").toString

val actual = scala.io.Source.fromFile(actualPath).mkString
val expected = scala.io.Source.fromFile(expectedPath).mkString
Expand Down
4 changes: 2 additions & 2 deletions src/sbt-test/sbt-header/auto-detection/test.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ checkFileContents := {
checkFile("HasNoHeader.scala")

def checkFile(name: String) = {
val actualPath = (scalaSource.in(Compile).value / name).toString
val expectedPath = (resourceDirectory.in(Compile).value / s"${name}_expected").toString
val actualPath = ((Compile / scalaSource).value / name).toString
val expectedPath = ((Compile / resourceDirectory).value / s"${name}_expected").toString

val actual = scala.io.Source.fromFile(actualPath).mkString
val expected = scala.io.Source.fromFile(expectedPath).mkString
Expand Down
4 changes: 2 additions & 2 deletions src/sbt-test/sbt-header/custom-license/test.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ checkFileContents := {
checkFile("HasNoHeader.scala")

def checkFile(name: String) = {
val actualPath = (scalaSource.in(Compile).value / name).toString
val expectedPath = (resourceDirectory.in(Compile).value / s"${name}_expected").toString
val actualPath = ((Compile / scalaSource).value / name).toString
val expectedPath = ((Compile / resourceDirectory).value / s"${name}_expected").toString

val actual = scala.io.Source.fromFile(actualPath).mkString
val expected = scala.io.Source.fromFile(expectedPath).mkString
Expand Down
22 changes: 11 additions & 11 deletions src/sbt-test/sbt-header/excludes/test.sbt
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
headerLicense := Some(HeaderLicense.ALv2("2015", "Heiko Seeberger"))

excludeFilter.in(headerSources) := HiddenFileFilter || "*Excluded.scala"
headerSources / excludeFilter := HiddenFileFilter || "*Excluded.scala"

val checkFiles = taskKey[Unit]("Verify files match expected files")
checkFiles := {

val includeFiles = Seq(
(scalaSource.in(Compile).value / "Included.scala").toString,
(scalaSource.in(Compile).value / "de/heikoseeberger/allincluded/Included.scala").toString,
(scalaSource.in(Compile).value / "de/heikoseeberger/mixed/Included.scala").toString
((Compile / scalaSource).value / "Included.scala").toString,
((Compile / scalaSource).value / "de/heikoseeberger/allincluded/Included.scala").toString,
((Compile / scalaSource).value / "de/heikoseeberger/mixed/Included.scala").toString
)
val excludeFiles = Seq(
(scalaSource.in(Compile).value / "Excluded.scala").toString,
(scalaSource.in(Compile).value / "de/heikoseeberger/allexcluded/Excluded.scala").toString,
(scalaSource.in(Compile).value / "de/heikoseeberger/mixed/Excluded.scala").toString
((Compile / scalaSource).value / "Excluded.scala").toString,
((Compile / scalaSource).value / "de/heikoseeberger/allexcluded/Excluded.scala").toString,
((Compile / scalaSource).value / "de/heikoseeberger/mixed/Excluded.scala").toString
)

// Check list of source files to process

val nonHeaderCreateSources = unmanagedSources.in(Compile).value
val headerCreateSources = headerSources.in(Compile).value
val nonHeaderCreateSources = (Compile / unmanagedSources).value
val headerCreateSources = (Compile / headerSources).value

def assertPathSetEquality(a: Seq[File], b: Seq[File], failureMessage: String): Unit = {
val aSet = a.map(_.getCanonicalPath).toSet
Expand Down Expand Up @@ -51,9 +51,9 @@ checkFiles := {
// Check contents of files

val expectedExcludedFile =
(resourceDirectory.in(Compile).value / "Excluded.scala_expected").toString
((Compile / resourceDirectory).value / "Excluded.scala_expected").toString
val expectedIncludedFile =
(resourceDirectory.in(Compile).value / "Included.scala_expected").toString
((Compile / resourceDirectory).value / "Included.scala_expected").toString

checkFileContents(excludeFiles, expectedExcludedFile)
checkFileContents(includeFiles, expectedIncludedFile)
Expand Down
4 changes: 2 additions & 2 deletions src/sbt-test/sbt-header/header-style/test.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ checkFileContents := {
checkFile("HasNoHeader.scala")

def checkFile(name: String) = {
val actualPath = (scalaSource.in(Compile).value / name).toString
val expectedPath = (resourceDirectory.in(Compile).value / s"${name}_expected").toString
val actualPath = ((Compile / scalaSource).value / name).toString
val expectedPath = ((Compile / resourceDirectory).value / s"${name}_expected").toString

val actual = scala.io.Source.fromFile(actualPath).mkString
val expected = scala.io.Source.fromFile(expectedPath).mkString
Expand Down
10 changes: 5 additions & 5 deletions src/sbt-test/sbt-header/incremental/test.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ stripHeader := {
stripHeader("HasHeader.scala")

def stripHeader(name: String) = {
val actualPath = (scalaSource.in(Compile).value / name).toString
val headerDropped = (resourceDirectory.in(Compile).value / s"${name}_headerdropped").toString
val actualPath = ((Compile / scalaSource).value / name).toString
val headerDropped = ((Compile / resourceDirectory).value / s"${name}_headerdropped").toString

Files.delete(file(actualPath).toPath)
Files.copy(file(headerDropped).toPath, file(actualPath).toPath)
Expand All @@ -24,8 +24,8 @@ checkFileContents := {
checkFile("HasNoHeader.scala")

def checkFile(name: String) = {
val actualPath = (scalaSource.in(Compile).value / name).toString
val expectedPath = (resourceDirectory.in(Compile).value / s"${name}_expected").toString
val actualPath = ((Compile / scalaSource).value / name).toString
val expectedPath = ((Compile / resourceDirectory).value / s"${name}_expected").toString

val actual = scala.io.Source.fromFile(actualPath).mkString
val expected = scala.io.Source.fromFile(expectedPath).mkString
Expand All @@ -41,6 +41,6 @@ checkFileContents := {
}

removeFile := {
val actualPath = scalaSource.in(Compile).value / "HasNoHeader.scala"
val actualPath = (Compile / scalaSource).value / "HasNoHeader.scala"
Files.delete(actualPath.toPath)
}
4 changes: 2 additions & 2 deletions src/sbt-test/sbt-header/no-file-extensions/test.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ checkFileContents := {
checkFile(".routes")

def checkFile(name: String) = {
val actualPath = (resourceDirectory.in(Compile).value / name).toString
val expectedPath = (resourceDirectory.in(Compile).value / s"${name}_expected").toString
val actualPath = ((Compile / resourceDirectory).value / name).toString
val expectedPath = ((Compile / resourceDirectory).value / s"${name}_expected").toString

val actual = scala.io.Source.fromFile(actualPath).mkString
val expected = scala.io.Source.fromFile(expectedPath).mkString
Expand Down
4 changes: 2 additions & 2 deletions src/sbt-test/sbt-header/override-default-mappings/test.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ checkFileContents := {
checkFile("HasNoHeader.scala")

def checkFile(name: String) = {
val actualPath = (scalaSource.in(Compile).value / name).toString
val expectedPath = (resourceDirectory.in(Compile).value / s"${name}_expected").toString
val actualPath = ((Compile / scalaSource).value / name).toString
val expectedPath = ((Compile / resourceDirectory).value / s"${name}_expected").toString

val actual = scala.io.Source.fromFile(actualPath).mkString
val expected = scala.io.Source.fromFile(expectedPath).mkString
Expand Down
12 changes: 6 additions & 6 deletions src/sbt-test/sbt-header/simple/test.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ unmanagedResources / excludeFilter := (_ => false)
val checkFileContents = taskKey[Unit]("Verify file contents match expected contents")

checkFileContents := {
checkFile("HasHeader.scala", scalaSource.in(Compile).value)
checkFile("HasNoHeader.scala", scalaSource.in(Compile).value)
checkFile("routes", resourceDirectory.in(Compile).value)
checkFile(".routes", resourceDirectory.in(Compile).value) // does not have extension, file name is only ".routes"
checkFile(".some.routes", resourceDirectory.in(Compile).value) // hidden file with extension .routes
checkFile("HasHeader.scala", (Compile / scalaSource).value)
checkFile("HasNoHeader.scala", (Compile / scalaSource).value)
checkFile("routes", (Compile / resourceDirectory).value)
checkFile(".routes", (Compile / resourceDirectory).value) // does not have extension, file name is only ".routes"
checkFile(".some.routes", (Compile / resourceDirectory).value) // hidden file with extension .routes

def checkFile(name: String, sourceDir: sbt.File) = {
val actualPath = (sourceDir / name).toString
val expectedPath = (resourceDirectory.in(Compile).value / s"${name}_expected").toString
val expectedPath = ((Compile / resourceDirectory).value / s"${name}_expected").toString

val actual = scala.io.Source.fromFile(actualPath).mkString
val expected = scala.io.Source.fromFile(expectedPath).mkString
Expand Down
4 changes: 2 additions & 2 deletions src/sbt-test/sbt-header/xml/test.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ checkFileContents := {
checkFile("order-no-header-no-xmldeclaration.xml")

def checkFile(name: String) = {
val actualPath = (resourceDirectory.in(Compile).value / name).toString
val expectedPath = (resourceDirectory.in(Compile).value / s"${name}_expected").toString
val actualPath = ((Compile / resourceDirectory).value / name).toString
val expectedPath = ((Compile / resourceDirectory).value / s"${name}_expected").toString

val actual = scala.io.Source.fromFile(actualPath).mkString
val expected = scala.io.Source.fromFile(expectedPath).mkString
Expand Down

0 comments on commit d1b5c25

Please sign in to comment.