Skip to content

Testing CLI apps #9

@killercup

Description

@killercup

(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

@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)A-testing-tuiArea: Testing of time and user dependent CLIsC-tracking-issueCategory: A tracking issue for an unstable feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions