Skip to content

scalafmt/dev1 #32

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ test-output/
_site/
.bsp/
build/
.gradle/
.gradle/
**/.metals
**/.bloop
8 changes: 8 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version = "3.9.5"
runner.dialect = scala213

maxColumn = 120
lineEndings = unix

# Only format files tracked by git.
project.git = true
42 changes: 22 additions & 20 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Compile / unmanagedSourceDirectories ++= {
val sourceDir = (Compile / sourceDirectory).value
CrossVersion.partialVersion(scalaVersion.value).map {
case (0 | 3, _) => sourceDir / "scala-3"
case (n, _) => sourceDir / s"scala-$n"
case (n, _) => sourceDir / s"scala-$n"
}
}

Expand All @@ -69,24 +69,24 @@ import scala.xml.transform.{RewriteRule, RuleTransformer}
pomPostProcess := { (node: XmlNode) =>
new RuleTransformer(new RewriteRule {
override def transform(node: XmlNode): XmlNodeSeq = node match {
case e: Elem if e.label == "dependency"
&& e.child.exists(child => child.label == "scope") =>
case e: Elem
if e.label == "dependency"
&& e.child.exists(child => child.label == "scope") =>
def txt(label: String): String = "\"" + e.child.filter(_.label == label).flatMap(_.text).mkString + "\""
Comment(s""" scoped dependency ${txt("groupId")} % ${txt("artifactId")} % ${txt("version")} % ${txt("scope")} has been omitted """)
Comment(s""" scoped dependency ${txt("groupId")} % ${txt("artifactId")} % ${txt("version")} % ${txt(
"scope"
)} has been omitted """)
case _ => node
}
}).transform(node).head
}

Test / testOptions :=
Seq(
Tests.Argument(TestFrameworks.ScalaTest,
"-m", "org.scalatestplus.junit5",
))
Seq(Tests.Argument(TestFrameworks.ScalaTest, "-m", "org.scalatestplus.junit5"))

Test / fork := true

Test / javaOptions +="-Dorg.scalatestplus.junit5.ScalaTestEngine.disabled=true"
Test / javaOptions += "-Dorg.scalatestplus.junit5.ScalaTestEngine.disabled=true"

enablePlugins(SbtOsgi)

Expand All @@ -98,12 +98,12 @@ OsgiKeys.exportPackage := Seq(

OsgiKeys.importPackage := Seq(
"org.scalatest.*",
"org.scalactic.*",
"scala.*;version=\"$<range;[==,=+);$<replace;"+scalaBinaryVersion.value+";-;.>>\"",
"org.scalactic.*",
"scala.*;version=\"$<range;[==,=+);$<replace;" + scalaBinaryVersion.value + ";-;.>>\"",
"*;resolution:=optional"
)

OsgiKeys.additionalHeaders:= Map(
OsgiKeys.additionalHeaders := Map(
"Bundle-Name" -> "ScalaTestPlusJUnit5",
"Bundle-Description" -> "ScalaTest+JUnit5 is an open-source integration library between ScalaTest and JUnit 5 for Scala projects.",
"Bundle-DocURL" -> "http://www.scalatest.org/",
Expand Down Expand Up @@ -151,8 +151,7 @@ def docTask(docDir: File, resDir: File, projectName: String): File = {
try {
writer.println(css)
writer.println(addlCss)
}
finally { writer.close }
} finally { writer.close }
}

if (projectName.contains("scalatest")) {
Expand All @@ -163,10 +162,13 @@ def docTask(docDir: File, resDir: File, projectName: String): File = {
docDir
}

Compile / doc := docTask((Compile / doc).value,
(Compile / sourceDirectory).value,
name.value)
Compile / doc := docTask((Compile / doc).value, (Compile / sourceDirectory).value, name.value)

Compile / doc / scalacOptions := Seq("-doc-title", s"ScalaTest + JUnit5 ${version.value}",
"-sourcepath", baseDirectory.value.getAbsolutePath(),
"-doc-source-url", s"https://github.com/scalatest/releases-source/blob/main/scalatestplus-junit5/${version.value}€{FILE_PATH}.scala")
Compile / doc / scalacOptions := Seq(
"-doc-title",
s"ScalaTest + JUnit5 ${version.value}",
"-sourcepath",
baseDirectory.value.getAbsolutePath(),
"-doc-source-url",
s"https://github.com/scalatest/releases-source/blob/main/scalatestplus-junit5/${version.value}€{FILE_PATH}.scala"
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class CustomListener extends TestExecutionListener {
}

override def executionFinished(testIdentifier: TestIdentifier, testExecutionResult: TestExecutionResult): Unit = {
System.err.println(s">>>>> CustomListener: execution FINISHED: ${testIdentifier.getDisplayName} with result: ${testExecutionResult.getStatus.name()}")
System.err.println(
s">>>>> CustomListener: execution FINISHED: ${testIdentifier.getDisplayName} with result: ${testExecutionResult.getStatus.name()}"
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import org.scalatest.funsuite.AnyFunSuiteLike

class DynamicTest extends AnyFunSuiteLike {

test(s"(won't run with gradle or intellij single run) this is dynamic value -> ${System.currentTimeMillis()}") {
}
test(s"(won't run with gradle or intellij single run) this is dynamic value -> ${System.currentTimeMillis()}") {}

test(s"(wwill run with gradle, intellij class run and intellij single run) this is test with static name") {
}
test(s"(wwill run with gradle, intellij class run and intellij single run) this is test with static name") {}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,13 @@ import org.scalatest.matchers.should.Matchers
@co.helmethair.scalatest.tags.Include
class IncludeWithScalaTag extends AnyFunSpec with Matchers {
describe("test one") {
it("assert one") {

}
it("assert two") {

}
it("assert one") {}
it("assert two") {}
}

describe("test two") {
it("assert one") {

}

it("assert two") {
it("assert one") {}

}
it("assert two") {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,13 @@ import org.scalatest.matchers.should.Matchers
@co.helmethair.scalatest.tags.Skip
class SkipWithScalaTag extends AnyFunSpec with Matchers {
describe("test one") {
it("assert one") {

}
it("assert two") {

}
it("assert one") {}
it("assert two") {}
}

describe("test two") {
it("assert one") {

}
it("assert two") {

}
it("assert one") {}
it("assert two") {}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import org.scalatest.funsuite.AnyFunSuiteLike

class DynamicTest extends AnyFunSuiteLike {

test(s"(won't run with gradle or intellij single run) this is dynamic value -> ${System.currentTimeMillis()}") {
}
test(s"(won't run with gradle or intellij single run) this is dynamic value -> ${System.currentTimeMillis()}") {}

test(s"(wwill run with gradle, intellij class run and intellij single run) this is test with static name") {
}
test(s"(wwill run with gradle, intellij class run and intellij single run) this is test with static name") {}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class CustomListener extends TestExecutionListener {
}

override def executionFinished(testIdentifier: TestIdentifier, testExecutionResult: TestExecutionResult): Unit = {
System.err.println(s">>>>> CustomListener: execution FINISHED: ${testIdentifier.getDisplayName} with result: ${testExecutionResult.getStatus.name()}")
System.err.println(
s">>>>> CustomListener: execution FINISHED: ${testIdentifier.getDisplayName} with result: ${testExecutionResult.getStatus.name()}"
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import org.scalatest.funsuite.AnyFunSuiteLike

class DynamicTest extends AnyFunSuiteLike {

test(s"(won't run with gradle or intellij single run) this is dynamic value -> ${System.currentTimeMillis()}") {
}
test(s"(won't run with gradle or intellij single run) this is dynamic value -> ${System.currentTimeMillis()}") {}

test(s"(wwill run with gradle, intellij class run and intellij single run) this is test with static name") {
}
test(s"(wwill run with gradle, intellij class run and intellij single run) this is test with static name") {}

}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.8
sbt.version=1.11.2
8 changes: 8 additions & 0 deletions project/metals.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// format: off
// DO NOT EDIT! This file is auto-generated.

// This file enables sbt-bloop to create bloop config files.

addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "2.0.9")

// format: on
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,24 @@ import org.scalactic._
import reflect.macros.Context
import org.scalatest.Assertion

/**
* Macro implementation that provides rich error message for boolean expression assertion.
/** Macro implementation that provides rich error message for boolean expression assertion.
*/
private[junit5] object AssertionsForJUnitMacro {

/**
* Provides assertion implementation for <code>Assertions.assert(booleanExpr: Boolean)</code>, with rich error message.
/** Provides assertion implementation for <code>Assertions.assert(booleanExpr: Boolean)</code>, with rich error
* message.
*
* @param context macro context
* @param condition original condition expression
* @return transformed expression that performs the assertion check and throw <code>TestFailedException</code> with rich error message if assertion failed
* @param context
* macro context
* @param condition
* original condition expression
* @return
* transformed expression that performs the assertion check and throw <code>TestFailedException</code> with rich
* error message if assertion failed
*/
def assert(context: Context)(condition: context.Expr[Boolean])(prettifier: context.Expr[Prettifier], pos: context.Expr[source.Position]): context.Expr[Assertion] = {
def assert(context: Context)(
condition: context.Expr[Boolean]
)(prettifier: context.Expr[Prettifier], pos: context.Expr[source.Position]): context.Expr[Assertion] = {
import context.universe._
new BooleanMacro[context.type](context).genMacro[Assertion](
Select(
Expand All @@ -54,18 +59,27 @@ private[junit5] object AssertionsForJUnitMacro {
"macroAssert",
context.literal(""),
prettifier,
pos)
pos
)
}

/**
* Provides assertion implementation for <code>Assertions.assert(booleanExpr: Boolean, clue: Any)</code>, with rich error message.
/** Provides assertion implementation for <code>Assertions.assert(booleanExpr: Boolean, clue: Any)</code>, with rich
* error message.
*
* @param context macro context
* @param condition original condition expression
* @param clue original clue expression
* @return transformed expression that performs the assertion check and throw <code>TestFailedException</code> with rich error message (clue included) if assertion failed
* @param context
* macro context
* @param condition
* original condition expression
* @param clue
* original clue expression
* @return
* transformed expression that performs the assertion check and throw <code>TestFailedException</code> with rich
* error message (clue included) if assertion failed
*/
def assertWithClue(context: Context)(condition: context.Expr[Boolean], clue: context.Expr[Any])(prettifier: context.Expr[Prettifier], pos: context.Expr[source.Position]): context.Expr[Assertion] = {
def assertWithClue(context: Context)(
condition: context.Expr[Boolean],
clue: context.Expr[Any]
)(prettifier: context.Expr[Prettifier], pos: context.Expr[source.Position]): context.Expr[Assertion] = {
import context.universe._
new BooleanMacro[context.type](context).genMacro[Assertion](
Select(
Expand All @@ -88,17 +102,23 @@ private[junit5] object AssertionsForJUnitMacro {
"macroAssert",
clue,
prettifier,
pos)
pos
)
}

/**
* Provides implementation for <code>Assertions.assume(booleanExpr: Boolean)</code>, with rich error message.
/** Provides implementation for <code>Assertions.assume(booleanExpr: Boolean)</code>, with rich error message.
*
* @param context macro context
* @param condition original condition expression
* @return transformed expression that performs the assumption check and throw <code>TestCanceledException</code> with rich error message if assumption failed
* @param context
* macro context
* @param condition
* original condition expression
* @return
* transformed expression that performs the assumption check and throw <code>TestCanceledException</code> with rich
* error message if assumption failed
*/
def assume(context: Context)(condition: context.Expr[Boolean])(prettifier: context.Expr[Prettifier], pos: context.Expr[source.Position]): context.Expr[Assertion] = {
def assume(context: Context)(
condition: context.Expr[Boolean]
)(prettifier: context.Expr[Prettifier], pos: context.Expr[source.Position]): context.Expr[Assertion] = {
import context.universe._
new BooleanMacro[context.type](context).genMacro[Assertion](
Select(
Expand All @@ -121,18 +141,27 @@ private[junit5] object AssertionsForJUnitMacro {
"macroAssume",
context.literal(""),
prettifier,
pos)
pos
)
}

/**
* Provides implementation for <code>Assertions.assume(booleanExpr: Boolean, clue: Any)</code>, with rich error message.
/** Provides implementation for <code>Assertions.assume(booleanExpr: Boolean, clue: Any)</code>, with rich error
* message.
*
* @param context macro context
* @param condition original condition expression
* @param clue original clue expression
* @return transformed expression that performs the assumption check and throw <code>TestCanceledException</code> with rich error message (clue included) if assumption failed
* @param context
* macro context
* @param condition
* original condition expression
* @param clue
* original clue expression
* @return
* transformed expression that performs the assumption check and throw <code>TestCanceledException</code> with rich
* error message (clue included) if assumption failed
*/
def assumeWithClue(context: Context)(condition: context.Expr[Boolean], clue: context.Expr[Any])(prettifier: context.Expr[Prettifier], pos: context.Expr[source.Position]): context.Expr[Assertion] = {
def assumeWithClue(context: Context)(
condition: context.Expr[Boolean],
clue: context.Expr[Any]
)(prettifier: context.Expr[Prettifier], pos: context.Expr[source.Position]): context.Expr[Assertion] = {
import context.universe._
new BooleanMacro[context.type](context).genMacro[Assertion](
Select(
Expand All @@ -155,6 +184,7 @@ private[junit5] object AssertionsForJUnitMacro {
"macroAssume",
clue,
prettifier,
pos)
pos
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ import org.scalatest.{Assertion, Assertions}
trait VersionSpecificAssertionsForJUnit extends Assertions {
import scala.language.experimental.macros

override def assert(condition: Boolean)(implicit prettifier: Prettifier, pos: source.Position): Assertion = macro AssertionsForJUnitMacro.assert
override def assert(condition: Boolean)(implicit prettifier: Prettifier, pos: source.Position): Assertion =
macro AssertionsForJUnitMacro.assert

override def assert(condition: Boolean, clue: Any)(implicit prettifier: Prettifier, pos: source.Position): Assertion = macro AssertionsForJUnitMacro.assertWithClue
override def assert(condition: Boolean, clue: Any)(implicit prettifier: Prettifier, pos: source.Position): Assertion =
macro AssertionsForJUnitMacro.assertWithClue

override def assume(condition: Boolean)(implicit prettifier: Prettifier, pos: source.Position): Assertion = macro AssertionsForJUnitMacro.assume
override def assume(condition: Boolean)(implicit prettifier: Prettifier, pos: source.Position): Assertion =
macro AssertionsForJUnitMacro.assume

override def assume(condition: Boolean, clue: Any)(implicit prettifier: Prettifier, pos: source.Position): Assertion = macro AssertionsForJUnitMacro.assumeWithClue
override def assume(condition: Boolean, clue: Any)(implicit prettifier: Prettifier, pos: source.Position): Assertion =
macro AssertionsForJUnitMacro.assumeWithClue
}
Loading