Skip to content

Commit 20a3b0b

Browse files
authored
Merge pull request #173 from olafurpg/dotty
Add support to expected output that only compiles with Dotty.
2 parents 29ec22c + 46da97c commit 20a3b0b

File tree

5 files changed

+33
-4
lines changed

5 files changed

+33
-4
lines changed

build.sbt

+13
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,17 @@ lazy val testsOutput = project
260260
)
261261
.dependsOn(testsShared)
262262

263+
lazy val testsOutputDotty = project
264+
.in(file("scalafix-tests/output-dotty"))
265+
.settings(
266+
allSettings,
267+
noPublish,
268+
scalaVersion := "0.1.1-bin-20170530-f8f52cc-NIGHTLY",
269+
libraryDependencies := libraryDependencies.value.map(_.withDottyCompat()),
270+
scalacOptions := Nil
271+
)
272+
.disablePlugins(ScalahostSbtPlugin)
273+
263274
lazy val unit = project
264275
.in(file("scalafix-tests/unit"))
265276
.settings(
@@ -282,6 +293,8 @@ lazy val unit = project
282293
sourceDirectory.in(testsInput, Compile).value,
283294
"outputSourceroot" ->
284295
sourceDirectory.in(testsOutput, Compile).value,
296+
"outputDottySourceroot" ->
297+
sourceDirectory.in(testsOutputDotty, Compile).value,
285298
"testsInputResources" -> resourceDirectory.in(testsInput, Compile).value,
286299
"mirrorClasspath" -> classDirectory.in(testsInput, Compile).value
287300
),

project/plugins.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.6.1")
33
resolvers += Resolver.bintrayIvyRepo("scalameta", "sbt-plugins") // only needed for scalatex 0.3.8-pre
44
addSbtPlugin("com.lihaoyi" % "scalatex-sbt-plugin" % "0.3.8-pre")
55
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0-M15")
6-
addSbtPlugin("org.wartremover" % "sbt-wartremover" % "1.2.1")
76
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")
87
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "1.1")
98
addSbtPlugin("me.lessis" % "bintray-sbt" % "0.3.0")
109
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "1.2.0")
10+
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.1.1")
1111
addSbtPlugin("org.scalameta" % "sbt-scalahost" % Dependencies.scalametaV)
1212

1313
resolvers += Resolver.bintrayIvyRepo("duhemm", "sbt-plugins")

scalafix-testkit/src/main/scala/scalafix/testkit/SemanticRewriteSuite.scala

+15-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ package scalafix
22
package testkit
33

44
import scala.meta._
5+
import org.scalameta.logger
56
import org.scalatest.BeforeAndAfterAll
67
import org.scalatest.FunSuite
78

89
abstract class SemanticRewriteSuite(
910
val mirror: Database,
1011
val inputSourceroot: AbsolutePath,
11-
val expectedOutputSourceroot: AbsolutePath
12+
val expectedOutputSourceroot: Seq[AbsolutePath]
1213
) extends FunSuite
1314
with DiffAssertions
1415
with BeforeAndAfterAll { self =>
@@ -27,7 +28,19 @@ abstract class SemanticRewriteSuite(
2728
}
2829
val expected =
2930
new String(
30-
expectedOutputSourceroot.resolve(diffTest.filename).readAllBytes)
31+
expectedOutputSourceroot
32+
.map(_.resolve(diffTest.filename))
33+
.find(_.isFile)
34+
.map(_.readAllBytes)
35+
.getOrElse {
36+
val tried = expectedOutputSourceroot
37+
.map(_.resolve(diffTest.filename))
38+
.mkString("\n")
39+
sys.error(
40+
s"""Missing expected output file for test ${diffTest.filename}. Tried:
41+
|$tried""".stripMargin)
42+
}
43+
)
3144
assertNoDiff(obtained, expected)
3245
}
3346
}

scalafix-tests/unit/src/test/scala/scalafix/tests/SemanticTests.scala

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ class SemanticTests
77
extends SemanticRewriteSuite(
88
Database.load(Classpath(AbsolutePath(BuildInfo.mirrorClasspath))),
99
AbsolutePath(BuildInfo.inputSourceroot),
10-
AbsolutePath(BuildInfo.outputSourceroot)
10+
Seq(
11+
AbsolutePath(BuildInfo.outputSourceroot),
12+
AbsolutePath(BuildInfo.outputDottySourceroot)
13+
)
1114
) {
1215
runAllTests()
1316
}

0 commit comments

Comments
 (0)