Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@

# Scala Steward: Reformat with scalafmt 3.9.10
1d6b2d8f534c6fa2ede2e46c872e09f7704bdbed

# Scala Steward: Reformat with scalafmt 3.10.5
b4c247c1d4a39b652926ab86f98a49f5a3ed32b8
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "3.10.1"
version = "3.10.5"

runner.dialect=scala213source3

Expand Down
73 changes: 43 additions & 30 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ lazy val core = crossProject(JVMPlatform, JSPlatform, NativePlatform)
"co.fs2" %%% "fs2-core" % Version.fs2,
"org.typelevel" %%% "cats-effect" % Version.catsEffect,
// https://github.com/portable-scala/portable-scala-reflect/issues/23
"org.portable-scala" %%% "portable-scala-reflect" % Version.portableReflect cross CrossVersion.for3Use2_13,
"org.typelevel" %% "scalac-compat-annotation" % Version.scalacCompatAnnotation,
"org.portable-scala" %%%
"portable-scala-reflect" % Version.portableReflect cross
CrossVersion.for3Use2_13,
"org.typelevel" %% "scalac-compat-annotation" %
Version.scalacCompatAnnotation,
"org.scalameta" %%% "munit-diff" % Version.munitDiff,
if (scalaVersion.value.startsWith("3."))
"org.scala-lang" % "scala-reflect" % scala213
Expand All @@ -95,7 +98,9 @@ lazy val munitDiffShadingSettings = Seq(
lazy val coreJVM = core.jvm
.settings(
libraryDependencies ++= Seq(
"org.scala-js" %%% "scalajs-stubs" % Version.scalajsStubs % "provided" cross CrossVersion.for3Use2_13,
"org.scala-js" %%%
"scalajs-stubs" % Version.scalajsStubs % "provided" cross
CrossVersion.for3Use2_13,
"junit" % "junit" % Version.junit % Optional
),
munitDiffShadingSettings
Expand All @@ -117,15 +122,18 @@ lazy val framework = crossProject(JVMPlatform, JSPlatform, NativePlatform)
lazy val frameworkJVM = framework.jvm
.settings(
libraryDependencies ++= Seq(
"org.scala-sbt" % "test-interface" % Version.testInterface,
"org.scala-js" %%% "scalajs-stubs" % Version.scalajsStubs % "provided" cross CrossVersion.for3Use2_13
"org.scala-sbt" % "test-interface" % Version.testInterface,
"org.scala-js" %%%
"scalajs-stubs" % Version.scalajsStubs % "provided" cross
CrossVersion.for3Use2_13
)
)

lazy val frameworkJS = framework.js
.settings(
libraryDependencies ++= Seq(
"org.scala-js" %% "scalajs-test-interface" % scalaJSVersion cross CrossVersion.for3Use2_13
"org.scala-js" %% "scalajs-test-interface" % scalaJSVersion cross
CrossVersion.for3Use2_13
)
)

Expand All @@ -149,7 +157,8 @@ lazy val coreCats = crossProject(JVMPlatform, JSPlatform, NativePlatform)
lazy val coreCatsJS = coreCats.js
.settings(
libraryDependencies ++= Seq(
"org.scala-js" %%% "scala-js-macrotask-executor" % Version.scalajsMacroTask)
"org.scala-js" %%% "scala-js-macrotask-executor" %
Version.scalajsMacroTask)
)

lazy val cats = crossProject(JVMPlatform, JSPlatform, NativePlatform)
Expand All @@ -161,7 +170,8 @@ lazy val cats = crossProject(JVMPlatform, JSPlatform, NativePlatform)
)
lazy val catsJVM = cats.jvm
.settings(
libraryDependencies += "com.siriusxm" %% "snapshot4s-core" % Version.snapshot4s % Test
libraryDependencies +=
"com.siriusxm" %% "snapshot4s-core" % Version.snapshot4s % Test
)
.enablePlugins(Snapshot4sPlugin)

Expand Down Expand Up @@ -235,28 +245,31 @@ lazy val docs = project
"org.http4s" %% "http4s-ember-client" % Version.http4s,
"org.typelevel" %% "cats-laws" % Version.catsLaws
),
tlSiteHelium ~= (_.site.internalCSS(Root / "assets")
.site.landingPage(
logo = Some(Image.internal(Root / "assets/logo.png")),
title = Some("Weaver"),
subtitle = Some("A test framework that runs everything in parallel."),
latestReleases = Seq(
ReleaseInfo("Upcoming Stable Release", "1.0.0")
),
license = Some("Apache2"),
titleLinks = Seq(
VersionMenu.create(unversionedLabel = "Getting Started"),
LinkGroup.create(
IconLink.external("https://github.com/typelevel/weaver-test",
HeliumIcon.github),
IconLink.external("https://discord.gg/XF3CXcMzqD", HeliumIcon.chat)
tlSiteHelium ~=
(_.site.internalCSS(Root / "assets")
.site.landingPage(
logo = Some(Image.internal(Root / "assets/logo.png")),
title = Some("Weaver"),
subtitle = Some("A test framework that runs everything in parallel."),
latestReleases = Seq(
ReleaseInfo("Upcoming Stable Release", "1.0.0")
),
license = Some("Apache2"),
titleLinks = Seq(
VersionMenu.create(unversionedLabel = "Getting Started"),
LinkGroup.create(
IconLink.external("https://github.com/typelevel/weaver-test",
HeliumIcon.github),
IconLink.external("https://discord.gg/XF3CXcMzqD",
HeliumIcon.chat)
)
),
documentationLinks = Seq(
TextLink.internal(Root / "overview/installation.md",
"Installation"),
TextLink.internal(Root / "features/expectations.md",
"Expectations (Assertions)")
)
),
documentationLinks = Seq(
TextLink.internal(Root / "overview/installation.md", "Installation"),
TextLink.internal(Root / "features/expectations.md",
"Expectations (Assertions)")
)
)),
)),
laikaConfig ~= (_.withRawContent)
)
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ object macros {
// Comparing roots to workaround a Windows-specific behaviour
// https://github.com/disneystreaming/weaver-test/issues/364
val rp =
if (!abstractFile.isVirtual && (pwd.getRoot() == abstractFile.file.toPath().getRoot())) {
if (!abstractFile.isVirtual &&
(pwd.getRoot() == abstractFile.file.toPath().getRoot())) {
pwd.relativize(abstractFile.file.toPath()).toString()
} else p

Expand Down
10 changes: 6 additions & 4 deletions modules/core/shared/src/main/scala/weaver/Formatter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ object Formatter {
tabulatedTestLines match {
case (_, firstLine) :: Nil => newPrefix + withDuration(firstLine)
case (_, firstLine) :: extraLines =>
newPrefix + withDuration(firstLine) + EOL + extraLines
.map(l => l._1.prefix + l._2)
.mkString(EOL)
newPrefix + withDuration(firstLine) + EOL +
extraLines
.map(l => l._1.prefix + l._2)
.mkString(EOL)
case Nil => newPrefix + ""
}
}
Expand Down Expand Up @@ -66,7 +67,8 @@ object Formatter {
val newLine = '\n'
builder.append(formatResultStatus(name, result, outcome.duration))

if ((mode == Verbose && outcome.status.isFailed) || (mode == Summary && !outcome.status.isFailed))
if ((mode == Verbose && outcome.status.isFailed) ||
(mode == Summary && !outcome.status.isFailed))
result.formatted.foreach { resultInfo =>
builder.append(EOL)
builder.append(resultInfo)
Expand Down
16 changes: 9 additions & 7 deletions modules/core/shared/src/main/scala/weaver/Runner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,15 @@ class Runner[F[_]: Async](
outcome =>
for {
failures <- buffer.get
_ <- (printLine(red(stars) + "FAILURES" + red(stars)) *> failures
.traverse[F, Unit] { specEvent =>
printLine(cyan(specEvent.name)) *>
specEvent.events.traverse(printTestEvent(Verbose)) *>
newLine
}
.void).whenA(failures.nonEmpty)
_ <-
(printLine(red(stars) + "FAILURES" + red(stars)) *>
failures
.traverse[F, Unit] { specEvent =>
printLine(cyan(specEvent.name)) *>
specEvent.events.traverse(printTestEvent(Verbose)) *>
newLine
}
.void).whenA(failures.nonEmpty)
_ <- printLine(outcome.formatted)
} yield outcome
}
Expand Down
3 changes: 2 additions & 1 deletion modules/core/shared/src/main/scala/weaver/suites.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ abstract class RunnableSuite[F[_]] extends EffectSuite[F] {
val argsFilter = Filters.filterTests(this.name)(args)

val testsIgnored =
testsTaggedOnlyAndIgnored ++ testsNotTaggedOnlyAndIgnored // "foo".only.ignore and "foo".ignore
testsTaggedOnlyAndIgnored ++
testsNotTaggedOnlyAndIgnored // "foo".only.ignore and "foo".ignore

val (filteredTests, filteredOutTests) =
testsNotTaggedOnlyAndNotIgnored.partition {
Expand Down
9 changes: 6 additions & 3 deletions modules/framework-cats/jvm/src/test/scala/MetaJVM.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ object MetaJVM {
state.getState(parallelWait = true).map {
case (initialised, finalised, totalUses, localUses) =>
expect.all(
initialised == 1, // resource is initialised only once and uses in parallel
finalised == 0, // resource is not finalised until all parallel uses are completed
initialised ==
1, // resource is initialised only once and uses in parallel
finalised ==
0, // resource is not finalised until all parallel uses are completed
totalUses >= 1,
totalUses <= 3,
localUses >= 1,
Expand All @@ -146,7 +148,8 @@ object MetaJVM {
state.getState(parallelWait = false).map {
case (initialised, finalised, totalUses, localUses) =>
expect.all(
initialised == totalUses, // lazy resource will get initialised for each suite
initialised ==
totalUses, // lazy resource will get initialised for each suite
finalised == totalUses - 1,
localUses == 1 // one test for each inialisation
)
Expand Down
12 changes: 8 additions & 4 deletions scalafix/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ inThisBuild(
),
semanticdbEnabled := true,
semanticdbVersion := scalafixSemanticdb.revision,
resolvers += "Sonatype central snapshots" at "https://central.sonatype.com/repository/maven-snapshots",
resolvers += "Sonatype central snapshots" at
"https://central.sonatype.com/repository/maven-snapshots",
scalacOptions += "-deprecation"
)
)
Expand All @@ -36,7 +37,8 @@ lazy val `weaver-test` = (project in file("."))
lazy val rules = projectMatrix
.settings(
moduleName := "scalafix",
libraryDependencies += "ch.epfl.scala" %% "scalafix-core" % V.scalafixVersion
libraryDependencies +=
"ch.epfl.scala" %% "scalafix-core" % V.scalafixVersion
)
.defaultAxes(VirtualAxis.jvm)
.jvmPlatform(rulesCrossVersions)
Expand All @@ -56,11 +58,13 @@ lazy val v0_9_0_tests = makeTests("v0_9_0", v0_9_0_input, v0_9_0_output)
lazy val v0_11_0_input =
makeInput("v0_11_0", "org.typelevel" %% "weaver-cats" % "0.10.1")
lazy val v0_11_0_output =
makeOutput("v0_11_0", "org.typelevel" %% "weaver-cats" % "0.11-799b8e6-SNAPSHOT")
makeOutput("v0_11_0",
"org.typelevel" %% "weaver-cats" % "0.11-799b8e6-SNAPSHOT")
lazy val v0_11_0_tests = makeTests("v0_11_0", v0_11_0_input, v0_11_0_output)

lazy val testsAggregate = Project("tests", file("target/testsAggregate"))
.aggregate(v0_8_3_tests.projectRefs ++ v0_9_0_tests.projectRefs ++ v0_11_0_tests.projectRefs: _*)
.aggregate(v0_8_3_tests.projectRefs ++ v0_9_0_tests.projectRefs ++
v0_11_0_tests.projectRefs: _*)
.settings(
publish / skip := true
)
Expand Down
6 changes: 3 additions & 3 deletions scalafix/rules/src/main/scala/fix/AddClueToExpect.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ class AddClueToExpect extends SemanticRule("AddClueToExpect") {

private def makeClue(expr: Term)(implicit doc: SemanticDocument): Term = {
expr match {
case _: Term.Name => q"clue($expr)"
case _: Term.Apply => q"clue($expr)"
case _: Term.Name => q"clue($expr)"
case _: Term.Apply => q"clue($expr)"
case _: Term.Select => q"clue($expr)"
case _ => expr
case _ => expr
}
}

Expand Down
15 changes: 11 additions & 4 deletions scalafix/rules/src/main/scala/fix/RemoveTagged.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@ class RemoveTagged extends SemanticRule("RemoveTagged") {

override def fix(implicit doc: SemanticDocument): Patch = {
val taggedMethod =
SymbolMatcher.normalized("weaver/Expectations.Helpers#StringOps#tagged().")
SymbolMatcher.normalized(
"weaver/Expectations.Helpers#StringOps#tagged().")
doc.tree.collect {
case tree @ Term.Apply.After_4_6_0(Term.Select(testName, taggedMethod(_)), Term.ArgClause(List(Lit.String("ignore")), None)) =>
case tree @ Term.Apply.After_4_6_0(
Term.Select(testName, taggedMethod(_)),
Term.ArgClause(List(Lit.String("ignore")), None)) =>
Patch.replaceTree(tree, q"$testName.ignore".toString)
case tree @ Term.Apply.After_4_6_0(Term.Select(testName, taggedMethod(_)), Term.ArgClause(List(Lit.String("only")), None)) =>
case tree @ Term.Apply.After_4_6_0(
Term.Select(testName, taggedMethod(_)),
Term.ArgClause(List(Lit.String("only")), None)) =>
Patch.replaceTree(tree, q"$testName.only".toString)
case tree @ Term.Apply.After_4_6_0(Term.Select(testName, taggedMethod(_)), Term.ArgClause(List(Lit.String(other)), None)) =>
case tree @ Term.Apply.After_4_6_0(
Term.Select(testName, taggedMethod(_)),
Term.ArgClause(List(Lit.String(other)), None)) =>
Patch.replaceTree(tree, s"$testName")
}.asPatch
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@ package fix

import scalafix.v1._
import scala.meta._
class RenameAssertionExceptionToExpectationFailed extends SemanticRule("RenameAssertionExceptionToExpectationFailed") {
class RenameAssertionExceptionToExpectationFailed
extends SemanticRule("RenameAssertionExceptionToExpectationFailed") {

override def fix(implicit doc: SemanticDocument): Patch = {
val symbol = SymbolMatcher.normalized("weaver/AssertionException")
doc.tree.collect {
case symbol(tree) =>
tree match {
case q"AssertionException" => Patch.replaceTree(tree, s"new ExpectationFailed")
case t"AssertionException" => Patch.replaceTree(tree, s"ExpectationFailed")
case importee"AssertionException" => Patch.replaceTree(tree, s"ExpectationFailed")
case q"AssertionException" =>
Patch.replaceTree(tree, s"new ExpectationFailed")
case t"AssertionException" =>
Patch.replaceTree(tree, s"ExpectationFailed")
case importee"AssertionException" =>
Patch.replaceTree(tree, s"ExpectationFailed")
case _ => Patch.empty
}
}.asPatch
Expand Down
29 changes: 21 additions & 8 deletions scalafix/rules/src/main/scala/fix/v0_11_0.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import scala.meta._
class v0_11_0 extends SemanticRule("v0_11_0") {

override def fix(implicit doc: SemanticDocument): Patch =
List(renameCancelToIgnore, renameAssertionException, removeTagged, renameVerify).asPatch
List(renameCancelToIgnore,
renameAssertionException,
removeTagged,
renameVerify).asPatch

def renameCancelToIgnore(implicit doc: SemanticDocument): Patch = {
val cancelMethod =
Expand All @@ -26,23 +29,33 @@ class v0_11_0 extends SemanticRule("v0_11_0") {
doc.tree.collect {
case symbol(tree) =>
tree match {
case q"AssertionException" => Patch.replaceTree(tree, s"new ExpectationFailed")
case t"AssertionException" => Patch.replaceTree(tree, s"ExpectationFailed")
case importee"AssertionException" => Patch.replaceTree(tree, s"ExpectationFailed")
case q"AssertionException" =>
Patch.replaceTree(tree, s"new ExpectationFailed")
case t"AssertionException" =>
Patch.replaceTree(tree, s"ExpectationFailed")
case importee"AssertionException" =>
Patch.replaceTree(tree, s"ExpectationFailed")
case _ => Patch.empty
}
}.asPatch
}

def removeTagged(implicit doc: SemanticDocument): Patch = {
val taggedMethod =
SymbolMatcher.normalized("weaver/Expectations.Helpers#StringOps#tagged().")
SymbolMatcher.normalized(
"weaver/Expectations.Helpers#StringOps#tagged().")
doc.tree.collect {
case tree @ Term.Apply.After_4_6_0(Term.Select(testName, taggedMethod(_)), Term.ArgClause(List(Lit.String("ignore")), None)) =>
case tree @ Term.Apply.After_4_6_0(
Term.Select(testName, taggedMethod(_)),
Term.ArgClause(List(Lit.String("ignore")), None)) =>
Patch.replaceTree(tree, q"$testName.ignore".toString)
case tree @ Term.Apply.After_4_6_0(Term.Select(testName, taggedMethod(_)), Term.ArgClause(List(Lit.String("only")), None)) =>
case tree @ Term.Apply.After_4_6_0(
Term.Select(testName, taggedMethod(_)),
Term.ArgClause(List(Lit.String("only")), None)) =>
Patch.replaceTree(tree, q"$testName.only".toString)
case tree @ Term.Apply.After_4_6_0(Term.Select(testName, taggedMethod(_)), Term.ArgClause(List(Lit.String(other)), None)) =>
case tree @ Term.Apply.After_4_6_0(
Term.Select(testName, taggedMethod(_)),
Term.ArgClause(List(Lit.String(other)), None)) =>
Patch.replaceTree(tree, s"$testName")
}.asPatch
}
Expand Down
Loading