Merge pull request #4872 from eatkins/legacy-filters

Add scripted test for excludeFilter
This commit is contained in:
eugene yokota 2019-07-17 09:13:32 -04:00 committed by GitHub
commit 5c85ee572f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 29 additions and 8 deletions

View File

@ -12,7 +12,7 @@ env:
matrix:
- SBT_CMD=";mimaReportBinaryIssues ;scalafmtCheckAll ;headerCheck ;test:headerCheck ;whitesourceOnPush ;test:compile; publishLocal ;mainSettingsProj/test ;safeUnitTests ;otherUnitTests; doc"
- SBT_CMD="scripted actions/* apiinfo/* compiler-project/* ivy-deps-management/* reporter/* tests/* watch/* classloader-cache/* package/*"
- SBT_CMD="scripted dependency-management/* plugins/* project-load/* java/* run/*"
- SBT_CMD="scripted dependency-management/* plugins/* project-load/* java/* run/* nio/*"
- SBT_CMD="repoOverrideTest:scripted dependency-management/*; scripted source-dependencies/* project/*"
matrix:

View File

@ -10,7 +10,7 @@ object Dependencies {
def nightlyVersion: Option[String] = sys.props.get("sbt.build.version")
// sbt modules
private val ioVersion = nightlyVersion.getOrElse("1.3.0-M12")
private val ioVersion = nightlyVersion.getOrElse("1.3.0-M13")
private val utilVersion = nightlyVersion.getOrElse("1.3.0-M8")
private val lmVersion =
sys.props.get("sbt.build.lm.version") match {

View File

@ -32,10 +32,10 @@ val checkAdded = taskKey[Unit]("check that modified files are returned")
checkAdded := Def.taskDyn {
val files = (foo / allInputFiles).value
val added = (foo / changedInputFiles).value.map(_.created).getOrElse(Nil)
if (added.isEmpty || files.sameElements(added)) Def.task(assert(true))
if (added.isEmpty || (files.toSet == added.toSet)) Def.task(assert(true))
else Def.task {
val base = baseDirectory.value / "base"
assert(files.sameElements(Seq("Bar.md", "Foo.txt").map(p => (base / p).toPath)))
assert(files.toSet == Set("Bar.md", "Foo.txt").map(p => (base / p).toPath))
assert(added == Seq((baseDirectory.value / "base" / "Bar.md").toPath))
}
}.value

View File

@ -0,0 +1,8 @@
Compile / excludeFilter := "Bar.scala" || "Baz.scala"
val checkSources = inputKey[Unit]("Check that the compile sources match the input file names")
checkSources := {
val sources = Def.spaceDelimited("").parsed.toSet
val actual = (Compile / unmanagedSources).value.map(_.getName).toSet
assert(sources == actual)
}

View File

@ -0,0 +1 @@
class Bar {

View File

@ -0,0 +1 @@
class Foo

View File

@ -0,0 +1,9 @@
> checkSources Foo.scala
> compile
> set Compile / excludeFilter := HiddenFileFilter
> checkSources Foo.scala Bar.scala
-> compile

View File

@ -1,6 +1,8 @@
import java.nio.file.{ Files, Path }
import scala.sys.process._
val compileOpts = settingKey[Seq[String]]("Extra compile options")
compileOpts := { if (scala.util.Properties.isLinux) "-fPIC" :: "-std=gnu99" :: Nil else Nil }
val compileLib = taskKey[Seq[Path]]("Compile the library")
compileLib / sourceDirectory := sourceDirectory.value / "lib"
compileLib / fileInputs := {
@ -34,7 +36,8 @@ compileLib := {
cFiles.map { file =>
val outFile = objectDir.resolve(objectFileName(file))
logger.info(s"Compiling $file to $outFile")
Seq("gcc", "-c", file.toString, s"-I$include", "-o", outFile.toString).!!
(Seq("gcc") ++ compileOpts.value ++
Seq("-c", file.toString, s"-I$include", "-o", outFile.toString)).!!
outFile
}
}
@ -87,15 +90,14 @@ compileMain := {
case Seq(main) =>
Files.createDirectories(outDir)
logger.info(s"Building executable $outPath")
Seq(
"gcc",
(Seq("gcc") ++ compileOpts.value ++ Seq(
main.toString,
s"-I$include",
"-o",
outPath.toString,
s"-L${library.getParent}",
"-lfoo"
).!!
)).!!
outPath
case main =>
throw new IllegalStateException(s"multiple main files detected: ${main.mkString(",")}")