You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The main problem this addresses are:
- Diffs are noisy.
Datamodel tests involve large strings literals, and very little
significant information otherwise. In a single file, even for simple
changes like reordering or renaming tests, or changing indentation,
the diffs get unreadable quickly, as the large blocks of Prisma
schemas and validation errors get mixed with the test function names
and calls to test helpers. This state of things disincentivizes
reorganizing tests. The new setup has one test per file, with the test
name being the file name, including its full path from the validation
tests root.
- Churn.
We often need to subtly adjust many tests to account for trivial
changes in the public APIs, when all we want to do is assert that a
certain schema is valid, or invalid with a given error. This prevents
us from evolving the datamodel API as much as we would like, and as a
consequence of these changes being a lot of work, we have a lot of
inconsistency in how tests are written and which test helpers are
used. This has manifested recently in difficulties simply moving
tests, without changing them, from `libs/datamodel/core` to `psl/psl`.
With this test suite, we rely on a lot less context, setup and noise
(variable names for expectations). We don't expect the shape of these
tests to evolve much, churn should be minimal and if we need to change
something, it will be possible to autofix through UPDATE_EXPECT=1.
- The test suite gets slower to compile as we add more tests, and that
noticeably hurts our feedback loops.
This setup is less rust code to compile: each test case translates to
a single test function containing a single synchronous function call.
We can transparently make test runs compile no rust code at all in the
future if we need to.
Prior art:
- In prisma-engines: we already did that in introspection engine tests in that commit: ef84679
- In other compiler-like projects, this is a common approach. Here are a few examples:
- go compiler (https://github.com/golang/go/blob/master/test/assign1.go)
- rustc UI tests (https://github.com/rust-lang/rust/tree/master/src/test/ui)
- zig compiler (ziglang/zig#11288)
next steps: same setup for reformatting tests
0 commit comments