Skip to content

Instantly share code, notes, and snippets.

@masaki
Created February 29, 2012 14:27
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 masaki/1941204 to your computer and use it in GitHub Desktop.
Save masaki/1941204 to your computer and use it in GitHub Desktop.
recent job detector
#!/usr/bin/env perl
use strict;
use warnings;
use String::CamelCase qw(decamelize);
use Getopt::Long;
use List::MoreUtils qw(uniq);
GetOptions('a|app=s', \my $app);
my @changes = @ARGV;
my @tests;
for my $changed (@changes) {
if ($changed =~ m!t/.+\.t$!) {
push @tests, $changed;
} elsif ($changed =~ m!(.+/)?lib/(.+)\.pm$!) {
my @comps = map { decamelize($_) } split m!/!, $2;
shift @comps if $comps[0] eq $app;
my $base = join '/', ($1 || '') . 't', @comps;
push @tests, glob("${base}.t"), glob("${base}/*.t");
}
}
print "$_\n" for uniq sort @tests;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment