LNT --help isn't very descriptive
| Bugzilla Link | 32789 |
| Resolution | FIXED |
| Resolved on | Jun 28, 2017 07:58 |
| Version | unspecified |
| OS | Linux |
| CC | @cmatthew,@kbeyls,@MatzeB |
Extended Description
For instance, running lnt runtest test-suite --help, I see this: --use-perf=USE_PERF Use Linux perf for high accuracy timing, profile information or both --perf-events=PERF_EVENTS
From that, I have no idea what the valid options for USE_PERF or PERF_EVENTS are. I don't know much about LNT internals, but Kristof says using argparse instead of the obsolete optparse would make things better in this respect.
The change was merged today in the context of https://reviews.llvm.org/D33541. So, marking the issue as resolved.
I've just sent a code review with a fix proposal for this issue.
On a first attempt I was intending to argparse, in order to avoid one more dependency. However, argparse has a critical open issue that directly impacts some options like --cflags '-Wfoo'. I tried to work around but it was an unacceptably hacky solution. This is https://bugs.python.org/issue9334.
Then I started looking at click as suggested on comment 2. It works fine in the --cflags case where argparse get confused. After that, I ported all the supported commands to use click.
Regarding the original reported problem, it looks like click provides a better output with the possible choices being listed near the options.
Before: --use-perf=USE_PERF Use Linux perf for high accuracy timing, profile information or both --perf-events=PERF_EVENTS Define which linux perf events to measure
After: --use-perf [none|time|profile|all] Use Linux perf for high accuracy timing, profile information or both --perf-events TEXT Define which linux perf events to measure
At the moment I see two issues with click for our use-case:
-
There is no equivalent to optparse.OptionGroup that is currently being used to organize the massive number of options we have on “lnt runtest nt|compile|test-suite *”. This is actually an open issue on click (https://github.com/pallets/click/issues/373).
-
Click uses unicode strings by default on the string option values, which caused problems in some of our inputs like the instance_path. I marked the ones I spotted to be plain strings and at the moment the tests are passing on the proposed fix, under review (https://reviews.llvm.org/D33486).
I think the 2.7 requirement is not a big deal now. We should definitely change this. Using one of these newer frameworks like click might work too. Many of them natively support this subcommand mode that we use. If switching to argparse is easy though, lets just do that.
From the documentation and a few StackOverflow posts, I indeed think that the help text would be improved in the way Diana envisions if we'd move from using optparse to using argparse. I think that would result in requiring python 2.7 - but I'm assuming that wouldn't be an issue for anyone?