-
Notifications
You must be signed in to change notification settings - Fork 405
Increase Fidelity of the sbt.testing.Framework Implementation #1107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
satorg
merged 1 commit into
typelevel:main
from
dubinsky:increase-fidelity-of-the-sbt-testing-framework-implementation
Aug 13, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
97 changes: 97 additions & 0 deletions
97
core/shared/src/test/scala/org/scalacheck/SbtSpecification.scala
This file contains hidden or 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,97 @@ | ||
/* | ||
* ScalaCheck | ||
* Copyright (c) 2007-2021 Rickard Nilsson. All rights reserved. | ||
* http://www.scalacheck.org | ||
* | ||
* This software is released under the terms of the Revised BSD License. | ||
* There is NO WARRANTY. See the file LICENSE for the full text. | ||
*/ | ||
|
||
package org.scalacheck | ||
|
||
import sbt.testing.{ | ||
Event, | ||
EventHandler, | ||
Framework, | ||
Selector, | ||
SuiteSelector, | ||
Task, | ||
TaskDef, | ||
TestSelector, | ||
TestWildcardSelector | ||
} | ||
|
||
object SbtFixture extends Properties("SbtFixture") { | ||
property("success") = Prop.passed | ||
} | ||
|
||
object SbtNestingFixture extends Properties("SbtNestingFixture") { | ||
include(SbtFixture) | ||
} | ||
|
||
object SbtSpecification extends Properties("Sbt") { | ||
property("suite") = run(Array(new SuiteSelector)) == List("SbtFixture.success") | ||
|
||
property("exact") = run(Array(new TestSelector("success"))) == List("SbtFixture.success") | ||
property("exactFull") = run(Array(new TestSelector("SbtFixture.success"))) == List("SbtFixture.success") | ||
property("exactMissing") = run(Array(new TestSelector("nonexistent"))) == List.empty | ||
|
||
property("wildcard") = run(Array(new TestWildcardSelector("succ"))) == List("SbtFixture.success") | ||
property("wildcardFull") = run(Array(new TestWildcardSelector("xture.succ"))) == List("SbtFixture.success") | ||
property("wildcardMissing") = run(Array(new TestWildcardSelector("prev"))) == List.empty | ||
|
||
property("nestedFull") = run( | ||
Array(new TestSelector("SbtNestingFixture.SbtFixture.success")), | ||
"org.scalacheck.SbtNestingFixture") == List("SbtNestingFixture.SbtFixture.success") | ||
|
||
property("nestedMedium") = run( | ||
Array(new TestSelector("SbtFixture.success")), | ||
"org.scalacheck.SbtNestingFixture") == List("SbtNestingFixture.SbtFixture.success") | ||
|
||
property("nestedShort") = run( | ||
Array(new TestSelector("success")), | ||
"org.scalacheck.SbtNestingFixture") == List("SbtNestingFixture.SbtFixture.success") | ||
|
||
// Since ScalaCheck does not keep track what class/object a property belongs to, | ||
// the following two issues concerning nested properties can not be fixed: | ||
// | ||
// When `explicitlySpecified = true`, properties from objects other than the one being run | ||
// should *not* run (and the outcome should be `List.empty`) - but they do. | ||
// | ||
// When a property from an object other than the one being run *does* run, | ||
// its status should be reported with a `NestedTestSelector` | ||
// where `suiteId` names the object that the property belongs to - | ||
// but it is reported with a `TestSelector`. | ||
|
||
property("nestedShouldRunAndDoes") = run( | ||
Array(new SuiteSelector), | ||
fullyQualifiedName = "org.scalacheck.SbtNestingFixture", | ||
explicitlySpecified = false | ||
) == List("SbtNestingFixture.SbtFixture.success") | ||
|
||
property("nestedShouldNotRunButDoes") = run( | ||
Array(new SuiteSelector), | ||
fullyQualifiedName = "org.scalacheck.SbtNestingFixture", | ||
explicitlySpecified = true | ||
) == List("SbtNestingFixture.SbtFixture.success") // should be List.empty | ||
|
||
// run using SBT Test Interface | ||
def run( | ||
selectors: Array[Selector], | ||
fullyQualifiedName: String = "org.scalacheck.SbtFixture", | ||
explicitlySpecified: Boolean = false | ||
): List[String] = { | ||
val framework: Framework = new ScalaCheckFramework | ||
var ran: List[String] = List.empty | ||
val eventHandler: EventHandler = | ||
(event: Event) => ran = ran :+ event.selector().asInstanceOf[TestSelector].testName() | ||
def execute(tasks: Array[Task]): Unit = tasks.foreach(task => execute(task.execute(eventHandler, Array.empty))) | ||
execute(framework.runner(Array.empty, Array.empty, Platform.getClassLoader).tasks(Array(new TaskDef( | ||
fullyQualifiedName, | ||
framework.fingerprints()(2), // object ... extends org.scalacheck.Properties | ||
explicitlySpecified, | ||
selectors | ||
)))) | ||
ran | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.