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

add testing or at least a demo to this repo #8

Open
SethTisue opened this issue Aug 14, 2018 · 4 comments
Open

add testing or at least a demo to this repo #8

SethTisue opened this issue Aug 14, 2018 · 4 comments

Comments

@SethTisue
Copy link
Collaborator

there is advice on this in the “Compiler Plugins 101” slides, but it might as well be in this repo directly, too

@hrhino has suggested using this to test:

scalacOptions in Test ++= Seq(
  s"-Xplugin:${(packageBin in Compile).value}",
  s"-Jdummy=${System.currentTimeMillis()}",
)

the -Jdummy thing is an attempt to fool sbt into rebuilding when necessary; it's copied (perhaps cargo-culted) from scala-continuations; I should see whether it is necessary on modern sbt, whether it actually works, and whether there's a better, less kludgey way

@SethTisue SethTisue self-assigned this Aug 14, 2018
@SethTisue
Copy link
Collaborator Author

I have found by experiment that it is in fact necessary to do something so that changing the plugin causes code in src/test to be rebuilt

@SethTisue
Copy link
Collaborator Author

maybe the best thing is actually to put the test code in a separate subproject, rather than try to subvert sbt's usual expectations

@SethTisue
Copy link
Collaborator Author

I tried the subproject thing:

val commonSettings = Seq(
  organization := "com.lightbend",
  version := "0.0.1",
  crossScalaVersions := Seq("2.12.6", "2.13.0-M4"),
  scalaVersion := crossScalaVersions.value.head,
  crossVersion := CrossVersion.patch,
  scalacOptions ++= Seq(
    "-encoding", "utf-8",
    "-deprecation",
    "-unchecked",
    "-feature",
    "-Xlint",
    "-Xfatal-warnings",
    "-Ywarn-value-discard"
  ))

lazy val plugin =
  project.in(file("plugin"))
    .settings(commonSettings)
    .settings(
      name := "cloc-plugin",
      libraryDependencies +=
        "org.scala-lang" % "scala-compiler" % scalaVersion.value % "provided"
    )

lazy val tests =
  project.in(file("tests"))
    .settings(commonSettings)
    .settings(
      scalacOptions ++= Seq(
        s"-Xplugin:${(plugin / Compile / packageBin).value}",
        s"-Xplugin-require:cloc"
      ))
    .dependsOn(plugin)

but it didn't help

@SethTisue
Copy link
Collaborator Author

SethTisue commented Aug 15, 2018

I see kind-projector does

scalacOptions in Test ++= {
  val jar = (packageBin in Compile).value
  Seq(s"-Xplugin:${jar.getAbsolutePath}", s"-Jdummy=${jar.lastModified}") // ensures recompile
}

and so does better-monadic-for

@SethTisue SethTisue removed their assignment Aug 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant