-
Notifications
You must be signed in to change notification settings - Fork 43
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
Improve/document ScalafixTestkitPlugin usage #120
Conversation
Since SemanticdbPlugin sets an explicit -P:semanticdb:targetroot, we cannot simply capture `scalacOptions` from the test runner as it does not match the flags used in the input project.
lazy val tests = project | ||
.settings( | ||
libraryDependencies += | ||
"ch.epfl.scala" % "scalafix-testkit" % Versions.scalafixVersion % Test cross CrossVersion.full, | ||
scalafixTestkitOutputSourceDirectories := | ||
sourceDirectories.in(output, Compile).value, | ||
scalafixTestkitInputSourceDirectories := | ||
sourceDirectories.in(input, Compile).value, | ||
scalafixTestkitInputClasspath := | ||
fullClasspath.in(input, Compile).value, | ||
scalafixTestkitInputScalacOptions := | ||
scalacOptions.in(input, Compile).value, | ||
scalafixTestkitInputScalaVersion := | ||
scalaVersion.in(input, Compile).value, | ||
mainClass in (Test, run) := Some("fix.IntputOutputSuite") | ||
) | ||
.dependsOn(input, rules) | ||
.enablePlugins(ScalafixTestkitPlugin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not familiar with Docusaurus, but could we capture that somehow (like https://developer.lightbend.com/docs/paradox/current/directives/snippets.html) into https://github.com/scalacenter/scalafix/blob/master/docs/developers/setup.md#library-api? I guess it's tricky because it's not in the same repo anyway...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's nothing like this out of the box that I'm aware of. It's possible to implement somehing like this on top of mdoc with custom modifiers https://scalameta.org/mdoc/docs/modifiers.html#stringmodifier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, thanks for the pointer!
Regarding the repo separation: the situation might be exceptional these days as the sbt plugin sees more activity/features than scalafix-core or scalafix-rules, but would it make sense to version-control the sbt-specific doc here, and have a hook that pushes it to the gh-pages
branch of the scalafix
repo? This might be particularly interesting with scalacenter/scalafix#1146.
04df24c
to
4278a1f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 This is a great idea
|
||
object IntputOutputSuite { | ||
def main(args: Array[String]): Unit = { | ||
if (Array("--save-expect").sameElements(args)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks generically useful, would it make sense to expose this somehow as an sbt-scalafix task or command where ScalafixTeskitPlugin is enabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed! scalacenter/scalafix#1147
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it just occured to me that I don't need to inline all this in the scripted, as I should be able to reuse RuleSuite#main()
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... and no! now I remember why I didn't do it - https://github.com/scalacenter/scalafix/blob/17a187ccc3e8d8a6acb7b57b4e8fb6e254e4ecd5/scalafix-tests/unit/src/test/scala/scalafix/tests/rule/RuleSuite.scala#L8-L29 is not part of testkit
, so it's not available here!
lazy val tests = project | ||
.settings( | ||
libraryDependencies += | ||
"ch.epfl.scala" % "scalafix-testkit" % Versions.scalafixVersion % Test cross CrossVersion.full, | ||
scalafixTestkitOutputSourceDirectories := | ||
sourceDirectories.in(output, Compile).value, | ||
scalafixTestkitInputSourceDirectories := | ||
sourceDirectories.in(input, Compile).value, | ||
scalafixTestkitInputClasspath := | ||
fullClasspath.in(input, Compile).value, | ||
scalafixTestkitInputScalacOptions := | ||
scalacOptions.in(input, Compile).value, | ||
scalafixTestkitInputScalaVersion := | ||
scalaVersion.in(input, Compile).value, | ||
mainClass in (Test, run) := Some("fix.IntputOutputSuite") | ||
) | ||
.dependsOn(input, rules) | ||
.enablePlugins(ScalafixTestkitPlugin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's nothing like this out of the box that I'm aware of. It's possible to implement somehing like this on top of mdoc with custom modifiers https://scalameta.org/mdoc/docs/modifiers.html#stringmodifier
@@ -12,15 +12,25 @@ object ScalafixTestkitPlugin extends AutoPlugin { | |||
object autoImport { | |||
val scalafixTestkitInputClasspath = | |||
taskKey[Classpath]("Classpath of input project") | |||
val scalafixTestkitInputScalacOptions = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
No description provided.