Merge pull request #2910 from eed3si9n/wip/212

[sbt 1.0] Use Scala 2.12.1
This commit is contained in:
eugene yokota 2017-01-15 22:24:33 -05:00 committed by GitHub
commit 9044d6c07a
34 changed files with 147 additions and 113 deletions

View File

@ -34,7 +34,7 @@ def buildLevelSettings: Seq[Setting[_]] = inThisBuild(Seq(
))
def commonSettings: Seq[Setting[_]] = Seq[SettingsDefinition](
scalaVersion := scala211,
scalaVersion := baseScalaVersion,
componentID := None,
resolvers += Resolver.typesafeIvyRepo("releases"),
resolvers += Resolver.sonatypeRepo("snapshots"),
@ -43,7 +43,7 @@ def commonSettings: Seq[Setting[_]] = Seq[SettingsDefinition](
testOptions += Tests.Argument(TestFrameworks.ScalaCheck, "-w", "1"),
javacOptions in compile ++= Seq("-target", "6", "-source", "6", "-Xlint", "-Xlint:-serial"),
incOptions := incOptions.value.withNameHashing(true),
crossScalaVersions := Seq(scala211),
crossScalaVersions := Seq(baseScalaVersion),
bintrayPackage := (bintrayPackage in ThisBuild).value,
bintrayRepository := (bintrayRepository in ThisBuild).value,
mimaDefaultSettings,
@ -113,7 +113,7 @@ lazy val testingProj = (project in file("testing")).
lazy val testAgentProj = (project in file("testing") / "agent").
settings(
minimalSettings,
crossScalaVersions := Seq(scala211),
crossScalaVersions := Seq(baseScalaVersion),
crossPaths := false,
autoScalaLibrary := false,
name := "Test Agent",
@ -228,7 +228,7 @@ lazy val sbtProj = (project in file("sbt")).
baseSettings,
name := "sbt",
normalizedName := "sbt",
crossScalaVersions := Seq(scala211),
crossScalaVersions := Seq(baseScalaVersion),
crossPaths := false
).
configure(addSbtCompilerBridge)
@ -341,8 +341,8 @@ lazy val otherProjects: ScopeFilter = ScopeFilter(
)
def customCommands: Seq[Setting[_]] = Seq(
commands += Command.command("setupBuildScala211") { state =>
s"""set scalaVersion in ThisBuild := "$scala211" """ ::
commands += Command.command("setupBuildScala212") { state =>
s"""set scalaVersion in ThisBuild := "$scala212" """ ::
state
},
safeUnitTests := {

View File

@ -8,10 +8,10 @@ import scala.tools.nsc.reporters.StoreReporter
import sbt.io.IO
object EvalTest extends Properties("eval") {
private[this] val reporter = new StoreReporter
class EvalTest extends Properties("eval") {
private[this] lazy val reporter = new StoreReporter
import reporter.{ ERROR, Info }
private[this] val eval = new Eval(_ => reporter, None)
private[this] lazy val eval = new Eval(_ => reporter, None)
property("inferred integer") = forAll { (i: Int) =>
val result = eval.eval(i.toString)

View File

@ -7,7 +7,7 @@ checkPom := {
val tpe = pom \\ "type"
if(!tpe.isEmpty)
error("Expected no <type> sections, got: " + tpe + " in \n\n" + pom)
sys.error("Expected no <type> sections, got: " + tpe + " in \n\n" + pom)
}
val b = ( <b/>)
val a = <aaa

View File

@ -6,7 +6,7 @@ lazy val checkPom = taskKey[Unit]("check pom to ensure no <type> sections are ge
val pom = xml.XML.loadFile(pomFile)
val tpe = pom \\ "type"
if(!tpe.isEmpty)
error("Expected no <type> sections, got: " + tpe + " in \n\n" + pom)
sys.error("Expected no <type> sections, got: " + tpe + " in \n\n" + pom)
}
val b = ( <b/>)

View File

@ -136,6 +136,8 @@ object ParseKey extends Properties("Key parser test") {
structure <- f(scopes, env, current)
} yield structure
// pickN is a function that randomly picks load % items from the from sequence.
// The rest of the tests expect at least one item, so I changed it to return 1 in case of 0.
def pickN[T](load: Double, from: Seq[T]): Gen[Seq[T]] =
pick((load * from.size).toInt, from)
pick(Math.max((load * from.size).toInt, 1), from)
}

View File

@ -12,7 +12,8 @@ import Gen._
// Notes:
// Generator doesn't produce cross-build project dependencies or do anything with the 'extra' axis
object TestBuild {
object TestBuild extends TestBuild
abstract class TestBuild {
val MaxTasks = 6
val MaxProjects = 7
val MaxConfigs = 5
@ -32,6 +33,7 @@ object TestBuild {
implicit val cGen = Arbitrary { genConfigs(idGen, MaxDepsGen, MaxConfigsGen) }
implicit val tGen = Arbitrary { genTasks(idGen, MaxDepsGen, MaxTasksGen) }
val seed = rng.Seed.random
final class Keys(val env: Env, val scopes: Seq[Scope]) {
override def toString = env + "\n" + scopes.mkString("Scopes:\n\t", "\n\t", "")
@ -53,7 +55,13 @@ object TestBuild {
new BuildUtil(keyIndex, data, env.root.uri, env.rootProject, getp, _.configurations.map(c => ConfigKey(c.name)), Relation.empty)
}
lazy val allAttributeKeys: Set[AttributeKey[_]] = data.data.values.flatMap(_.keys).toSet
lazy val allAttributeKeys: Set[AttributeKey[_]] = {
val x = data.data.values.flatMap(_.keys).toSet
if (x.isEmpty) {
sys.error("allAttributeKeys is empty")
}
x
}
lazy val (taskAxes, globalTaskAxis, onlyTaskAxis, multiTaskAxis) =
{
import collection.mutable
@ -170,6 +178,15 @@ object TestBuild {
def structure(env: Env, settings: Seq[Setting[_]], current: ProjectRef): Structure =
{
implicit val display = Def.showRelativeKey(current, env.allProjects.size > 1)
if (settings.isEmpty) {
try {
sys.error("settings is empty")
} catch {
case e: Throwable =>
e.printStackTrace
throw e
}
}
val data = Def.make(settings)(env.delegates, const(Nil), display)
val keys = data.allKeys((s, key) => ScopedKey(s, key))
val keyMap = keys.map(k => (k.key.label, k.key)).toMap[String, AttributeKey[_]]
@ -246,7 +263,7 @@ object TestBuild {
genAcyclic(maxDeps, xs, next :: acc)
}
def sequence[T](gs: Seq[Gen[T]]): Gen[Seq[T]] = Gen.parameterized { prms =>
wrap(gs map { g => g(prms) getOrElse sys.error("failed generator") })
delay(gs map { g => g(prms, seed) getOrElse sys.error("failed generator") })
}
type Inputs[A, T] = (T, Seq[T], Seq[A] => A)
}

View File

@ -129,7 +129,7 @@ class EmbeddedXmlSpec extends CheckIfParsedSpec {
| val pom = xml.XML.loadFile(pomFile)
| val tpe = pom \\ "type"
| if(!tpe.isEmpty)
| error("Expected no <type> sections, got: " + tpe + " in \n\n" + pom)
| sys.error("Expected no <type> sections, got: " + tpe + " in \n\n" + pom)
|}
|
|

View File

@ -9,7 +9,7 @@ import sbt.internal.util.MessageOnlyException
import scala.io.Source
class ErrorSpec extends AbstractSpec with ScalaCheck {
class ErrorSpec extends AbstractSpec {
implicit val splitter: SplitExpressions.SplitExpression = EvaluateConfigurations.splitExpressions
"Parser " should {

View File

@ -7,6 +7,8 @@ object Dependencies {
val scala293 = "2.9.3"
val scala210 = "2.10.6"
val scala211 = "2.11.8"
val scala212 = "2.12.1"
val baseScalaVersion = scala212
// sbt modules
private val ioVersion = "1.0.0-M9"
@ -87,8 +89,8 @@ object Dependencies {
val sjsonNewScalaJson = "com.eed3si9n" %% "sjson-new-scalajson" % "0.7.0"
val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.11.4"
val specs2 = "org.specs2" %% "specs2" % "2.3.11"
val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.13.4"
val specs2 = "org.specs2" %% "specs2" % "2.4.17"
val junit = "junit" % "junit" % "4.11"
private def scala211Module(name: String, moduleVersion: String) = Def setting (

View File

@ -32,7 +32,6 @@ object Util {
"-language:implicitConversions",
"-language:postfixOps",
"-Xfuture",
"-Yinline-warnings",
"-Yno-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",

View File

@ -11,7 +11,7 @@ object Marker extends AutoPlugin {
final def mark(baseKey: SettingKey[File]): Initialize[Task[Unit]] = baseKey map { base =>
val toMark = base / "ran"
if(toMark.exists)
error("Already ran (" + toMark + " exists)")
sys.error("Already ran (" + toMark + " exists)")
else
IO touch toMark
}

View File

@ -1,18 +1,21 @@
lazy val rootProj = (project in file(".")).
aggregate(libProj, fooPlugin)
aggregate(libProj, fooPlugin).
settings(
scalaVersion := "2.12.1"
)
lazy val libProj = (project in file("lib")).
settings(
name := "foo-lib",
scalaVersion := "2.11.8",
crossScalaVersions := Seq("2.11.8", "2.10.4")
scalaVersion := "2.12.1",
crossScalaVersions := Seq("2.12.1", "2.11.8")
)
lazy val fooPlugin =(project in file("sbt-foo")).
settings(
name := "sbt-foo",
sbtPlugin := true,
scalaVersion := "2.10.4",
crossScalaVersions := Seq("2.10.4")
scalaVersion := "2.12.1",
crossScalaVersions := Seq("2.12.1")
)

View File

@ -1,46 +1,38 @@
> + compile
$ exists lib/target/scala-2.12
$ exists lib/target/scala-2.11
$ exists lib/target/scala-2.10
$ exists sbt-foo/target/scala-2.10
$ exists sbt-foo/target/scala-2.12
-$ exists sbt-foo/target/scala-2.11
> clean
> + libProj/compile
$ exists lib/target/scala-2.12
$ exists lib/target/scala-2.11
$ exists lib/target/scala-2.10
-$ exists sbt-foo/target/scala-2.10
-$ exists sbt-foo/target/scala-2.12
-$ exists sbt-foo/target/scala-2.11
> clean
> ++ 2.11.1 compile
$ exists lib/target/scala-2.11
-$ exists lib/target/scala-2.10
$ exists sbt-foo/target/scala-2.10
-$ exists sbt-foo/target/scala-2.11
> clean
> ++ 2.10.4 compile
> ++ 2.12.1 compile
$ exists lib/target/scala-2.12
-$ exists lib/target/scala-2.11
$ exists lib/target/scala-2.10
$ exists sbt-foo/target/scala-2.10
$ exists sbt-foo/target/scala-2.12
-$ exists sbt-foo/target/scala-2.11
> clean
> ++ 2.11.5 compile
> ++ 2.11.8 -v compile
$ exists lib/target/scala-2.11
-$ exists lib/target/scala-2.10
$ exists sbt-foo/target/scala-2.10
-$ exists lib/target/scala-2.12
# -$ exists sbt-foo/target/scala-2.12
-$ exists sbt-foo/target/scala-2.11
> clean
> ++ 2.11.5! compile
# > clean
# > ++ 2.11.8! compile
$ exists lib/target/scala-2.11
-$ exists lib/target/scala-2.10
-$ exists sbt-foo/target/scala-2.10
$ exists sbt-foo/target/scala-2.11
# $ exists lib/target/scala-2.11
# -$ exists lib/target/scala-2.12
# -$ exists sbt-foo/target/scala-2.12
# $ exists sbt-foo/target/scala-2.11

View File

@ -1,11 +0,0 @@
organization := "org.example"
name := "artifacta"
version := "1.0.0-SNAPSHOT"
publishArtifact in (Test,packageBin) := true
publishTo := Some(MavenCache("demo", ((baseDirectory in ThisBuild).value / "demo-repo")))
//Resolver.file("demo", (baseDirectory in ThisBuild).value / "demo-repo"))

View File

@ -1,7 +0,0 @@
libraryDependencies += "org.example" %% "artifacta" % "1.0.0-SNAPSHOT" withSources() classifier("tests")
externalResolvers := Seq(
MavenCache("demo", ((baseDirectory in ThisBuild).value / "demo-repo")),
DefaultMavenRepository
)

View File

@ -1,3 +1,3 @@
object B {
object B {
val y = A.x
}

View File

@ -1,6 +1,24 @@
def localCache =
def localCache =
ivyPaths := IvyPaths(baseDirectory.value, Some((baseDirectory in ThisBuild).value / "ivy" / "cache"))
val b = project.settings(localCache)
val b = project
.settings(
localCache,
scalaVersion := "2.11.8",
libraryDependencies += "org.example" %% "artifacta" % "1.0.0-SNAPSHOT" withSources() classifier("tests"),
externalResolvers := Seq(
MavenCache("demo", ((baseDirectory in ThisBuild).value / "demo-repo")),
DefaultMavenRepository
)
)
val a = project.settings(localCache)
val a = project
.settings(
localCache,
scalaVersion := "2.11.8",
organization := "org.example",
name := "artifacta",
version := "1.0.0-SNAPSHOT",
publishArtifact in (Test,packageBin) := true,
publishTo := Some(MavenCache("demo", ((baseDirectory in ThisBuild).value / "demo-repo")))
)

View File

@ -17,5 +17,5 @@ def check(ver: String) =
case f if f.getName contains "log4j-" => f.getName
}
if (log4j.size != 1 || !log4j.head.contains(ver))
error("Did not download the correct jar.")
sys.error("Did not download the correct jar.")
}

View File

@ -29,5 +29,5 @@ def checkPomRepositories(file: File, args: Seq[String], s: TaskStreams)
s.log.info("Extracted: " + extracted.mkString("\n\t", "\n\t", "\n"))
s.log.info("Expected: " + args.mkString("\n\t", "\n\t", "\n"))
extracted.find { e => !expected.exists(_.accept(e.root)) } map { "Repository should not be exported: " + _ } orElse
(expected.find { e => !extracted.exists(r => e.accept(r.root)) } map { "Repository should be exported: " + _ } ) foreach error
(expected.find { e => !extracted.exists(r => e.accept(r.root)) } map { "Repository should be exported: " + _ } ) foreach sys.error
}

View File

@ -12,6 +12,7 @@ lazy val sharedResolver: Resolver = {
lazy val common = project.
settings(customIvyPaths: _*).
settings(
scalaVersion := "2.11.8",
organization := "com.badexample",
name := "badexample",
version := "1.0-SNAPSHOT",
@ -29,6 +30,7 @@ lazy val common = project.
lazy val dependent = project.
settings(customIvyPaths: _*).
settings(
scalaVersion := "2.11.8",
// Uncomment the following to test the before/after
// updateOptions := updateOptions.value.withLatestSnapshots(false),
// Ignore the inter-project resolver, so we force to look remotely.

View File

@ -12,7 +12,7 @@ TaskKey[Unit]("checkUpdate") := {
val mods = report.configuration(Compile.name).get.allModules.map(_.name).toSet
val expected = Set("org.sat4j.pb", "org.sat4j.core")
if(mods != expected)
error("Expected modules " + expected + ", got: " + mods)
sys.error("Expected modules " + expected + ", got: " + mods)
}
TaskKey[Unit]("checkClasspath") := (dependencyClasspath in Compile map { cp =>
@ -20,5 +20,5 @@ TaskKey[Unit]("checkClasspath") := (dependencyClasspath in Compile map { cp =>
// Note: pb depends on tests artifact in core for no good reason. Previously this was not correctly added to the classpath.
val expected = Set("org.sat4j.pb-2.3.1.jar", "org.sat4j.core-2.3.1.jar", "org.sat4j.core-2.3.1-tests.jar")
if(jars != expected)
error("Expected jars " + expected + ", got: " + jars)
sys.error("Expected jars " + expected + ", got: " + jars)
}).value

View File

@ -5,9 +5,9 @@
val shouldExist = parser.parsed
val dir = (classDirectory in Compile).value
if((dir / "Anon.class").exists != shouldExist)
error("Top level class incorrect" )
sys.error("Top level class incorrect" )
else if( (dir / "Anon$1.class").exists != shouldExist)
error("Inner class incorrect" )
sys.error("Inner class incorrect" )
else
()
}

View File

@ -2,7 +2,7 @@ val root = (project in file("."))
TaskKey[Unit]("checkScalaVersion", "test") := {
val sv = scalaVersion.value
assert(sv startsWith "2.11.", s"Found $sv!")
assert(sv startsWith "2.12.", s"Found $sv!")
}
TaskKey[Unit]("checkArtifacts", "test") := {

View File

@ -1,10 +1,10 @@
> publishLocal
$ exists target/ivy-cache/local/com.example/app_2.11/0.1.0/poms/app_2.11.pom
$ exists target/ivy-cache/local/com.example/app_2.11/0.1.0/jars/app_2.11.jar
$ absent target/ivy-cache/local/com.example/default-root_2.11/0.1.0/ivys/ivy.xml
$ exists target/ivy-cache/local/com.example/app_2.12/0.1.0/poms/app_2.12.pom
$ exists target/ivy-cache/local/com.example/app_2.12/0.1.0/jars/app_2.12.jar
$ absent target/ivy-cache/local/com.example/default-root_2.12/0.1.0/ivys/ivy.xml
$ copy-file changes/bare.sbt build.sbt
> reload
> publishLocal
$ exists target/ivy-cache/local/com.example/generated-root-no-publish_2.11/0.1.0/poms/generated-root-no-publish_2.11.pom
$ exists target/ivy-cache/local/com.example/generated-root-no-publish_2.11/0.1.0/jars/generated-root-no-publish_2.11.jar
$ exists target/ivy-cache/local/com.example/generated-root-no-publish_2.12/0.1.0/poms/generated-root-no-publish_2.12.pom
$ exists target/ivy-cache/local/com.example/generated-root-no-publish_2.12/0.1.0/jars/generated-root-no-publish_2.12.jar

View File

@ -2,6 +2,6 @@ object Spawn
{
def main(args: Array[String])
{
error("Test error main")
sys.error("Test error main")
}
}

View File

@ -1,5 +1,7 @@
name := "forked-test"
organization := "org.example"
libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.10.0" % "test"
lazy val root = (project in file("."))
.settings(
scalaVersion in ThisBuild := "2.11.8",
name := "forked-test",
organization := "org.example",
libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.10.0" % Test
)

View File

@ -23,7 +23,7 @@ object Spawn
catch { case e: InterruptedException =>
val msg = "TrapExit improperly interrupted non-daemon thread"
System.err.println(msg)
error(msg)
sys.error(msg)
}
}
}

View File

@ -1,3 +1,5 @@
scalaVersion in ThisBuild := "2.11.8"
lazy val dep = project
lazy val use = project.

View File

@ -3,5 +3,5 @@ trait Equal[-A] {
def equal(a1: A, a2: A): Boolean
}
object Test {
implicit def TraversableEqual[CC[X] <: collection.TraversableLike[X, CC[X]] with Traversable[X], A: Equal]: Equal[CC[A]] = error("")
implicit def TraversableEqual[CC[X] <: collection.TraversableLike[X, CC[X]] with Traversable[X], A: Equal]: Equal[CC[A]] = sys.error("")
}

View File

@ -1,13 +1,19 @@
libraryDependencies += "org.scalatest" % "scalatest_2.10.0-RC3" % "1.8-B1" % "test"
val scalatest = "org.scalatest" %% "scalatest" % "3.0.1"
testOptions in Configurations.Test ++= {
def args(path: String, args: String*): Seq[TestOption] = if(file(path).exists) Tests.Argument(args : _*) :: Nil else Nil
//
args("success1", "-n", "test2 test3") ++
args("success2", "-n", "test2") ++
args("success3", "-n", "test3") ++
args("failure1", "-n", "test1") ++
args("failure2", "-n", "test1 test4") ++
args("failure3", "-n", "test1 test3")
}
lazy val root = (project in file("."))
.settings(
scalaVersion in ThisBuild := "2.11.8",
libraryDependencies += scalatest % Test,
// testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-f", "result.txt", "-eNDXEHLO")
testOptions in Configurations.Test ++= {
def args(path: String, args: String*): Seq[TestOption] =
if(file(path).exists) Tests.Argument(args : _*) :: Nil
else Nil
args("success1", "-n", "test2 test3") ++
args("success2", "-n", "test2") ++
args("success3", "-n", "test3") ++
args("failure1", "-n", "test1") ++
args("failure2", "-n", "test1 test4") ++
args("failure3", "-n", "test1 test3")
}
)

View File

@ -1,12 +1,19 @@
import org.scalatest.fixture.FixtureFunSuite
import org.scalatest._
import org.scalatest.Tag
import org.scalatest.fixture
class ArgumentTest extends FixtureFunSuite{
class ArgumentTest extends fixture.FunSuite {
type FixtureParam = Map[String,Any]
override def withFixture(test: OneArgTest): Unit = {
test(test.configMap)
override def withFixture(test: OneArgTest) = {
// Perform setup
val theFixture = test.configMap
try withFixture(test.toNoArgTest(theFixture)) // Invoke the test function
finally {
// Perform cleanup
}
}
test("1", Tag("test1")){ conf => sys.error("error #1") }
test("2", Tag("test2")){ conf => () }
test("3", Tag("test3")){ conf => () }

View File

@ -1,7 +1,6 @@
scalaVersion in ThisBuild := "2.11.8"
concurrentRestrictions in Global := Seq(Tags.limitAll(4))
libraryDependencies += "org.specs2" %% "specs2-core" % "3.8.4" % Test
inConfig(Test)(Seq(
testGrouping := definedTests.value.map { test => new Tests.Group(test.name, Seq(test), Tests.SubProcess(
ForkOptions(

View File

@ -1,3 +1,4 @@
scalaVersion in ThisBuild := "2.11.8"
parallelExecution in Test := false
libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.10.0" % Test
libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.10.0" % "test"

View File

@ -1,2 +1,2 @@
> compile
$ exists target/scala-2.11/classes/ch/epfl/scala/Client.class
$ exists target/scala-2.12/classes/ch/epfl/scala/Client.class