Pino Toscano
2019-Dec-11 13:26 UTC
[Libguestfs] [PATCH 1/2] podcheck: __INCLUDE:file.pod__ and __VERBATIM:file.txt__ in POD files.
Make sure the pod checker script can deal with the newer additions of podwrapper.pl. Followup of commit 46e59e9535c2fcd1c188464b5249a249f22af1a0. --- podcheck.pl | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/podcheck.pl b/podcheck.pl index 527a2e47d..795fe0e9b 100755 --- a/podcheck.pl +++ b/podcheck.pl @@ -83,6 +83,15 @@ used where the POD includes patterns which podwrapper would substitute. =cut +my @paths; + +=item B<--path DIR> + +This works like the L<podwrapper.pl(1)> I<--path> option and should be +used where the POD includes patterns which podwrapper would substitute. + +=cut + # Clean up the program name. my $progname = $0; $progname =~ s{.*/}{}; @@ -91,6 +100,7 @@ $progname =~ s{.*/}{}; GetOptions ("help|?" => \$help, "ignore=s" => \$ignore, "insert=s" => \@inserts, + "path=s" => \@paths, "verbatim=s" => \@verbatims, ) or pod2usage (2); pod2usage (1) if $help; @@ -117,6 +127,10 @@ foreach (@inserts) { if $content eq $oldcontent; } +# Perform INCLUDE directives. +$content =~ s{__INCLUDE:([-a-z0-9_]+\.pod)__} + {read_whole_file ("$1", use_path => 1)}ge; + # Perform @verbatims. foreach (@verbatims) { my @a = split /:/, $_, 2; @@ -128,6 +142,10 @@ foreach (@verbatims) { if $content eq $oldcontent; } +# Perform VERBATIM directives. +$content =~ s{__VERBATIM:([-a-z0-9_]+\.txt)__} + {read_verbatim_file ("$1", use_path => 1)}ge; + # Run the tool with --long-options and --short-options. my @tool_options = (); open PIPE, "$tool --long-options |" @@ -235,11 +253,27 @@ printf "$progname: $tool: checked $tool_options_checked tool options, $pod_optio exit 0; +sub find_file +{ + my $input = shift; + my $use_path = shift; + local $_; + + my @search_path = ("."); + push (@search_path, @paths) if $use_path; + foreach (@search_path) { + return "$_/$input" if -f "$_/$input"; + } + die "$progname: $input: cannot find input file on path" +} + sub read_whole_file { my $input = shift; + my %options = @_; local $/ = undef; + $input = find_file ($input, $options{use_path}); open FILE, $input or die "$progname: $input: $!"; $_ = <FILE>; close FILE; @@ -249,8 +283,10 @@ sub read_whole_file sub read_verbatim_file { my $input = shift; + my %options = @_; my $r = ""; + $input = find_file ($input, $options{use_path}); open FILE, $input or die "$progname: $input: $!"; while (<FILE>) { $r .= " $_"; -- 2.23.0
Pass to the various podcheck invocations the paths with POD files that are included. Followup of commit 46e59e9535c2fcd1c188464b5249a249f22af1a0. --- cat/test-docs.sh | 13 +++++++++---- customize/test-virt-customize-docs.sh | 1 + diff/test-virt-diff-docs.sh | 1 + edit/test-virt-edit-docs.sh | 3 ++- fish/test-docs.sh | 4 +--- fuse/test-docs.sh | 3 ++- get-kernel/test-virt-get-kernel-docs.sh | 3 ++- inspector/test-virt-inspector-docs.sh | 3 ++- sparsify/test-virt-sparsify-docs.sh | 1 + sysprep/test-virt-sysprep-docs.sh | 1 + 10 files changed, 22 insertions(+), 11 deletions(-) diff --git a/cat/test-docs.sh b/cat/test-docs.sh index 30cc1eeb4..0d6d5461a 100755 --- a/cat/test-docs.sh +++ b/cat/test-docs.sh @@ -21,9 +21,14 @@ set -e $TEST_FUNCTIONS skip_if_skipped -$top_srcdir/podcheck.pl virt-cat.pod virt-cat -$top_srcdir/podcheck.pl virt-filesystems.pod virt-filesystems -$top_srcdir/podcheck.pl virt-log.pod virt-log +$top_srcdir/podcheck.pl virt-cat.pod virt-cat \ + --path $top_srcdir/common/options +$top_srcdir/podcheck.pl virt-filesystems.pod virt-filesystems \ + --path $top_srcdir/common/options +$top_srcdir/podcheck.pl virt-log.pod virt-log \ + --path $top_srcdir/common/options $top_srcdir/podcheck.pl virt-ls.pod virt-ls \ + --path $top_srcdir/common/options \ --ignore=--checksums,--extra-stat,--time,--uid -$top_srcdir/podcheck.pl virt-tail.pod virt-tail +$top_srcdir/podcheck.pl virt-tail.pod virt-tail \ + --path $top_srcdir/common/options diff --git a/customize/test-virt-customize-docs.sh b/customize/test-virt-customize-docs.sh index 99e67cb10..9a8da5180 100755 --- a/customize/test-virt-customize-docs.sh +++ b/customize/test-virt-customize-docs.sh @@ -21,6 +21,7 @@ set -e $TEST_FUNCTIONS $top_srcdir/podcheck.pl virt-customize.pod virt-customize \ + --path $top_srcdir/common/options \ --insert $top_srcdir/common/mlcustomize/customize-synopsis.pod:__CUSTOMIZE_SYNOPSIS__ \ --insert $top_srcdir/common/mlcustomize/customize-options.pod:__CUSTOMIZE_OPTIONS__ \ --ignore=--dryrun diff --git a/diff/test-virt-diff-docs.sh b/diff/test-virt-diff-docs.sh index cf6ce728e..d0d93cfd2 100755 --- a/diff/test-virt-diff-docs.sh +++ b/diff/test-virt-diff-docs.sh @@ -21,4 +21,5 @@ set -e $TEST_FUNCTIONS $top_srcdir/podcheck.pl virt-diff.pod virt-diff \ + --path $top_srcdir/common/options \ --ignore=--checksums,--dir-link,--dir-nlink,--dir-nlinks,--dir-time,--extra-stat,--time,--uid,--xattr diff --git a/edit/test-virt-edit-docs.sh b/edit/test-virt-edit-docs.sh index d824db9d4..7805d7e1d 100755 --- a/edit/test-virt-edit-docs.sh +++ b/edit/test-virt-edit-docs.sh @@ -20,4 +20,5 @@ set -e $TEST_FUNCTIONS -$top_srcdir/podcheck.pl virt-edit.pod virt-edit +$top_srcdir/podcheck.pl virt-edit.pod virt-edit \ + --path $top_srcdir/common/options diff --git a/fish/test-docs.sh b/fish/test-docs.sh index 6630da43e..7e9f9928e 100755 --- a/fish/test-docs.sh +++ b/fish/test-docs.sh @@ -22,7 +22,5 @@ $TEST_FUNCTIONS skip_if_skipped $top_srcdir/podcheck.pl guestfish.pod guestfish \ - --insert $srcdir/guestfish-actions.pod:__ACTIONS__ \ - --insert $srcdir/guestfish-commands.pod:__FISH_COMMANDS__ \ - --insert $srcdir/guestfish-prepopts.pod:__PREPOPTS__ \ + --path $srcdir --path $top_srcdir/common/options \ --ignore=-D diff --git a/fuse/test-docs.sh b/fuse/test-docs.sh index ba2c9c57a..0edc25658 100755 --- a/fuse/test-docs.sh +++ b/fuse/test-docs.sh @@ -21,7 +21,8 @@ set -e $TEST_FUNCTIONS skip_if_skipped -$top_srcdir/podcheck.pl guestmount.pod guestmount +$top_srcdir/podcheck.pl guestmount.pod guestmount \ + --path $top_srcdir/common/options # guestunmount doesn't implement bash completion, so we cannot # test it at the moment. XXX diff --git a/get-kernel/test-virt-get-kernel-docs.sh b/get-kernel/test-virt-get-kernel-docs.sh index 7c454777e..40bb7334d 100755 --- a/get-kernel/test-virt-get-kernel-docs.sh +++ b/get-kernel/test-virt-get-kernel-docs.sh @@ -21,4 +21,5 @@ set -e $TEST_FUNCTIONS skip_if_skipped -$top_srcdir/podcheck.pl virt-get-kernel.pod virt-get-kernel +$top_srcdir/podcheck.pl virt-get-kernel.pod virt-get-kernel \ + --path $top_srcdir/common/options diff --git a/inspector/test-virt-inspector-docs.sh b/inspector/test-virt-inspector-docs.sh index c9ad00b6b..11ee6518f 100755 --- a/inspector/test-virt-inspector-docs.sh +++ b/inspector/test-virt-inspector-docs.sh @@ -21,4 +21,5 @@ set -e $TEST_FUNCTIONS skip_if_skipped -$top_srcdir/podcheck.pl virt-inspector.pod virt-inspector +$top_srcdir/podcheck.pl virt-inspector.pod virt-inspector \ + --path $top_srcdir/common/options diff --git a/sparsify/test-virt-sparsify-docs.sh b/sparsify/test-virt-sparsify-docs.sh index 2afca3b12..6c2bd8f89 100755 --- a/sparsify/test-virt-sparsify-docs.sh +++ b/sparsify/test-virt-sparsify-docs.sh @@ -22,4 +22,5 @@ $TEST_FUNCTIONS skip_if_skipped $top_srcdir/podcheck.pl virt-sparsify.pod virt-sparsify \ + --path $top_srcdir/common/options \ --ignore=--inplace diff --git a/sysprep/test-virt-sysprep-docs.sh b/sysprep/test-virt-sysprep-docs.sh index e950410d7..b31e0f097 100755 --- a/sysprep/test-virt-sysprep-docs.sh +++ b/sysprep/test-virt-sysprep-docs.sh @@ -22,6 +22,7 @@ $TEST_FUNCTIONS skip_if_skipped $top_srcdir/podcheck.pl virt-sysprep.pod virt-sysprep \ + --path $top_srcdir/common/options \ --insert sysprep-extra-options.pod:__EXTRA_OPTIONS__ \ --insert sysprep-operations.pod:__OPERATIONS__ \ --ignore=--dryrun,--dump-pod,--dump-pod-options,--no-selinux-relabel -- 2.23.0
Richard W.M. Jones
2019-Dec-12 08:05 UTC
Re: [Libguestfs] [PATCH 2/2] tests: fix podcheck tests
On Wed, Dec 11, 2019 at 02:26:33PM +0100, Pino Toscano wrote:> Pass to the various podcheck invocations the paths with POD files that > are included. > > Followup of commit 46e59e9535c2fcd1c188464b5249a249f22af1a0. > --- > cat/test-docs.sh | 13 +++++++++---- > customize/test-virt-customize-docs.sh | 1 + > diff/test-virt-diff-docs.sh | 1 + > edit/test-virt-edit-docs.sh | 3 ++- > fish/test-docs.sh | 4 +--- > fuse/test-docs.sh | 3 ++- > get-kernel/test-virt-get-kernel-docs.sh | 3 ++- > inspector/test-virt-inspector-docs.sh | 3 ++- > sparsify/test-virt-sparsify-docs.sh | 1 + > sysprep/test-virt-sysprep-docs.sh | 1 + > 10 files changed, 22 insertions(+), 11 deletions(-) > > diff --git a/cat/test-docs.sh b/cat/test-docs.sh > index 30cc1eeb4..0d6d5461a 100755 > --- a/cat/test-docs.sh > +++ b/cat/test-docs.sh > @@ -21,9 +21,14 @@ set -e > $TEST_FUNCTIONS > skip_if_skipped > > -$top_srcdir/podcheck.pl virt-cat.pod virt-cat > -$top_srcdir/podcheck.pl virt-filesystems.pod virt-filesystems > -$top_srcdir/podcheck.pl virt-log.pod virt-log > +$top_srcdir/podcheck.pl virt-cat.pod virt-cat \ > + --path $top_srcdir/common/options > +$top_srcdir/podcheck.pl virt-filesystems.pod virt-filesystems \ > + --path $top_srcdir/common/options > +$top_srcdir/podcheck.pl virt-log.pod virt-log \ > + --path $top_srcdir/common/options > $top_srcdir/podcheck.pl virt-ls.pod virt-ls \ > + --path $top_srcdir/common/options \ > --ignore=--checksums,--extra-stat,--time,--uid > -$top_srcdir/podcheck.pl virt-tail.pod virt-tail > +$top_srcdir/podcheck.pl virt-tail.pod virt-tail \ > + --path $top_srcdir/common/options > diff --git a/customize/test-virt-customize-docs.sh b/customize/test-virt-customize-docs.sh > index 99e67cb10..9a8da5180 100755 > --- a/customize/test-virt-customize-docs.sh > +++ b/customize/test-virt-customize-docs.sh > @@ -21,6 +21,7 @@ set -e > $TEST_FUNCTIONS > > $top_srcdir/podcheck.pl virt-customize.pod virt-customize \ > + --path $top_srcdir/common/options \ > --insert $top_srcdir/common/mlcustomize/customize-synopsis.pod:__CUSTOMIZE_SYNOPSIS__ \ > --insert $top_srcdir/common/mlcustomize/customize-options.pod:__CUSTOMIZE_OPTIONS__ \ > --ignore=--dryrun > diff --git a/diff/test-virt-diff-docs.sh b/diff/test-virt-diff-docs.sh > index cf6ce728e..d0d93cfd2 100755 > --- a/diff/test-virt-diff-docs.sh > +++ b/diff/test-virt-diff-docs.sh > @@ -21,4 +21,5 @@ set -e > $TEST_FUNCTIONS > > $top_srcdir/podcheck.pl virt-diff.pod virt-diff \ > + --path $top_srcdir/common/options \ > --ignore=--checksums,--dir-link,--dir-nlink,--dir-nlinks,--dir-time,--extra-stat,--time,--uid,--xattr > diff --git a/edit/test-virt-edit-docs.sh b/edit/test-virt-edit-docs.sh > index d824db9d4..7805d7e1d 100755 > --- a/edit/test-virt-edit-docs.sh > +++ b/edit/test-virt-edit-docs.sh > @@ -20,4 +20,5 @@ set -e > > $TEST_FUNCTIONS > > -$top_srcdir/podcheck.pl virt-edit.pod virt-edit > +$top_srcdir/podcheck.pl virt-edit.pod virt-edit \ > + --path $top_srcdir/common/options > diff --git a/fish/test-docs.sh b/fish/test-docs.sh > index 6630da43e..7e9f9928e 100755 > --- a/fish/test-docs.sh > +++ b/fish/test-docs.sh > @@ -22,7 +22,5 @@ $TEST_FUNCTIONS > skip_if_skipped > > $top_srcdir/podcheck.pl guestfish.pod guestfish \ > - --insert $srcdir/guestfish-actions.pod:__ACTIONS__ \ > - --insert $srcdir/guestfish-commands.pod:__FISH_COMMANDS__ \ > - --insert $srcdir/guestfish-prepopts.pod:__PREPOPTS__ \ > + --path $srcdir --path $top_srcdir/common/options \ > --ignore=-D > diff --git a/fuse/test-docs.sh b/fuse/test-docs.sh > index ba2c9c57a..0edc25658 100755 > --- a/fuse/test-docs.sh > +++ b/fuse/test-docs.sh > @@ -21,7 +21,8 @@ set -e > $TEST_FUNCTIONS > skip_if_skipped > > -$top_srcdir/podcheck.pl guestmount.pod guestmount > +$top_srcdir/podcheck.pl guestmount.pod guestmount \ > + --path $top_srcdir/common/options > > # guestunmount doesn't implement bash completion, so we cannot > # test it at the moment. XXX > diff --git a/get-kernel/test-virt-get-kernel-docs.sh b/get-kernel/test-virt-get-kernel-docs.sh > index 7c454777e..40bb7334d 100755 > --- a/get-kernel/test-virt-get-kernel-docs.sh > +++ b/get-kernel/test-virt-get-kernel-docs.sh > @@ -21,4 +21,5 @@ set -e > $TEST_FUNCTIONS > skip_if_skipped > > -$top_srcdir/podcheck.pl virt-get-kernel.pod virt-get-kernel > +$top_srcdir/podcheck.pl virt-get-kernel.pod virt-get-kernel \ > + --path $top_srcdir/common/options > diff --git a/inspector/test-virt-inspector-docs.sh b/inspector/test-virt-inspector-docs.sh > index c9ad00b6b..11ee6518f 100755 > --- a/inspector/test-virt-inspector-docs.sh > +++ b/inspector/test-virt-inspector-docs.sh > @@ -21,4 +21,5 @@ set -e > $TEST_FUNCTIONS > skip_if_skipped > > -$top_srcdir/podcheck.pl virt-inspector.pod virt-inspector > +$top_srcdir/podcheck.pl virt-inspector.pod virt-inspector \ > + --path $top_srcdir/common/options > diff --git a/sparsify/test-virt-sparsify-docs.sh b/sparsify/test-virt-sparsify-docs.sh > index 2afca3b12..6c2bd8f89 100755 > --- a/sparsify/test-virt-sparsify-docs.sh > +++ b/sparsify/test-virt-sparsify-docs.sh > @@ -22,4 +22,5 @@ $TEST_FUNCTIONS > skip_if_skipped > > $top_srcdir/podcheck.pl virt-sparsify.pod virt-sparsify \ > + --path $top_srcdir/common/options \ > --ignore=--inplace > diff --git a/sysprep/test-virt-sysprep-docs.sh b/sysprep/test-virt-sysprep-docs.sh > index e950410d7..b31e0f097 100755 > --- a/sysprep/test-virt-sysprep-docs.sh > +++ b/sysprep/test-virt-sysprep-docs.sh > @@ -22,6 +22,7 @@ $TEST_FUNCTIONS > skip_if_skipped > > $top_srcdir/podcheck.pl virt-sysprep.pod virt-sysprep \ > + --path $top_srcdir/common/options \ > --insert sysprep-extra-options.pod:__EXTRA_OPTIONS__ \ > --insert sysprep-operations.pod:__OPERATIONS__ \ > --ignore=--dryrun,--dump-pod,--dump-pod-options,--no-selinux-relabel > -- > 2.23.0 >Sorry I missed this, thanks for fixing it. ACK series. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
Seemingly Similar Threads
- [PATCH 0/3] Various dist/build fixes
- [PATCH 0/3] tests: Define common test functions.
- Re: [PATCH libguestfs 1/3] podwrapper: __INCLUDE:file.pod__ and __VERBATIM:file.txt__ in POD files.
- [PATCH libguestfs 1/3] podwrapper: __INCLUDE:file.pod__ and __VERBATIM:file.txt__ in POD files.
- [PATCH v2 0/3] options: Describe --key SELECTOR in a single file.