-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat(cli): add test listing and allow users to parse a specific test number #3067
Conversation
No worries, y'all have been doing a ton of cool stuff with the project lately!
👍
Makes sense to me 😄
That seems fair. Since the tests are accessed in a recursive manner, it's hard to know the total number of tests up front. I think it probably makes sense to have a fixed width for the test number. I checked over some of the more popular grammars and it seems like 3 digits should be fine for this (unless there's grammars out there with 1000+ tests). Alternatively the code could do a quick dry run to iterate through and count all the tests, but I imagine that's a bit overkill. Thanks so much for taking a look! I should be able to spend some time on this soon! :) |
Here's a first pass on your feedback. I now have the test numbers printing out (with a set width of 3 characters) by default.
Let me know if there's anything else I can do to improve this. :) |
a5965a4
to
b76dce4
Compare
mind rebasing? I can take a look & get it in then |
On it :) |
1cd7362
to
59090c9
Compare
what happened to |
I just pushed some changes, including squashing your commits into one, as well as
|
Yeah I had removed
The let else for early bails is indeed much nicer, and I really like avoiding the allocation in |
tbh, it's fine as a default. it's probably good for authors who are in a rapid developing & testing cycle without having to remember to use the I do think we should use
No problem 😁 I also think we should just use tempfile and pass in the given file since it'll auto delete on |
Ok, scratch that last idea. temp files are annoying since |
Sounds good!
Wasn't aware of this dependency, but that's really cool! I was trying to work out how to pass the file around with changing too much of the existing iteration, but like you said it was a little annoying. I was taking a look at the docs and TempPath looked promising. It's a path that deletes its corresponding file when EDIT: Oh nevermind, I see what you mean. 😆 |
7f56db3
to
7914b47
Compare
Okay, coming back to this I opted to print the test # and name - it was a little unclear which one was actually being parsed, and I also account for users starting their count at 1. I also used coloring for the test name itself, similar to the |
018ed42
to
38a240f
Compare
--test-input <test_number>
for parse
, --list
for test
also handles multi grammar repos with specific attributes now as well, that was nagging me |
I was interested in implementing some of the changes described in #2726. Namely,
I used the existing ordering already in place from the
test
subcommand.When provided with a test number
x
,parse --test-input x
will parse the contents of testx
. Specifically, the test's contents are extracted, written to a temporary file, and thenparse
continues execution with the path to said temporary file. Listing all of the tests with their numbers seemed redundant withtest --list
(described below), so I didn't implement that.Running
test --list
will list tests with their respective numbers. This should still respect the--filter
,--include
, and--exclude
arguments if provided. It currently only prints each test's name and leaves the inputs/ expected trees out. I'm assuming there will be further discussion on what should be printed here?Happy to make fixes, refactor, and/or split this up as needed. Hope this helps! :)
Closes #2726