typelevel / typelevel/weaver-test
Initialization bug with helpers over `test`
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 85
- Forks
- 15
- PR merge metrics
- No merged PRs in 30d
Description
This issue was copied over from: https://github.com/disneystreaming/weaver-test/issues/705
It was opened by: BalmungSan
I found a strange issue with weaver around initialization... or at least that is what I think.
It is a bit involved but hopefully, I can provide enough info for someone to take a look.
// First, we need a base Suite with a bunch of helpers:
trait FooBaseSuite extends IOSuite:
override final val maxParallelism: Int = 1
override final type Res = FooRes
override final val sharedResource: Resource[IO, Res] = ???
// Define helper method to reduce boilerplate:
protected def fooTest(name: String)(check: Foo => Expectations): Unit =
test(name) { foo =>
IO(check(foo))
}
// Then we need an object that extends such base Suite:
object FooSpec extends FooBaseSuite:
// And use the helper method:
fooTest(name = "Testing foo") { foo =>
expect(...)
}
The tests will fail because Foo is already closed (or so I think).
There are a couple of ways to fix the issue:
- Don't have a
trait+objectbut just a singleobject - Remove the
fooTesthelper and replicate the boilerplate in eachtest - Make
FooSpecaclasswhich accepts an (unused)GlobalRead
Things that didn't work:
- Using
abstract classrather thantrait - Moving
fooTestfrom thetrait(FooBaseSuite) to theobject(FooSpec)
More info:
- Scala
3.3.1 - weaver:
0.8.3 - cats-effect:
3.5.1 - sbt:
1.9.6 - Java: GraalVM CE
17.0.8 - OS: Mac
14.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file or test is named; start by reproducing the FooBaseSuite/FooSpec example with Scala 3.3.1, weaver 0.8.3, and cats-effect 3.5.1. Trace IOSuite initialization and resource lifetime around helper-registered tests, then verify that Foo remains usable and add a regression test for the trait/object case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100