#!/usr/bin/perl
# list tests that would be ran by nose but in a format
# that can be passed to nose itself, line by line (see
# http://stackoverflow.com/questions/21685260)

use strict;
use warnings;

my $list = `nosetests -vvv --collect-only 2>&1`;
my $db;


## parse
#
my $file = "UNKNOWN";
my $method = "UNKNOWN";
LINE: foreach (split "\n", $list) {
    if (m|wantFile (.*)\? True$|) {
        $file = $1;
        next LINE;
    } elsif (m|wantMethod (.*)\? True$|) {
        m|<unbound method (.*)>|;
        $method = $1;
        push @{$db->{$file}}, $method;
    }
}


## print out
#
foreach my $f (keys %$db) {
    printf "%s:%s\n", $f, $_ foreach @{$db->{$f}};
}