Skip to content
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

HasTests: show line number with config error #3946

Merged
merged 1 commit into from
May 4, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand All @@ -96,6 +96,7 @@ trait HasTests extends FormatAssertions {
base.copy(runner = base.runner.withParser(x))
}
},
1,
)

@tailrec
Expand All @@ -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,
Expand Down
Loading