App-cpan2arch

 view release on metacpan or  search on metacpan

lib/App/cpan2arch/CheckPackages.pm  view on Meta::CPAN


# Get a list of core modules from specific Perl version.
method _get_corelist ($ver)
{
    $self->_psub;

    my $prog = $self->prog;

    # NOTE:
    #   Ideally, M::CoreList should always support the current perl pkg version,
    #   but its min required version would have to be kept updated, so just fallback
    #   to the current perl version if perl pkg version is not found in M::CoreList.
    #   This might lead to the generated PKGBUILD miss core modules (Arch users
    #   will have latest perl anyways).
    require Module::CoreList;

    my $perl_pkg_ver = do {
        try {
            version->parse($ver)->numify;
        }
        catch ($e) {

t/01-offline.t  view on Meta::CPAN


        my $DIST = 'Regexp-Debugger';

        my %FILES = (
            outfile  => 'PKGBUILD',
            metadata => '.SRCINFO',
        );

        my %TESTS_OUT = (
            '--update' => {
                normal_ver          => 'PKGBUILD + version updated',
                normal_ver_no_pkger => 'PKGBUILD updated + version updated + co-maintainer not preserved',
                normal_bump         => 'PKGBUILD updated + pkgrel bumped',
                normal_comp         => '.SRCINFO != generated metadata',
                normal_epoch        => 'PKGBUILD updated + preserve epoch',

                epoch_add    => 'PKGBUILD updated + add epoch',
                epoch_bump   => 'PKGBUILD updated + bump epoch',
                epoch_vercmp => 'no vercmp',

                no_files => 'no .SRCINFO or PKGBUILD',
                no_vars  => 'no pkgbase/pkgver/pkgrel in .SRCINFO',

                bogus_pkgbase => '.SRCINFO pkgbase != generated pkgbase',
                bogus_pkgver  => '.SRCINFO pkgver is newer than generated pkgver',
                bogus_pkgrel  => '.SRCINFO pkgrel != number',
            },
            '--write' => {

t/01-offline.t  view on Meta::CPAN

                        | sha256sums   | -                 | db096cf2e0e1e6127 | Only in Generated |
                        |              |                   | dacc40be6fbd526aa |                   |
                        |              |                   | 5ad41886a5bae00f4 |                   |
                        |              |                   | fe6a53a6c6ffb     |                   |
                        |              |                   |                   |                   |
                        | pkgdesc      | Bogus abstract    | Visually debug re | Differs           |
                        |              |                   | gexes in-place    |                   |
                        +--------------+-------------------+-------------------+-------------------+
                        END

                    # Expected updated PKGBUILD
                    my $updated_default;
                    {
                        $updated_default = $expected->{$DIST}{pkgbuild} =~ s{
                            \A
                            \#\ Maintainer:\ [^\n]+\n
                            \K
                        }
                        {$CONTRIBS}xr;
                    }

                    foreach my ( $t, $name ) ( $info->%* ) {
                        subtest "$t ($name)" => sub {
                            my $TODO;

t/01-offline.t  view on Meta::CPAN

                                    $TODO = todo 'This test fails when TTY width is not 80';

                                    test_diff(
                                        $stderr, $comparison,
                                        'STDERR',
                                    );
                                }

                                my $outfile = path( $FILES{outfile} )->slurp_utf8;

                                my $updated = $t eq 'normal_ver_no_pkger'
                                  ? (
                                      # Replace Maintainer with Contributor since co-maintainers
                                      # are not preserved when PACKAGER is not the current
                                      # PKGBUILD maintainer.
                                      $updated_default
                                      =~ s{^# Maintainer:(?= Alice <alice\@domain.tld>$)}{# Contributor:}mr
                                  )
                                  : $updated_default;

                                # Bump pkgrel
                                {
                                    my $pkgrel =
                                        $t eq 'normal_bump' || $t eq 'normal_epoch' ? 2
                                      : $t eq 'normal_comp'                         ? 3
                                      :                                               ();

                                    $updated =~ s{^pkgrel=\K[^\n]+$}{$pkgrel}m
                                      if $t  =~ /\Anormal_(?> bump | comp | epoch)\z/x;
                                }

                                # Add/bump epoch
                                {
                                    my $epoch =
                                        $t eq 'epoch_add' || $t eq 'normal_epoch' ? 1
                                      : $t eq 'epoch_bump'                        ? 2
                                      :                                             ();

                                    $updated =~ s{^pkgrel=[^\n]+\n\K}{epoch=$epoch\n}m
                                      if $t eq 'normal_epoch' || $t =~ /\Aepoch_/;
                                }

                                test_diff(
                                    $outfile, $updated,
                                    "$FILES{outfile} file",
                                );

                                is(
                                    $ret[0], number(0),
                                    'return value (success)',
                                );
                            }

                            chdir $cwd or die $!;  # tempdir cleanup



( run in 0.340 second using v1.01-cache-2.11-cpan-bbe5e583499 )