apheleia
apheleia copied to clipboard
Formatter test fails despite the output seems to be the same
Hi, I'm trying to contribute a formatter for Rustywind (tailwindcss). It works in my Emacs and seems to be also working in the test setup that you have but the comparison doesn't path even though the diff shows identical lines.
The only way to make it pass was by trying with an empty file. Other options like having IN and OUT to be the same, etc. - failed.
What should I take care of or check for in that diff? I guess it could be something non-printed? Can it be related to the No newline... message from git diff.
I'm stuck and would be really thankful for the hint.
apheleia@206efdc28ed6:/src$ make fmt-test FORMATTERS=rustywind
diff --git a/tmp/apheleia-ft-file-0sc9WE.expected b/tmp/apheleia-ft-file-0WlzpU.actual
index 092f883..3534fe8 100644
--- a/tmp/apheleia-ft-file-0sc9WE.expected
+++ b/tmp/apheleia-ft-file-0WlzpU.actual
@@ -1 +1 @@
-<div class="flex flex-col mx-auto text-white md:flex-row xl:py-10 2xl:py-20 dark:text-purple-500">Fancy test div</div>
+<div class="flex flex-col mx-auto text-white md:flex-row xl:py-10 2xl:py-20 dark:text-purple-500">Fancy test div</div>
\ No newline at end of file
Formatter rustywind did not format as expected
make: *** [Makefile:76: fmt-test] Error 255
Is the formatter stripping the trailing newline from your file? If so, can that be disabled?
@raxod502, I ran several tests and the formatter indeed removes the newline at the end of a file when it's used with --stdin option. I haven't found a way to disable this behavior. When used from the command line it keeps the new line because it probably rewrites the whole file.
I think because it's just sorting CSS classes in a string it usually treats newline in a special way when --stdin option is used. Do you have an idea how to deal with this and if there's a way to make the tests happy?
I'd submit a bug report upstream - all files on Linux end with a trailing newline and if a tool is producing something else, I'd consider that a bug. If upstream is not willing to fix their implementation, we can add a workaround here, but it seems best to check with them first.
@raxod502, I'll do as you say. Let's see about their reply.
Let's hope for a fast fix:
- https://github.com/avencera/rustywind/issues/62
- https://github.com/avencera/rustywind/pull/63
Heh, seems like upstream might not be the most responsive. If we can't get it fixed there, then I don't think it would be the worst thing to include a wrapper script to append a newline, much like https://github.com/radian-software/apheleia/blob/04366a90dfc1063c4a22ea2e4ccaa48303a457e0/scripts/formatters/apheleia-phpcs works around an exit code issue.
Hey @artemkovalyov should be fixed in new release: https://github.com/avencera/rustywind/releases/tag/v0.15.1
Amazing, thank you!
This thread is being closed automatically by Tidier because it is labeled with "waiting on response" and has not seen any activity for 90 days. But don't worry—if you have any information that might advance the discussion, leave a comment and I will be happy to reopen the thread :)