aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAndreas Guldstrand <andreas.guldstrand@gmail.com>2016-04-01 21:08:22 +0200
committerAndreas Guldstrand <andreas.guldstrand@gmail.com>2016-04-01 21:08:22 +0200
commit2a756f6f23bd7c646dc31f16652cadf159a1129d (patch)
tree559e5aa770fdfb69c012ed5d36a5074a7eeb4219 /tools
parent34d0b8fd067a4c118ae576df78edad830e7bdb2a (diff)
downloadsbotools-2a756f6f23bd7c646dc31f16652cadf159a1129d.tar.xz
Add tools/cover.pl helper script
Diffstat (limited to 'tools')
-rwxr-xr-xtools/cover.pl60
1 files changed, 60 insertions, 0 deletions
diff --git a/tools/cover.pl b/tools/cover.pl
new file mode 100755
index 0000000..379a17e
--- /dev/null
+++ b/tools/cover.pl
@@ -0,0 +1,60 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use feature 'say';
+
+use AWS::S3;
+use Path::Tiny;
+
+if (!@ARGV) {
+ die "Need to specify a build number to check coverage for.\n";
+}
+
+my $build = shift;
+my $base = qr!^[^/]+/sbotools/\Q$build\E/!;
+
+if (
+ ! length($ENV{S3_ID}) or
+ ! length($ENV{S3_KEY}) or
+ ! length($ENV{S3_BUCKET})) {
+ die "S3_ID and S3_KEY need to be defined in the environment.\n";
+}
+
+print "Connecting to S3...\n";
+
+my $s3 = AWS::S3->new(
+ access_key_id => $ENV{S3_ID},
+ secret_access_key => $ENV{S3_KEY},
+);
+
+my $bucket = $s3->bucket($ENV{S3_BUCKET});
+
+my $f_iter = $bucket->files(
+ page_size => 100,
+ page_number => 1,
+ pattern => qr!$base!,
+);
+
+my $num = 0;
+while (my @files = $f_iter->next_page) {
+ for my $file (@files) {
+ $num++;
+ print $file->key, "\n";
+
+ my $local_fname = $file->key =~ s!$base!cover_db/!r;
+ my $path = path($local_fname)->absolute();
+
+ $path->touchpath->spew_raw(${ $file->contents() });
+ }
+}
+
+if ($num == 0) {
+ die "No files found for build number $build.\n";
+}
+
+foreach my $build_dir (glob("cover_db/$build.*/")) {
+ system '/bin/bash', '-c', "cd $build_dir; tar xvf cover_db.tar";
+}
+
+system 'cover', '-write', "cover_db/$build", glob("cover_db/$build.*/cover_db/");