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

Clean up tests #165

Merged
merged 14 commits into from
May 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
pipeline:
tests:
image: scalaplatform/scala:1.2
image: olafurpg/scala:0.1
environment:
- BINTRAY_USERNAME=foo_user
- BINTRAY_PASSWORD=foo_password
pull: true
commands:
- git fetch --tags && git log | head -n 20
- ./scalafmt --test
- /usr/bin/sbt $CI_TEST
- ./bin/runci.sh $CI_TEST

publish:
image: olafurpg/scalafix:0.3.0
Expand All @@ -30,3 +29,4 @@ matrix:
CI_SCALA_VERSION: 2.12.2
- CI_TEST: ci-slow
CI_SCALA_VERSION: 2.11.11
- CI_TEST: scalafmt
2 changes: 1 addition & 1 deletion .drone.yml.sig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
eyJhbGciOiJIUzI1NiJ9.cGlwZWxpbmU6CiAgdGVzdHM6CiAgICBpbWFnZTogc2NhbGFwbGF0Zm9ybS9zY2FsYToxLjIKICAgIGVudmlyb25tZW50OgogICAgICAtIEJJTlRSQVlfVVNFUk5BTUU9Zm9vX3VzZXIKICAgICAgLSBCSU5UUkFZX1BBU1NXT1JEPWZvb19wYXNzd29yZAogICAgcHVsbDogdHJ1ZQogICAgY29tbWFuZHM6CiAgICAgIC0gZ2l0IGZldGNoIC0tdGFncyAmJiBnaXQgbG9nIHwgaGVhZCAtbiAyMAogICAgICAtIC4vc2NhbGFmbXQgLS10ZXN0CiAgICAgIC0gL3Vzci9iaW4vc2J0ICRDSV9URVNUCgogIHB1Ymxpc2g6CiAgICBpbWFnZTog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ogICAgd2hlbjoKICAgICAgZXZlbnQ6IFtwdXNoLCB0YWddCiAgICAgIGJyYW5jaDogW21hc3Rlcl0KCm1hdHJpeDoKICBpbmNsdWRlOgogICAgLSBDSV9URVNUOiBjaS1mYXN0CiAgICAgIENJX1NDQUxBX1ZFUlNJT046IDIuMTEuMTEKICAgICAgQ0lfUFVCTElTSDogdHJ1ZQogICAgLSBDSV9URVNUOiBjaS1mYXN0CiAgICAgIENJX1NDQUxBX1ZFUlNJT046IDIuMTIuMgogICAgLSBDSV9URVNUOiBjaS1zbG93CiAgICAgIENJX1NDQUxBX1ZFUlNJT046IDIuMTEuMTEKICAgIC0gQ0lfVEVTVDogc2NhbGFmbXQK.SxfxsZ9QYuIR2jIvU5VUhC-R6Et1O3zQ3Vtf3MjWjjQ
11 changes: 11 additions & 0 deletions .jvmopts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-Dfile.encoding=UTF8
-Xms1G
-Xmx6G
-XX:MaxPermSize=512M
-XX:ReservedCodeCacheSize=250M
-XX:+TieredCompilation
-XX:-UseGCOverheadLimit
# effectively adds GC to Perm space
-XX:+CMSClassUnloadingEnabled
# must be enabled for CMSClassUnloadingEnabled to work
-XX:+UseConcMarkSweepGC
3 changes: 3 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ align.tokens = [
]
onTestFailure = "To fix this, run `./scalafmt` from the project base directory"
optIn.annotationNewlines = true
project.excludeFilters = [
scalafix-tests/output
]
48 changes: 27 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
language: scala
sudo: false
cache:
directories:
- $HOME/.ivy2/cache
- $HOME/.sbt/boot/
git:
submodules: false
scala:
- 2.11.8
before_install:
- ./bin/setupCI.sh
script:
- ./bin/testAll.sh
after_success:
- codecov
- ./bin/runci.sh $CI_TEST
jdk:
- oraclejdk7
notifications:
email:
- olafurpg@gmail.com
branches:
only:
- master
- oraclejdk8
env:
matrix:
- CI_TEST: ci-fast
CI_SCALA_VERSION: 2.11.11
CI_PUBLISH: true
- CI_TEST: ci-fast
CI_SCALA_VERSION: 2.12.2
- CI_TEST: ci-slow
CI_SCALA_VERSION: 2.11.11
- CI_TEST: scalafmt

cache:
directories:
- $HOME/.sbt/0.13/dependency
- $HOME/.sbt/boot/scala*
- $HOME/.sbt/launchers
- $HOME/.ivy2/cache
- $HOME/.coursier

before_cache:
- du -h -d 1 $HOME/.ivy2/cache
- du -h -d 2 $HOME/.sbt/
- find $HOME/.sbt -name "*.lock" -type f -delete
- find $HOME/.ivy2/cache -name "ivydata-*.properties" -type f -delete
- find $HOME/.ivy2/cache -name "*scalafix*.xml" -type f -delete
- rm -rf $HOME/.ivy2/local
13 changes: 13 additions & 0 deletions bin/runci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
set -eux
TEST=${1}

case "$TEST" in
"scalafmt" )
./scalafmt --test
;;
* )
sbt $TEST
;;
esac

137 changes: 110 additions & 27 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import sbt.ScriptedPlugin
import sbt.ScriptedPlugin._

import Dependencies._
import xsbti.Position
import xsbti.Reporter
import xsbti.Severity
organization in ThisBuild := "ch.epfl.scala"
version in ThisBuild := customScalafixVersion.getOrElse(
version.in(ThisBuild).value)
Expand Down Expand Up @@ -84,13 +86,20 @@ lazy val allSettings = List(
version := sys.props.getOrElse("scalafix.version", version.value),
resolvers += Resolver.bintrayRepo("scalameta", "maven"),
resolvers += Resolver.sonatypeRepo("releases"),
resolvers ~= { old =>
if (isDroneCI) {
println(s"Using resolver: $epflArtifactory")
epflArtifactory +: old
} else old
},
triggeredMessage in ThisBuild := Watched.clearWhenTriggered,
scalacOptions := compilerOptions,
scalacOptions ++= compilerOptions,
scalacOptions in (Compile, console) := compilerOptions :+ "-Yrepl-class-based",
libraryDependencies += scalatest % Test,
testOptions in Test += Tests.Argument("-oD"),
scalaVersion := ciScalaVersion.getOrElse(scala212),
crossScalaVersions := crossVersions,
scalametaSemanticdb := ScalametaSemanticdb.Disabled,
updateOptions := updateOptions.value.withCachedResolution(true)
)

Expand Down Expand Up @@ -176,7 +185,7 @@ lazy val `scalafix-sbt` = project
ScriptedPlugin.scriptedSettings,
sbtPlugin := true,
testQuick := {}, // these test are slow.
test in IntegrationTest := {
test.in(IntegrationTest) := {
RunSbtCommand(
s"; plz $scala212 publishLocal " +
"; very scalafix-sbt/scripted"
Expand Down Expand Up @@ -215,33 +224,102 @@ lazy val testkit = project
reflect
)

lazy val tests = project
.configure(setId)
.configs(IntegrationTest)
lazy val testsDeps = List(
// integration property tests
"org.renucci" %% "scala-xml-quote" % "0.1.3",
"org.typelevel" %% "catalysts-platform" % "0.0.5",
"com.typesafe.slick" %% "slick" % "3.2.0-M2",
"com.chuusai" %% "shapeless" % "2.3.2",
"org.scalacheck" %% "scalacheck" % "1.13.4"
)

lazy val testsShared = project
.in(file("scalafix-tests/shared"))
.settings(
allSettings,
noPublish
)

lazy val testsInput = project
.in(file("scalafix-tests/input"))
.settings(
allSettings,
noPublish,
Defaults.itSettings,
libraryDependencies += scalatest % IntegrationTest,
test.in(IntegrationTest) := RunSbtCommand(
s"; plz $scala212 publishLocal " +
s"; such scalafix-sbt/publishLocal " +
"; tests/it:testQuick" // hack to workaround cyclic dependencies in test.
)(state.value),
parallelExecution in Test := true,
scalametaSourceroot := sourceDirectory.in(Compile).value,
scalametaSemanticdb := ScalametaSemanticdb.Fat,
scalacOptions ~= (_.filterNot(_ == "-Yno-adapted-args")),
// TODO: Remove once scala-xml-quote is merged into scala-xml
resolvers += Resolver.bintrayRepo("allanrenucci", "maven"),
libraryDependencies ++= Seq(
scalahost % Test,
// integration property tests
"org.renucci" %% "scala-xml-quote" % "0.1.3" % Test,
"org.typelevel" %% "catalysts-platform" % "0.0.5" % Test,
"com.typesafe.slick" %% "slick" % "3.2.0-M2" % Test,
"com.chuusai" %% "shapeless" % "2.3.2" % Test,
"org.scalacheck" %% "scalacheck" % "1.13.4" % Test
)
libraryDependencies ++= testsDeps
)
.dependsOn(testsShared)

lazy val testsOutput = project
.in(file("scalafix-tests/output"))
.settings(
allSettings,
noPublish,
resolvers := resolvers.in(testsInput).value,
libraryDependencies := libraryDependencies.in(testsInput).value
)
.dependsOn(testsShared)

lazy val unit = project
.in(file("scalafix-tests/unit"))
.settings(
allSettings,
noPublish,
fork := false,
javaOptions := Nil,
buildInfoPackage := "scalafix.tests",
buildInfoObject := "BuildInfo",
compileInputs.in(Compile, compile) :=
compileInputs
.in(Compile, compile)
.dependsOn(
compile.in(testsInput, Compile),
compile.in(testsOutput, Compile)
)
.value,
buildInfoKeys := Seq[BuildInfoKey](
"inputSourceroot" ->
sourceDirectory.in(testsInput, Compile).value,
"outputSourceroot" ->
sourceDirectory.in(testsOutput, Compile).value,
"testsInputResources" -> resourceDirectory.in(testsInput, Compile).value,
"mirrorClasspath" -> classDirectory.in(testsInput, Compile).value
),
libraryDependencies ++= testsDeps
)
.enablePlugins(BuildInfoPlugin)
.dependsOn(
testsInput % Scalameta,
cli,
testkit
)

lazy val integration = project
.in(file("scalafix-tests/integration"))
.configs(IntegrationTest)
.settings(
allSettings,
noPublish,
Defaults.itSettings,
test.in(IntegrationTest) := {
test
.in(IntegrationTest)
.dependsOn(
publishLocal.in(core),
publishLocal.in(cli),
publishLocal.in(reflect),
publishLocal.in(`scalafix-sbt`)
)
.value
},
libraryDependencies += scalatest % IntegrationTest
)
.dependsOn(
testsInput % Scalameta,
core,
reflect,
testkit
Expand Down Expand Up @@ -285,8 +363,7 @@ def exposePaths(projectName: String,
fullClasspath in config := {
val defaultValue = (fullClasspath in config).value
val classpath = defaultValue.files.map(_.getAbsolutePath)
val scalaLibrary =
classpath.map(_.toString).find(_.contains("scala-library")).get
val scalaLibrary = classpath.find(_.contains("scala-library")).get
System.setProperty("sbt.paths.scalalibrary.classes", scalaLibrary)
System.setProperty(prefix + "classes",
classpath.mkString(java.io.File.pathSeparator))
Expand Down Expand Up @@ -329,7 +406,13 @@ lazy val gitPushTag = taskKey[Unit]("Push to git tag")

def setId(project: Project): Project = {
val newId = "scalafix-" + project.id
project.copy(base = file(newId)).settings(moduleName := newId)
project
.copy(base = file(newId))
.settings(moduleName := newId)
.disablePlugins(ScalahostSbtPlugin)
}

def customScalafixVersion = sys.props.get("scalafix.version")
def isDroneCI = sys.env.get("CI").exists(_ == "DRONE")
def epflArtifactory =
MavenRepository("epfl-artifactory",
"http://scala-webapps.epfl.ch:8081/artifactory/dbuild/")
7 changes: 4 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "1.1")
addSbtPlugin("me.lessis" % "bintray-sbt" % "0.3.0")
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "1.2.0")
addSbtPlugin("org.scalameta" % "sbt-scalahost" % Dependencies.scalametaV)

resolvers += Resolver.bintrayIvyRepo("duhemm", "sbt-plugins")
addSbtPlugin("org.duhemm" % "sbt-errors-summary" % "0.2.0")

// TODO(olafur) re-enable scoverage.
// scoverage is disabled because it messes up with scalafix-nsc
//addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.0.1")
libraryDependencies += "org.scala-sbt" % "scripted-plugin" % sbtVersion.value
1 change: 1 addition & 0 deletions project/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0-M15")
unmanagedSources.in(Compile) += baseDirectory.value / ".." / "Dependencies.scala"
4 changes: 2 additions & 2 deletions readme/Changelog.scalatex
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
@li
Configuration in .scalafix.conf has been greatly improved to support a wide range
of options.
Examples, see @sect.ref{patches}, @sect.ref{imports} and @sect.ref{All options}.
Examples, see @sect.ref{patches}, @code{imports} (now removed) and @sect.ref{All options}.
@sect{0.2.1}
@ul
@li
Expand All @@ -127,7 +127,7 @@
@sect{0.2.0}
@ul
@li
First semantic rewrite! See @sect.ref{ExplicitImplicit}
First semantic rewrite! See @sect.ref{ExplicitReturnTypes}.
@li
Removed command line interface in favor of compiler plugin.
Why? To run semantic rewrites, scalafix needs to compile source files.
Expand Down
29 changes: 0 additions & 29 deletions readme/Configuration.scalatex
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,6 @@
"scala:scalafix.rewrite.ProcedureSyntax"
]

@sect{imports}

@b{NOTE.} This feature is new and may still have bugs that cause rewritten
code to not compile. Please report back you bump into issues.

@p
Scalafix can organize imports.
If you use import patches such as @code{Add/RemoveGlobalImport},
you need to allow scalafix to organize you imports.
To minimize the diff from import patches, it's best to run scalafix once
with organize imports enabled and no zero patches.
@config
// Group and sort imports
imports.organize = true
// Example relative import: `import collection.immutable`
// Expanded: `import scala.collection.immutable`
imports.expandRelative = true
// Removes global imports that -Ywarn-unused-import complains about
// Requires sbt-scalafix/ScalafixMirror
imports.removeUnused = true
// Groups are separated by a blank line, example:
// import com.a
// import com.b
//
// import scala.collection.immutable._
imports.groups = [
"com.mycompany.*"
"scala\\..*"
]
@sect{patches}
For simple use-cases, it's possible to write custom rewrites directly
.scalafix.conf.
Expand Down
Loading