Feature request: a way to programmatically test the completions #327
-
https://docs.rs/bpaf/latest/bpaf/#testing-your-parsers-and-running-them lists a few ways to test the parser. But what about testing completions? I could probably inspect what flags the generated completion uses, and then use that directly when testing the parser, but I presume that is not a public API to be relied upon. What is the recommended way (if any) to write tests for the completion? I don't want to make a integration test that executes the actual binary: that doesn't work at all when cross compiling with cross (it runs the tests under qemu user mode emulation). |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
First you can take a look at completion tests - they are using public API only. Then there's comtester crate. You'll probably have to clone it and add to your repo in some way, but it can configure the completion environment, run each command line in a separate shell and collect the results. You'll have to make sure shells you want to test on are available. I'm planning to make changes to it to make it more end user friendly, big documentation update I'm working on is somewhat related to this change. And finally https://crates.io/crates/completest crate - a fork of Later two methods require running a binary and test all the things end to end, they take longer to run though. |
Beta Was this translation helpful? Give feedback.
First you can take a look at completion tests - they are using public API only.
set_comp
with revision 0 generates some textual shell agnostic representation for completionbpaf
would generate. 0th revision is something I consider to be public API and not planning to remove or change. If you want to test your part of the completion without running the binary - that's where I would start.Then there's comtester crate. You'll probably have to clone it and add to your repo in some way, but it can configure the completion environment, run each command line in a separate shell and collect the results. You'll have to make sure shells you want to test on are available. I'm planning to make chang…