Skip to content

Commit

Permalink
Alternative way to enable fill file path names in scalactic
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill Saksin committed Mar 19, 2020
1 parent 4e1e38e commit fc697aa
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
Expand Up @@ -57,7 +57,7 @@ notValidPosZFloat=PosZFloat.apply can only be invoked on a non-negative (n >= 0.
notLiteralPosZFloat=PosZFloat.apply can only be invoked on a floating point literal, like PosZFloat(42.0F). Please use PosZFloat.from instead.
notValidPosZDouble=PosZDouble.apply can only be invoked on a non-negative (n >= 0.0 && !n.isNaN) floating point literal, like PosZDouble(42.0).
notLiteralPosZDouble=PosZDouble.apply can only be invoked on a floating point literal, like PosZDouble(42.0). Please use PosZDouble.from instead.
pleaseDefineScalacticFillFilePathnameEnvVar=Please set the environment variable SCALACTIC_FILL_FILE_PATHNAMES to yes at compile time to enable this feature.
pleaseDefineScalacticFillFilePathnameEnvVar=Please set the environment variable SCALACTIC_FILL_FILE_PATHNAMES (or property scalactic.fillFilePathnames) to yes at compile time to enable this feature.
notValidNonZeroInt=NonZeroInt.apply can only be invoked on a non-zero (n != 0) integer literal, like NonZeroInt(42).
notLiteralNonZeroInt=NonZeroInt.apply can only be invoked on an integer literal, like NonZeroInt(42). Please use NonZeroInt.from instead.
notValidNonZeroLong=NonZeroLong.apply can only be invoked on a non-zero (n != 0L) long literal, like NonZeroLong(42L).
Expand Down
Expand Up @@ -28,8 +28,11 @@ object PositionMacro {
import sourceCompatHack._

private[scalactic] lazy val showScalacticFillFilePathnames: Boolean = {
val value = System.getenv("SCALACTIC_FILL_FILE_PATHNAMES")
value != null && value == "yes"
val enabledThroughEnv = System.getenv("SCALACTIC_FILL_FILE_PATHNAMES")
val enabledThroughProp = System.getProperty("scalactic.fillFilePathnames")

(enabledThroughEnv != null && enabledThroughEnv == "yes") ||
(enabledThroughProp != null && enabledThroughProp == "yes")
}

private class PositionMacroImpl(val universe: scala.reflect.api.Universe) {
Expand Down
Expand Up @@ -63,7 +63,7 @@ class LocationSpec extends FunSpec {
if (System.getenv("SCALACTIC_FILL_FILE_PATHNAMES") != null && System.getenv("SCALACTIC_FILL_FILE_PATHNAMES") == "yes")
assert(filePathname.endsWith(s"org${sep}scalatest${sep}events${sep}LocationSpec.scala"))
else
assert(filePathname == "Please set the environment variable SCALACTIC_FILL_FILE_PATHNAMES to yes at compile time to enable this feature.")
assert(filePathname == "Please set the environment variable SCALACTIC_FILL_FILE_PATHNAMES (or property scalactic.fillFilePathnames) to yes at compile time to enable this feature.")
}
}
}
Expand Down
Expand Up @@ -395,7 +395,7 @@ import StringReporter.withPossibleLineNumber
if (System.getenv("SCALACTIC_FILL_FILE_PATHNAMES") != null && System.getenv("SCALACTIC_FILL_FILE_PATHNAMES") == "yes")
assert(result endsWith "org/scalatest/tools/StringReporterSuite.scala:" + (thisLineNumber - 3) + " **")
else
assert(result endsWith "Please set the environment variable SCALACTIC_FILL_FILE_PATHNAMES to yes at compile time to enable this feature.:" + (thisLineNumber - 5) + " **")
assert(result endsWith "Please set the environment variable SCALACTIC_FILL_FILE_PATHNAMES (or property scalactic.fillFilePathnames) to yes at compile time to enable this feature.:" + (thisLineNumber - 5) + " **")
}

class BuilderStringReporter(presentInColor: Boolean) extends StringReporter(
Expand Down
Expand Up @@ -195,7 +195,7 @@ class XmlSocketReporterSpec extends FunSpec with Eventually {
if (System.getenv("SCALACTIC_FILL_FILE_PATHNAMES") != null && System.getenv("SCALACTIC_FILL_FILE_PATHNAMES") == "yes")
assert((scopeOpened \ "location" \ "LineInFile" \ "filePathname").text endsWith s"org${sep}scalatest${sep}tools${sep}${fileName}")
else
assert((scopeOpened \ "location" \ "LineInFile" \ "filePathname").text endsWith "Please set the environment variable SCALACTIC_FILL_FILE_PATHNAMES to yes at compile time to enable this feature.")
assert((scopeOpened \ "location" \ "LineInFile" \ "filePathname").text endsWith "Please set the environment variable SCALACTIC_FILL_FILE_PATHNAMES (or property scalactic.fillFilePathnames) to yes at compile time to enable this feature.")
}

def checkTestStarting(testStarting:Elem, suiteName: String, suiteId: String, suiteClassName: Option[String],
Expand All @@ -211,7 +211,7 @@ class XmlSocketReporterSpec extends FunSpec with Eventually {
if (System.getenv("SCALACTIC_FILL_FILE_PATHNAMES") != null && System.getenv("SCALACTIC_FILL_FILE_PATHNAMES") == "yes")
assert((testStarting \ "location" \ "LineInFile" \ "filePathname").text endsWith s"org${sep}scalatest${sep}tools${sep}${fileName}")
else
assert((testStarting \ "location" \ "LineInFile" \ "filePathname").text endsWith "Please set the environment variable SCALACTIC_FILL_FILE_PATHNAMES to yes at compile time to enable this feature.")
assert((testStarting \ "location" \ "LineInFile" \ "filePathname").text endsWith "Please set the environment variable SCALACTIC_FILL_FILE_PATHNAMES (or property scalactic.fillFilePathnames) to yes at compile time to enable this feature.")
checkStringOption((testStarting \ "rerunner").text, rerunner)
}

Expand All @@ -227,7 +227,7 @@ class XmlSocketReporterSpec extends FunSpec with Eventually {
if (System.getenv("SCALACTIC_FILL_FILE_PATHNAMES") != null && System.getenv("SCALACTIC_FILL_FILE_PATHNAMES") == "yes")
assert((testSucceeded \ "location" \ "LineInFile" \ "filePathname").text endsWith s"org${sep}scalatest${sep}tools${sep}${fileName}")
else
assert((testSucceeded \ "location" \ "LineInFile" \ "filePathname").text endsWith "Please set the environment variable SCALACTIC_FILL_FILE_PATHNAMES to yes at compile time to enable this feature.")
assert((testSucceeded \ "location" \ "LineInFile" \ "filePathname").text endsWith "Please set the environment variable SCALACTIC_FILL_FILE_PATHNAMES (or property scalactic.fillFilePathnames) to yes at compile time to enable this feature.")
checkStringOption((testSucceeded \ "rerunner").text, rerunner)
}

Expand Down Expand Up @@ -255,7 +255,7 @@ class XmlSocketReporterSpec extends FunSpec with Eventually {
if (System.getenv("SCALACTIC_FILL_FILE_PATHNAMES") != null && System.getenv("SCALACTIC_FILL_FILE_PATHNAMES") == "yes")
assert((testPending \ "location" \ "LineInFile" \ "filePathname").text endsWith s"org${sep}scalatest${sep}tools${sep}${fileName}")
else
assert((testPending \ "location" \ "LineInFile" \ "filePathname").text endsWith "Please set the environment variable SCALACTIC_FILL_FILE_PATHNAMES to yes at compile time to enable this feature.")
assert((testPending \ "location" \ "LineInFile" \ "filePathname").text endsWith "Please set the environment variable SCALACTIC_FILL_FILE_PATHNAMES (or property scalactic.fillFilePathnames) to yes at compile time to enable this feature.")
checkStringOption((testPending \ "rerunner").text, rerunner)
}

Expand All @@ -271,7 +271,7 @@ class XmlSocketReporterSpec extends FunSpec with Eventually {
if (System.getenv("SCALACTIC_FILL_FILE_PATHNAMES") != null && System.getenv("SCALACTIC_FILL_FILE_PATHNAMES") == "yes")
assert((testIgnored \ "location" \ "LineInFile" \ "filePathname").text endsWith s"org${sep}scalatest${sep}tools${sep}${fileName}")
else
assert((testIgnored \ "location" \ "LineInFile" \ "filePathname").text endsWith "Please set the environment variable SCALACTIC_FILL_FILE_PATHNAMES to yes at compile time to enable this feature.")
assert((testIgnored \ "location" \ "LineInFile" \ "filePathname").text endsWith "Please set the environment variable SCALACTIC_FILL_FILE_PATHNAMES (or property scalactic.fillFilePathnames) to yes at compile time to enable this feature.")
}

def checkTestCanceled(testCanceled: Elem, message: String, suiteName: String, suiteId: String, suiteClassName: Option[String],
Expand All @@ -287,7 +287,7 @@ class XmlSocketReporterSpec extends FunSpec with Eventually {
if (System.getenv("SCALACTIC_FILL_FILE_PATHNAMES") != null && System.getenv("SCALACTIC_FILL_FILE_PATHNAMES") == "yes")
assert((testCanceled \ "location" \ "LineInFile" \ "filePathname").text endsWith s"org${sep}scalatest${sep}tools${sep}${fileName}")
else
assert((testCanceled \ "location" \ "LineInFile" \ "filePathname").text endsWith "Please set the environment variable SCALACTIC_FILL_FILE_PATHNAMES to yes at compile time to enable this feature.")
assert((testCanceled \ "location" \ "LineInFile" \ "filePathname").text endsWith "Please set the environment variable SCALACTIC_FILL_FILE_PATHNAMES (or property scalactic.fillFilePathnames) to yes at compile time to enable this feature.")
}

def checkSuiteStarting(suiteStarting: Elem, suiteName: String, suiteId: String, suiteClassName: Option[String],
Expand Down

0 comments on commit fc697aa

Please sign in to comment.