2019-02-22 23:48:37 +01:00
|
|
|
package example.test
|
|
|
|
|
|
|
|
|
|
import minitest._
|
|
|
|
|
import scala.sys.process._
|
|
|
|
|
import java.io.File
|
|
|
|
|
|
|
|
|
|
object SbtRunnerTest extends SimpleTestSuite with PowerAssertions {
|
2019-09-23 07:25:35 +02:00
|
|
|
// 1.3.0, 1.3.0-M4
|
|
|
|
|
private val versionRegEx = "\\d(\\.\\d+){2}(-\\w+)?"
|
|
|
|
|
|
2019-07-16 01:23:58 +02:00
|
|
|
lazy val isWindows: Boolean = sys.props("os.name").toLowerCase(java.util.Locale.ENGLISH).contains("windows")
|
|
|
|
|
lazy val sbtScript =
|
|
|
|
|
if (isWindows) new File("target/universal/stage/bin/sbt.bat")
|
|
|
|
|
else new File("target/universal/stage/bin/sbt")
|
2019-09-23 07:25:35 +02:00
|
|
|
|
2019-09-14 07:36:30 +02:00
|
|
|
def sbtProcess(arg: String) = sbtProcessWithOpts(arg, "", "")
|
2019-05-09 06:28:14 +02:00
|
|
|
def sbtProcessWithOpts(arg: String, javaOpts: String, sbtOpts: String) =
|
2019-02-23 04:31:58 +01:00
|
|
|
sbt.internal.Process(sbtScript.getAbsolutePath + " " + arg, new File("citest"),
|
2019-05-09 06:28:14 +02:00
|
|
|
"JAVA_OPTS" -> javaOpts,
|
|
|
|
|
"SBT_OPTS" -> sbtOpts)
|
2019-02-22 23:48:37 +01:00
|
|
|
|
|
|
|
|
test("sbt runs") {
|
|
|
|
|
assert(sbtScript.exists)
|
|
|
|
|
val out = sbtProcess("compile -v").!
|
|
|
|
|
assert(out == 0)
|
|
|
|
|
()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test("sbt -no-colors") {
|
|
|
|
|
val out = sbtProcess("compile -no-colors -v").!!.linesIterator.toList
|
|
|
|
|
assert(out.contains[String]("-Dsbt.log.noformat=true"))
|
|
|
|
|
()
|
|
|
|
|
}
|
2019-02-23 04:31:58 +01:00
|
|
|
|
2019-04-05 16:20:52 +02:00
|
|
|
test("sbt --no-colors") {
|
|
|
|
|
val out = sbtProcess("compile --no-colors -v").!!.linesIterator.toList
|
|
|
|
|
assert(out.contains[String]("-Dsbt.log.noformat=true"))
|
|
|
|
|
()
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-05 17:30:59 +02:00
|
|
|
test("sbt --color=false") {
|
|
|
|
|
val out = sbtProcess("compile --color=false -v").!!.linesIterator.toList
|
|
|
|
|
assert(out.contains[String]("-Dsbt.color=false"))
|
|
|
|
|
()
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-10 19:42:17 +02:00
|
|
|
test("sbt --debug-inc") {
|
|
|
|
|
val out = sbtProcess("compile --debug-inc -v").!!.linesIterator.toList
|
|
|
|
|
assert(out.contains[String]("-Dxsbt.inc.debug=true"))
|
|
|
|
|
()
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-05 17:30:59 +02:00
|
|
|
test("sbt --supershell=never") {
|
|
|
|
|
val out = sbtProcess("compile --supershell=never -v").!!.linesIterator.toList
|
|
|
|
|
assert(out.contains[String]("-Dsbt.supershell=never"))
|
|
|
|
|
()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test("sbt --timings") {
|
|
|
|
|
val out = sbtProcess("compile --timings -v").!!.linesIterator.toList
|
|
|
|
|
assert(out.contains[String]("-Dsbt.task.timings=true"))
|
|
|
|
|
()
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-14 07:36:30 +02:00
|
|
|
test("sbt --sbt-version") {
|
|
|
|
|
val out = sbtProcess("--sbt-version 1.3.0 compile -v").!!.linesIterator.toList
|
|
|
|
|
assert(out.contains[String]("-Dsbt.version=1.3.0"))
|
|
|
|
|
()
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-23 04:31:58 +01:00
|
|
|
test("sbt -mem 503") {
|
|
|
|
|
val out = sbtProcess("compile -mem 503 -v").!!.linesIterator.toList
|
|
|
|
|
assert(out.contains[String]("-Xmx503m"))
|
|
|
|
|
()
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-23 07:25:35 +02:00
|
|
|
test("sbt with -mem 503, -Xmx in JAVA_OPTS") {
|
2019-05-09 06:28:14 +02:00
|
|
|
val out = sbtProcessWithOpts("compile -mem 503 -v", "-Xmx1024m", "").!!.linesIterator.toList
|
2019-02-23 04:31:58 +01:00
|
|
|
assert(out.contains[String]("-Xmx503m"))
|
2019-09-23 07:25:35 +02:00
|
|
|
assert(!out.contains[String]("-Xmx1024m"))
|
|
|
|
|
()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test("sbt with -mem 503, -Xmx in SBT_OPTS") {
|
|
|
|
|
val out = sbtProcessWithOpts("compile -mem 503 -v", "", "-Xmx1024m").!!.linesIterator.toList
|
|
|
|
|
assert(out.contains[String]("-Xmx503m"))
|
|
|
|
|
assert(!out.contains[String]("-Xmx1024m"))
|
2019-02-23 04:31:58 +01:00
|
|
|
()
|
|
|
|
|
}
|
2019-05-09 06:28:14 +02:00
|
|
|
|
|
|
|
|
test("sbt with -Xms2048M -Xmx2048M -Xss6M in SBT_OPTS") {
|
2019-09-23 07:25:35 +02:00
|
|
|
if (isWindows) cancel("Test not supported on windows")
|
2019-05-09 06:28:14 +02:00
|
|
|
val out = sbtProcessWithOpts("compile -v", "", "-Xms2048M -Xmx2048M -Xss6M").!!.linesIterator.toList
|
|
|
|
|
assert(out.contains[String]("-Xss6M"))
|
|
|
|
|
()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test("sbt with --no-colors in SBT_OPTS") {
|
2019-09-23 07:25:35 +02:00
|
|
|
if (isWindows) cancel("Test not supported on windows")
|
2019-05-09 06:28:14 +02:00
|
|
|
val out = sbtProcessWithOpts("compile -v", "", "--no-colors").!!.linesIterator.toList
|
|
|
|
|
assert(out.contains[String]("-Dsbt.log.noformat=true"))
|
|
|
|
|
()
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-23 19:23:48 +02:00
|
|
|
test("sbt -V|-version|--version should print sbtVersion") {
|
2019-07-19 01:32:41 +02:00
|
|
|
val out = sbtProcessWithOpts("-version", "", "").!!.trim
|
2019-09-23 19:23:48 +02:00
|
|
|
val expectedVersion =
|
|
|
|
|
s"""|(?m)^sbt version in this project: $versionRegEx
|
2019-09-23 07:25:35 +02:00
|
|
|
|sbt script version: $versionRegEx$$
|
|
|
|
|
|""".stripMargin.trim.replace("\n", "\\n")
|
2019-07-19 01:32:41 +02:00
|
|
|
assert(out.matches(expectedVersion))
|
|
|
|
|
|
2019-09-23 19:23:48 +02:00
|
|
|
val out2 = sbtProcessWithOpts("--version", "", "").!!.trim
|
2019-07-19 01:32:41 +02:00
|
|
|
assert(out2.matches(expectedVersion))
|
2019-09-23 19:23:48 +02:00
|
|
|
|
|
|
|
|
val out3 = sbtProcessWithOpts("-V", "", "").!!.trim
|
|
|
|
|
assert(out3.matches(expectedVersion))
|
2019-07-19 01:32:41 +02:00
|
|
|
()
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-23 19:23:48 +02:00
|
|
|
test("sbt --numeric-version should print sbt script version") {
|
|
|
|
|
val out = sbtProcessWithOpts("--numeric-version", "", "").!!.trim
|
|
|
|
|
val expectedVersion = "^"+versionRegEx+"$"
|
|
|
|
|
assert(out.matches(expectedVersion))
|
|
|
|
|
()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test("sbt --script-version should print sbtVersion") {
|
|
|
|
|
val out = sbtProcessWithOpts("--numeric-version", "", "").!!.trim
|
|
|
|
|
val expectedVersion = "^"+versionRegEx+"$"
|
|
|
|
|
assert(out.matches(expectedVersion))
|
|
|
|
|
()
|
|
|
|
|
}
|
2019-02-22 23:48:37 +01:00
|
|
|
}
|