Alien-Build

 view release on metacpan or  search on metacpan

t/alien_build.t  view on Meta::CPAN

            path     => "$path",
            tmp      => 0,
          };
        }
        else
        {
          die "oops";
        }

        note _dump($file);

        is
          dies { $build->check_digest($file) },
          match qr/^No digest for foo.txt.gz/,
          "dies when no digest specified";

        $build->meta_prop->{digest} = {
          'foo.txt.gz' => [ SHA256 => $good ],
        };

        delete $build->install_prop->{download_detail};

        is
          $build->check_digest($file),
          1,
          'good signature with filename';

        if(ref($file) eq 'HASH' && defined $file->{path})
        {
          is
            $build->install_prop,
            hash {
              field download_detail => hash {
                field $file->{path} => hash {
                  field digest => [ SHA256 => $good ];
                  etc;
                };
                etc;
              };
              etc;
            },
            '.install.download_detail.$download.digest is populated and matches';
        }

        $build->meta_prop->{digest} = {
          'foo.txt.gz' => [ SHA256 => $bad ],
        };

        is
          dies { $build->check_digest($file) },
          match qr/^foo.txt.gz SHA256 digest does not match: got $good, expected $bad/,
          'bad signature with filename';

        $build->meta_prop->{digest} = {
          '*' => [ SHA256 => $good ],
        };

        is
          $build->check_digest($file),
          1,
          'good signature with glob';

        $build->meta_prop->{digest} = {
          'foo.txt.gz' => [ FOO92 => $good ],
        };

        is
          dies { $build->check_digest($file) },
          match qr/^No plugin provides digest algorithm for FOO92/,
          'no algorithm';

        if($type eq 'string')
        {
          $file = $path->sibling('bogus.txt.gz')->stringify;
        }
        elsif($type eq 'path-tiny')
        {
          $file = $path->sibling('bogus.txt.gz');
        }
        elsif($type eq 'content')
        {

          $file = {
            type => 'file',
            filename => 'bogus.txt,gz',
          };

          note _dump($file);

          is
            dies { $build->check_digest($file) },
            match qr/^bogus.txt.gz has no content/,
            'error on missing file';

          $file = {
            type => 'file',
          };

          note _dump($file);

          is
            dies { $build->check_digest($file) },
            match qr/^File has no filename/,
            'error on missing filename';

          $file = {
            type => 'list',
          };

          note _dump($file);

          is
            dies { $build->check_digest($file) },
            match qr/^File is wrong type/,
            'error on wrote file type';

          $file = {
          };

          note _dump($file);



( run in 1.551 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )