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

Improve/document ScalafixTestkitPlugin usage #120

Merged
merged 3 commits into from
Jun 7, 2020

Conversation

bjaglin
Copy link
Collaborator

@bjaglin bjaglin commented Jun 1, 2020

No description provided.

bjaglin and others added 3 commits May 31, 2020 18:00
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.
Comment on lines +21 to +38
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)
Copy link
Collaborator Author

@bjaglin bjaglin Jun 1, 2020

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...

Copy link
Contributor

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

Copy link
Collaborator Author

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.

@bjaglin bjaglin marked this pull request as ready for review June 1, 2020 09:49
@bjaglin bjaglin force-pushed the testkit-setup branch 2 times, most recently from 04df24c to 4278a1f Compare June 1, 2020 13:03
@bjaglin bjaglin requested review from olafurpg and mlachkar June 3, 2020 10:22
Copy link
Contributor

@olafurpg olafurpg left a 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)) {
Copy link
Contributor

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

@bjaglin bjaglin Jun 3, 2020

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()...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +21 to +38
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)
Copy link
Contributor

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 =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@bjaglin bjaglin merged commit 9d7d177 into scalacenter:master Jun 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants