scalameta / munit

Scala testing library with actionable errors and extensible APIs
https://scalameta.org/munit
Apache License 2.0
428 stars 88 forks source link

Add `contextSize` test parameter to enlarge the scope of a diff #788

Open TonioGela opened 3 months ago

TonioGela commented 3 months ago

As per description, this PR introduces a contextSize overridable suite parameter that control the number of lines around the reported diff in case of a mismatch ( ala grep -A <n> -B <n>)

Ofc the normal behaviour was kept identical to the actual, and there's no change in the user API (at least for the methods used via Assertions)

TonioGela commented 3 months ago

Hmm, given that a lot of the stuff in Diff is effectively exposed the mima check screams with 11 compatibility errors. I'll try to figure out a better encoding for the content of this PR, so don't take it too seriously for the moment 😇

tgodzik commented 3 months ago

Shouldn't this be a parameter to the runner https://github.com/scalameta/munit/blob/8b63f0e7f8574cd7910816d171d98bbf2507d672/munit/js-native/src/main/scala/munit/internal/junitinterface/JUnitFramework.scala#L110 ?

TonioGela commented 3 months ago

Shouldn't this be a parameter to the runner

https://github.com/scalameta/munit/blob/8b63f0e7f8574cd7910816d171d98bbf2507d672/munit/js-native/src/main/scala/munit/internal/junitinterface/JUnitFramework.scala#L110 ?

Interesting question. Going further: should it just be a parameter or also a parameter?

tgodzik commented 3 months ago

I think just a parameter since it doesn't really change the test logic, but how the test is being displayed. Potentially we could have runner defaults for a specific suite as a separate thing.

tgodzik commented 3 months ago

btw. MiMa is not a huge issue here, we would need to do 1.1.x next so that it's automatically picked up as possible incompatibility

TonioGela commented 3 months ago

I think just a parameter since it doesn't really change the test logic, but how the test is being displayed. Potentially we could have runner defaults for a specific suite as a separate thing.

Okay, this seems reasonable. I'll try to rework it. I'll also try to add documentation about that flag maybe here: https://scalameta.org/munit/docs/troubleshooting.html