forked from lightbend-labs/mima
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for versions with less segments (lightbend-labs#212)
- Loading branch information
Showing
4 changed files
with
101 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
sbtplugin/src/test/scala/com/typesafe/tools/mima/plugin/ProblemReportingSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.typesafe.tools.mima.plugin | ||
|
||
import com.typesafe.tools.mima.core.util.log.Logging | ||
import com.typesafe.tools.mima.core._ | ||
import sbt._ | ||
import org.scalatest.{Matchers, WordSpec} | ||
|
||
class ProblemReportingSpec extends WordSpec with Matchers { | ||
import ProblemReportingSpec._ | ||
|
||
"problem" should { | ||
"be reported when there are no filters" in { | ||
isReported("0.0.1", Seq.empty) shouldBe true | ||
} | ||
|
||
"not be reported when filtered out by general filters" in { | ||
isReported("0.0.1", Seq(AllMatchingFilter)) shouldBe false | ||
} | ||
|
||
"not be reported when filtered out by versioned filters" in { | ||
isReported("0.0.1", Map("0.0.1" -> Seq(AllMatchingFilter))) shouldBe false | ||
} | ||
|
||
"not be reported when filtered out by versioned wildcard filters" in { | ||
isReported("0.0.1", Map("0.0.x" -> Seq(AllMatchingFilter))) shouldBe false | ||
} | ||
|
||
"not be reported when filter version does not have patch segment" in { | ||
isReported("0.1", Map("0.1" -> Seq(AllMatchingFilter))) shouldBe false | ||
} | ||
|
||
"not be reported when filter version is only epoch" in { | ||
isReported("1", Map("1" -> Seq(AllMatchingFilter))) shouldBe false | ||
} | ||
|
||
"not be reported when filter version has less segments than module version" in { | ||
isReported("0.1.0", Map("0.1" -> Seq(AllMatchingFilter))) shouldBe false | ||
} | ||
|
||
"not be reported when filter version has more segments than module version" in { | ||
isReported("0.1", Map("0.1.0" -> Seq(AllMatchingFilter))) shouldBe false | ||
} | ||
} | ||
|
||
private def isReported(moduleVersion: String, filters: Seq[ProblemFilter]) = | ||
SbtMima.isReported("test" % "module" % moduleVersion, filters, Map.empty)(NoOpLogger, "test")(MissingFieldProblem(NoMemberInfo)) | ||
private def isReported(moduleVersion: String, versionedFilters: Map[String, Seq[ProblemFilter]]) = | ||
SbtMima.isReported("test" % "module" % moduleVersion, Seq.empty, versionedFilters)(NoOpLogger, "test")(MissingFieldProblem(NoMemberInfo)) | ||
|
||
} | ||
|
||
object ProblemReportingSpec { | ||
final val NoOpLogger = new Logging { | ||
override def info(str: String): Unit = () | ||
override def debugLog(str: String): Unit = () | ||
} | ||
|
||
final val NoMemberInfo = new MemberInfo(NoClass, "", 0, "") | ||
|
||
final val AllMatchingFilter = (_: Problem) => false | ||
} |