Skip to content

Commit

Permalink
test(mangen): Add test for flatten_help
Browse files Browse the repository at this point in the history
This test shows that the output stays the same independent of the value
of `flatten_help`. Further commits may implement `flatten_help` for
`clap_mangen`.

Signed-off-by: Paul Spooren <[email protected]>
  • Loading branch information
aparcar committed Oct 17, 2024
1 parent 61f5ee5 commit 70d80fc
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
26 changes: 26 additions & 0 deletions clap_mangen/tests/snapshots/flatten_help.roff
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.TH my-app 1 "my-app "
.SH NAME
my\-app
.SH SYNOPSIS
\fBmy\-app\fR [\fB\-c \fR] [\fB\-v \fR] [\fB\-h\fR|\fB\-\-help\fR] [\fIsubcommands\fR]
.SH DESCRIPTION
.SH OPTIONS
.TP
\fB\-c\fR

.TP
\fB\-v\fR

.TP
\fB\-h\fR, \fB\-\-help\fR
Print help
.SH SUBCOMMANDS
.TP
my\-app\-test(1)
Subcommand
with a second line
.TP
my\-app\-help(1)
Print this message or the help of the given subcommand(s)
14 changes: 14 additions & 0 deletions clap_mangen/tests/testsuite/roff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,17 @@ fn value_name_without_arg() {
cmd,
);
}

#[test]
fn flatten_help_false() {
let name = "my-app";
let cmd = common::basic_command(name).flatten_help(false);
common::assert_matches(snapbox::file!["../snapshots/basic.bash.roff"], cmd);
}

#[test]
fn flatten_help_true() {
let name = "my-app";
let cmd = common::basic_command(name).flatten_help(true);
common::assert_matches(snapbox::file!["../snapshots/flatten_help.roff"], cmd);
}

0 comments on commit 70d80fc

Please sign in to comment.