Skip to content

Commit

Permalink
realeasy includes annoying tests
Browse files Browse the repository at this point in the history
  • Loading branch information
som-snytt committed Apr 11, 2023
1 parent 21fc828 commit 905c92f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
24 changes: 15 additions & 9 deletions src/partest/scala/tools/partest/nest/AbstractRunner.scala
Expand Up @@ -296,7 +296,8 @@ class AbstractRunner(val config: RunnerSpec.Config, protected final val testSour

val isRerun = config.optFailed
val rerunTests = if (isRerun) testKinds.failedTests else Nil
def miscTests = individualTests ++ greppedTests ++ branchedTests ++ rerunTests
val specialTests = if (realeasy) List(Path("test/files/run/t6240-universe-code-gen.scala")) else Nil
def miscTests = List(individualTests, greppedTests, branchedTests, rerunTests, specialTests).flatten

val givenKinds = standardKinds filter config.parsed.isSet
val kinds = (
Expand All @@ -312,16 +313,21 @@ class AbstractRunner(val config: RunnerSpec.Config, protected final val testSour

def testContributors = {
List(
if (rerunTests.isEmpty) "" else "previously failed tests",
if (kindsTests.isEmpty) "" else s"${kinds.size} named test categories",
if (greppedTests.isEmpty) "" else s"${greppedTests.size} tests matching '$grepExpr'",
if (branchedTests.isEmpty) "" else s"${branchedTests.size} tests modified on this branch",
if (individualTests.isEmpty) "" else "specified tests",
).filterNot(_.isEmpty).mkString(", ")
(rerunTests, "previously failed tests"),
(kindsTests, s"${kinds.size} named test categories"),
(greppedTests, s"${greppedTests.size} tests matching '$grepExpr'"),
(branchedTests, s"${branchedTests.size} tests modified on this branch"),
(individualTests, "specified tests"),
(specialTests, "other tests you might have forgotten"),
).filterNot(_._1.isEmpty).map(_._2) match {
case Nil => "the well of despair. I see you're not in a testing mood."
case one :: Nil => one
case all => all.init.mkString("", ", ", s", and ${all.last}")
}
}

val allTests: Array[Path] = distinctBy(miscTests ++ kindsTests)(_.toCanonical).sortBy(_.toString).toArray
val grouped = (allTests groupBy kindOf).toArray sortBy (x => standardKinds indexOf x._1)
val allTests: Array[Path] = distinctBy(miscTests ::: kindsTests)(_.toCanonical).sortBy(_.toString).toArray
val grouped = allTests.groupBy(kindOf).toArray.sortBy(x => standardKinds.indexOf(x._1))

onlyIndividualTests = individualTests.nonEmpty && rerunTests.isEmpty && kindsTests.isEmpty && greppedTests.isEmpty
totalTests = allTests.size
Expand Down
3 changes: 2 additions & 1 deletion src/partest/scala/tools/partest/nest/Runner.scala
Expand Up @@ -531,7 +531,8 @@ class Runner(val testInfo: TestInfo, val suiteRunner: AbstractRunner) {
else from.toInt <= currentJavaVersion && currentJavaVersion <= to.toInt
else
currentJavaVersion >= from.toInt
if (ok) None
if (ok && suiteRunner.realeasy && from.toInt > 8) Some(genSkip(s"skipped on Java $javaSpecVersion, compiling against JDK8 but must run on $v"))
else if (ok) None
else Some(genSkip(s"skipped on Java $javaSpecVersion, only running on $v"))
case v =>
Some(genFail(s"invalid javaVersion range in test comment: $v"))
Expand Down
11 changes: 11 additions & 0 deletions test/files/run/blank.scala
@@ -0,0 +1,11 @@
// javaVersion: 11+
//
// skalac: --release:8
// trivial manual test for partest --realeasy, which sets --release:8.
// under --realeasy, skip this test because of the javaVersion, irrespective of JDK in use.
// otherwise, this test passes trivially on JDK11+ and is skipped on lesser JDKs.
// note that explicit --release:8 asks to compile against JDK8 but only run on the requested version.

object Test extends App {
assert("".isBlank) // String#isBlank was added in JDK11
}

0 comments on commit 905c92f

Please sign in to comment.