From 272afa9d737cdbbb00a2b092dc26f2dbeb861494 Mon Sep 17 00:00:00 2001 From: jvican Date: Wed, 3 May 2017 00:59:51 +0200 Subject: [PATCH] Try another travis structure + build tweaks I've tried to put together some scripted tests to remove the overhead of compiling the whole sbt, which is around 3 minutes every time. This new structure *should* make the scripted tests run faster. Aside from this, we do some more tweaks: * Increase memory. * Fork processes to compile and run (to see if it makes a difference). * Pass in the server flag to sbt. --- .travis.yml | 25 ++++++------------- build.sbt | 9 ++++--- .../main/scala/sbt/test/ScriptedTests.scala | 14 ++++++++--- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3e419dc53..ff54cfa27 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,29 +16,17 @@ matrix: env: matrix: - - SBT_CMD=";test:compile;scalafmtCheck" - - SBT_CMD="mimaReportBinaryIssues" - - SBT_CMD="safeUnitTests" - - SBT_CMD="otherUnitTests" + - SBT_CMD=";mimaReportBinaryIssues;test:compile;scalafmtCheck;safeUnitTests;otherUnitTests" - SBT_CMD="scripted actions/*" - - SBT_CMD="scripted apiinfo/*" - - SBT_CMD="scripted compiler-project/*" + - SBT_CMD="scripted apiinfo/* compiler-project/* ivy-deps-management/*" - SBT_CMD="scripted dependency-management/*1of4" - SBT_CMD="scripted dependency-management/*2of4" - SBT_CMD="scripted dependency-management/*3of4" - SBT_CMD="scripted dependency-management/*4of4" - - SBT_CMD="scripted ivy-deps-management/*" - - SBT_CMD="scripted java/*" - - SBT_CMD="scripted package/*" - - SBT_CMD="scripted project/*1of2" - - SBT_CMD="scripted project/*2of2" - - SBT_CMD="scripted reporter/*" - - SBT_CMD="scripted run/*" - - SBT_CMD="scripted source-dependencies/*1of3" - - SBT_CMD="scripted source-dependencies/*2of3" - - SBT_CMD="scripted source-dependencies/*3of3" + - SBT_CMD="scripted java/* package/* reporter/* run/*" + - SBT_CMD="scripted project/* project-load/*" + - SBT_CMD="scripted source-dependencies/*" - SBT_CMD="scripted tests/*" - - SBT_CMD="scripted project-load/*" - SBT_CMD="repoOverrideTest:scripted dependency-management/*" notifications: @@ -46,7 +34,8 @@ notifications: - sbt-dev-bot@googlegroups.com script: - - sbt -J-XX:ReservedCodeCacheSize=128m -J-Xmx1g -J-Xms1g "$SBT_CMD" + # It doesn't need that much memory because compile and run are forked + - sbt -J-XX:ReservedCodeCacheSize=128m -J-Xmx800M -J-Xms800M -J-server "$SBT_CMD" before_cache: - find $HOME/.ivy2 -name "ivydata-*.properties" -print -delete diff --git a/build.sbt b/build.sbt index e28fa2aba..913d31f78 100644 --- a/build.sbt +++ b/build.sbt @@ -53,7 +53,9 @@ def commonSettings: Seq[Setting[_]] = mimaBinaryIssueFilters ++= { import com.typesafe.tools.mima.core._, ProblemFilters._ Seq() - } + }, + fork in compile := true, + fork in run := true ) flatMap (_.settings) def minimalSettings: Seq[Setting[_]] = @@ -352,7 +354,7 @@ def otherRootSettings = scriptedUnpublished := scriptedUnpublishedTask.evaluated, scriptedSource := (sourceDirectory in sbtProj).value / "sbt-test", // scriptedPrescripted := { addSbtAlternateResolver _ }, - scriptedLaunchOpts := List("-Xmx1024M", "-Xms512M"), + scriptedLaunchOpts := List("-Xmx1500M", "-Xms512M", "-server"), publishAll := { val _ = (publishLocal).all(ScopeFilter(inAnyProject)).value }, publishLocalBinAll := { val _ = (publishLocalBin).all(ScopeFilter(inAnyProject)).value }, aggregate in bintrayRelease := false @@ -362,8 +364,9 @@ def otherRootSettings = () }, scriptedLaunchOpts := { - List("-Xmx1024M", + List("-Xmx1500M", "-Xms512M", + "-server", "-Dsbt.override.build.repos=true", s"""-Dsbt.repository.config=${scriptedSource.value / "repo.config"}""") }, diff --git a/scripted/sbt/src/main/scala/sbt/test/ScriptedTests.scala b/scripted/sbt/src/main/scala/sbt/test/ScriptedTests.scala index 85405e87f..7502a8ae3 100644 --- a/scripted/sbt/src/main/scala/sbt/test/ScriptedTests.scala +++ b/scripted/sbt/src/main/scala/sbt/test/ScriptedTests.scala @@ -111,7 +111,7 @@ final class ScriptedTests(resourceBaseDirectory: File, * * It sets the name of the local root project for those tests run in batch mode. * - * This is necessary because the current design to run tests in batch mode force + * This is necessary because the current design to run tests in batch mode forces * scripted tests to share one common sbt dir instead of each one having its own. * * Sbt extracts the local root project name from the directory name. So those @@ -184,14 +184,22 @@ final class ScriptedTests(resourceBaseDirectory: File, // Reload and initialize (to reload contents of .sbtrc files) val pluginImplementation = createAutoPlugin(name) IO.write(tempTestDir / "project" / "InstrumentScripted.scala", pluginImplementation) - val sbtHandler = handlers.getOrElse('>', sys.error("Missing sbt handler.")) + val sbtHandlerError = "Missing sbt handler. Scripted is misconfigured." + val sbtHandler = handlers.getOrElse('>', sbtHandlerError).asInstanceOf[SbtHandler] val commandsToRun = ";reload;setUpScripted" val statement = Statement(commandsToRun, Nil, successExpected = true, line = -1) + // Run reload inside the hook to reuse error handling for pending tests val wrapHook = (file: File) => { preHook(file) - runner.processStatement(sbtHandler.asInstanceOf[SbtHandler], statement, states) + try runner.processStatement(sbtHandler, statement, states) + catch { + case t: Throwable => + val newMsg = "Reload for scripted batch execution failed." + throw new TestException(statement, newMsg, t) + } } + commonRunTest(label, tempTestDir, wrapHook, handlers, runner, states, buffer) }