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
Basic Automated Test Harness #26
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love how simple it is to add a test, just adding the two files and no extra busywork required!
test/test-formatters.bash
Outdated
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
find formatters/ -type f,l ! -name "*.formatted" | while read f; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-type f,l
Do we want to find symlinks, or just files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've used symlinks for modes that are likely to be working on the same code with the same formatter e.g. rust-mode and rustic-mode both work on Rust and likely use rustfmt. I can strengthen the requirement if you like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, that makes sense.
Since the callback of apheleia--run-formatter is run in an asynchronous process, all output to stdout was being handled by the inferior process. Output must be retrieved in the main process with accept-process-output. Additionally, any formatter that uses the file directive will not run if buffer doesn't match the file on disk. with-temp-buffer doesn't have an associated file so most formatters wouldn't run.
Ensures apheleia-formatters and apheleia-mode-alist have no missing or incorrect entries in the README.
The good:
The bad:
The ugly:
If none of those issues are too big, I'd say this is ready to merge. |
I fixed things up so CI will run in only 2-3 minutes, and made various other improvements. The main thing remaining is that there seems to be something wrong with json-mode in Emacs 25, do you think you could take a look at that? |
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 :) |
I wrote my own version of this in #72, partly drawing from the code here. The only things missing are package-lint integration, and the auto-generated table of formatters in the README. |
Here is a very simple framework for ensuring all the formatters properly configured. Currently, it has a small issue in that it doesn't actually work.
Each test consists of two files of the format
formatters/mode-it-should-be-active-in/formatter.ext
andformatters/mode-it-should-be-active-in/formatter.ext.formatted
. The former is unformatted code while the latter is the expected output after running the formatter.test-apheleia.el
should (but doesn't) return the result of calling the given formatter on the unformatted code to stdout.All output from
test-apheleia.el
should be coming from theapheleia--run-formatters
function. I think any stdout is being smothered because it's called from the async inferior process. How would I maketest-apheleia.el
return the formatted buffer to stdout?TODO:
test-apheleia.el
work.apheleia-modes-alist
andapheleia-formatters
.