Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Converted to CPAN::Meta::Check

  • Loading branch information...
commit 99ef18fc9cea19eee44a567a212afdc10f1456f4 1 parent 616f63b
@Leont authored
View
26 lib/Test/CheckDeps.pm
@@ -9,6 +9,7 @@ our %EXPORT_TAGS = (all => [ @EXPORT, @EXPORT_OK ] );
use CPAN::Meta;
use List::Util qw/first/;
+use CPAN::Meta::Check qw/check_requirements requirements_for/;
use Module::Metadata;
use Test::Builder;
@@ -18,26 +19,19 @@ sub check_dependencies {
my $metafile = first { -e $_ } qw/MYMETA.json MYMETA.yml META.json META.yml/ or return $builder->ok(0, "No META information provided\n");
my $meta = CPAN::Meta->load_file($metafile);
check_dependencies_opts($meta, $_, 'requires') for qw/configure build test runtime/;
+ check_dependencies_opts($meta, 'runtime', 'conflicts');
return;
}
sub check_dependencies_opts {
- my ($meta, $phase, $type) = @_;
-
- my $reqs = $meta->effective_prereqs->requirements_for($phase, $type);
- for my $module ($reqs->required_modules) {
- my $version;
- if ($module eq 'perl') {
- $version = $];
- }
- else {
- my $metadata = Module::Metadata->new_from_module($module);
- $builder->ok(0, "Module '$module' is not installed"), next if not defined $metadata;
- $version = eval { $metadata->version };
- }
- $builder->ok(0, "Missing version info for module '$module'"), next if not $version;
- $builder->ok(0, sprintf 'Version %s of module %s is not in range \'%s\'', $version, $module, $reqs->as_string_hash->{$module}), next if not $reqs->accepts_module($module, $version);
- $builder->ok(1, "$module $version is present");
+ my ($meta, $phases, $type) = @_;
+
+ my $reqs = requirements_for($meta, $phases, $type);
+ my $raw = $reqs->as_string_hash;
+ my $ret = check_requirements($reqs, $type);
+
+ for my $module (keys %{$ret}) {
+ $builder->ok(!defined $ret->{$module}, "$module satisfies '" . $raw->{$module} . "'") or $builder->diag($ret->{$module});
}
return;
}
View
0  t/00-basics.t → t/10-basics.t
File renamed without changes
Please sign in to comment.
Something went wrong with that request. Please try again.