This file is indexed.

/usr/share/perl5/Test2/Require.pm is in libtest2-suite-perl 0.000102-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package Test2::Require;
use strict;
use warnings;

our $VERSION = '0.000102';

use Test2::API qw/context/;
use Carp qw/croak/;

sub skip {
    my $class = shift;
    croak "Class '$class' needs to implement 'skip()'";
}

sub import {
    my $class = shift;
    return if $class eq __PACKAGE__;

    my $skip = $class->skip(@_);
    return unless defined $skip;

    my $ctx = context();
    $ctx->plan(0, SKIP => $skip || "No reason given.");
    $ctx->release;
}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

Test2::Require - Base class and documentation for skip-unless type test
packages.

=head1 DESCRIPTION

Test2::Require::* packages are packages you load to ensure your test file is
skipped unless a specific requirement is met. Modules in this namespace may
subclass L<Test2::Require> if they wish, but it is not strictly necessary to do
so.

=head1 HOW DO I WRITE A 'REQUIRE' MODULE?

=head2 AS A SUBCLASS

    package Test2::Require::Widget;
    use strict;
    use warnings;

    use base 'Test2::Require';

    sub HAVE_WIDGETS { ... };

    sub skip {
        my $class = shift;
        my @import_args = @_;

        if (HAVE_WIDGETS()) {
            # We have widgets, do not skip
            return undef;
        }
        else {
            # No widgets, skip the test
            return "Skipped because there are no widgets" unless HAVE_WIDGETS();
        }
    }

    1;

A subclass of L<Test2::Require> simply needs to implement a C<skip()> method.
This method will receive all import arguments. This method should return undef
if the test should run, and should return a reason for skipping if the test
should be skipped.

=head2 STAND-ALONE

If you do not wish to subclass L<Test2::Require> then you should write an
C<import()> method:

    package Test2::Require::Widget;
    use strict;
    use warnings;

    use Test2::API qw/context/;

    sub HAVE_WIDGETS { ... };

    sub import {
        my $class = shift;

        # Have widgets, should run.
        return if HAVE_WIDGETS();

        # Use the context object to create the event
        my $ctx = context();
        $ctx->plan(0, SKIP => "Skipped because there are no widgets");
        $ctx->release;
    }

    1;

=head1 SOURCE

The source code repository for Test2-Suite can be found at
F<https://github.com/Test-More/Test2-Suite/>.

=head1 MAINTAINERS

=over 4

=item Chad Granum E<lt>exodist@cpan.orgE<gt>

=back

=head1 AUTHORS

=over 4

=item Chad Granum E<lt>exodist@cpan.orgE<gt>

=back

=head1 COPYRIGHT

Copyright 2017 Chad Granum E<lt>exodist@cpan.orgE<gt>.

This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

See F<http://dev.perl.org/licenses/>

=cut