From cee0e9c156470c4ceed2c93bbe7aa5f5d98aaeaf Mon Sep 17 00:00:00 2001 From: Albert Meltzer <7529386+kitbellew@users.noreply.github.com> Date: Sat, 4 May 2024 06:19:22 -0700 Subject: [PATCH] HasTests: show line number with config error --- .../src/test/scala/org/scalafmt/util/HasTests.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scalafmt-tests/src/test/scala/org/scalafmt/util/HasTests.scala b/scalafmt-tests/src/test/scala/org/scalafmt/util/HasTests.scala index fe360ae17f..fdb3ab24aa 100644 --- a/scalafmt-tests/src/test/scala/org/scalafmt/util/HasTests.scala +++ b/scalafmt-tests/src/test/scala/org/scalafmt/util/HasTests.scala @@ -81,10 +81,10 @@ trait HasTests extends FormatAssertions { val moduleOnly = isOnly(head) val moduleSkip = isSkip(head) - def loadStyle(cfg: String, base: ScalafmtConfig): ScalafmtConfig = + def loadStyle(cfg: String, base: ScalafmtConfig, ln: Int): ScalafmtConfig = ScalafmtConfig.fromHoconString(cfg, base).getOrRecover { c => throw new IllegalArgumentException( - s"""|Failed to parse filename $filename: + s"""|Failed to parse line=$ln filename $filename: |$cfg |$c""".stripMargin, ) @@ -96,6 +96,7 @@ trait HasTests extends FormatAssertions { base.copy(runner = base.runner.withParser(x)) } }, + 1, ) @tailrec @@ -117,7 +118,7 @@ trait HasTests extends FormatAssertions { val original = matcher.group(3) val altFilename = Option(matcher.group(4)) val expected = matcher.group(5) - val testStyle = extraConfig.fold(style)(loadStyle(_, style)) + val testStyle = extraConfig.fold(style)(loadStyle(_, style, linenum)) val actualName = stripPrefix(name) val test = DiffTest( actualName,