-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Labels
A-testing-cliArea: One-shot testing of CLIs (no interaction)Area: One-shot testing of CLIs (no interaction)A-testing-tuiArea: Testing of time and user dependent CLIsArea: Testing of time and user dependent CLIsC-tracking-issueCategory: A tracking issue for an unstable featureCategory: A tracking issue for an unstable feature
Description
(moderated summary by @epage)
Context
Common inputs to a CLI
- Files
- Command line flags
- Environment variables
- stdin
- signals
Common outputs to a CLI
- Files (sometimes unique, sometimes mutating the input)
- stdout
Plan of Attack
Testing crate(s)
- Make it easy to initialize a tempdir
- Copy files over from tests dir
touch
files- dump string to a file in tempdir
- cmd assertions
- stdout
- exit code
- file system assertions
- file exists
- file content assertions
- fixture dir is a subset of target dir, reporting the differences
- fixture dir exactly matches target dir, reporting the differences
In-ecosystem resources
- tempfile
- dir-diff
- assert_cli
- cli_test_dir
- Can serve as inspiration but changing it based on input from this WG seems limited
- From a deleted issue: "At this point, the API of cli_test_dir is unlikely to break backwards compatibility in any major ways. I'm happy to add new features to it that people need. And if anybody would like to re-export parts of it, I'm happy to do that, too."
Challenges
- Mocking
- Should this be a priority?
- For unit tests, we should probably encourage a higher level abstraction over the file system that can instead be mocked
- For integration and end-to-end tests, we should probably run against real resources
- Should this be a priority?
- Symbolic links on windows
- Testing colored output
- Testing signal handling
@killercup's original post
In the first meeting, we identified that testing CLI apps cross-platform is not trivial and that we want to improve the situation.
Metadata
Metadata
Labels
A-testing-cliArea: One-shot testing of CLIs (no interaction)Area: One-shot testing of CLIs (no interaction)A-testing-tuiArea: Testing of time and user dependent CLIsArea: Testing of time and user dependent CLIsC-tracking-issueCategory: A tracking issue for an unstable featureCategory: A tracking issue for an unstable feature