-
Notifications
You must be signed in to change notification settings - Fork 1
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
Testing formatters #3
Comments
Can you elaborate on this part? I'd be happy to make this more formatter friendly if I know what features are needed for it. I know that the currently generated diff images are a little hard to use, but I've already got plans on how to improve this. Currently, you can already use it in non typst packages using the |
Elaborating : You'd use something like
This naive approach would already give pretty good result and help notice when formatting a document broke something, I tried my hand at that but got too busy a while ago |
I'm not sure if I want to tie testing so close to formatting. But I see how comparing two different versions of the same document which are both created on demand would also be helpful. I'm trying to think of a nice way to fit this into the current system without trying it too closely to formatting. Perhaps by allowing the user to create the references on demand, using the custom actions which are run before/after tests. |
|
I mean the reference images, creating them on demand instead of assuming they exist, would be some kind of action the suer could specify for a test, and how to do that exactly. |
@astrale-sharp hey it's been a while, I've implemented They come with some rough edges, as I don't have any custom user actions to actually do any action on the test file before creating the references for now, so you'd need a task runner which does this for you. You can do the following to test it out:
I've run this locally with Nushell and a Justfile like so: fmt := './typstfmt'
tt := 'typst-test --root .'
test:
#! /usr/bin/env nu
let tests = {{ tt }} list --format=plain | lines | split column ' ' name type
for test in $tests {
let ref = ('tests' | path join $test.name | path join 'ref.typ')
let test = ('tests' | path join $test.name | path join 'test.typ')
{{ fmt }} $ref -o $test
}
{{ tt }} run Essentially, I'm planning to make this whole ordeal easier to use, but for now I'm busy with my master’s thesis, so I can't work on the rewrite all that often :/. |
I'll close this as completed, |
Looks really nice!
Maybe it could be use to test formatters as well!
Given a formatter and a test file
Apply diffs with dichotomy and test the output, it's a bit of a headache to implement because the diff types I used were hard to understand I think
It could happily live next to typstfmt when I get up to it but I think it might be better suited in typst-test
The text was updated successfully, but these errors were encountered: