Skip to content

Instantly share code, notes, and snippets.

@Mouq
Last active December 20, 2015 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mouq/6141500 to your computer and use it in GitHub Desktop.
Save Mouq/6141500 to your computer and use it in GitHub Desktop.
$ mkdir mod_test && cd mod_test
$ mkdir lib
$ curl http://modules.perl6.org/proto.json > proto.json
$ export PERL6LIB=$PWD/lib:PERL6LIB
$ export PREFIX=$PWD/lib
$ perl test.pl
#!/usr/bin/env perl
use v5.12;
use JSON;
use Data::Dumper;
open my $proto, "<", "proto.json";
my %modules = %{decode_json(join "", <$proto>)};
close $proto;
# Get
for (keys %modules) {
say "Getting $modules{$_}{name} from $modules{$_}{url}:";
say `git clone $modules{$_}{url} &`;
}
# Install + Test
my %installed;
my %tested;
for (keys %modules) {
install($_) unless $installed{$_} # has to be recusive b/c of dependencies
}
sub install {
my $m = shift;
say "Trying to install and test $m:";
chdir $modules{$m}{repo_name}
or (warn "Couldn't enter dir $modules{$m}{repo_name}" and return);
if (-e "META.info"){
open my $meta, "<", "META.info";
my $dep = (decode_json(join "", <$meta>))->{'depends'};
close $meta;
if (defined $dep && scalar @$dep) {
say "Dependencies found: @$dep";
chdir "..";
install($_) for @$dep;
chdir $modules{$m}{repo_name};
}
}
else {
warn "No META.info file found for $m";
}
my $output = '';
say $output = `ufo && make -e test install purge`;
$installed{$m}++;
say "$m probably passed its tests" if $tested{$m} = $output =~ /\nResult: PASS\n/;
chdir "..";
}
say scalar %tested, " passed their tests. Or faked it.";
say Dumper \%tested;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment