#!/usr/bin/perl

use strict;
use warnings;

my $reg_test = qr/^\s*\{\s*(TEST_[a-z0-9_]*)\s*,.*\"(.*:[0-9]+)\"/i;

sub scanModule($) {
  my ($module) = @_;
  open(IN, '<'.$module) || die "cannot read '$module' (Reason: $!)";
  my $line;
  while (defined ($line=<IN>)) {
    if ($line =~ $reg_test) {
      my ($tname,$tloc) = ($1,$2);
      print "$tloc: Found test $tname in untested unit\n";
    }
  }
  close(IN);
}

sub main() {
  my $args = scalar(@ARGV);
  if ($args==1) {
    scanModule($ARGV[0]);
  }
  else {
    print "Usage: dumpTestLocations.pl testmodule.cxx\n";
    print "dumps locations of tests contained in testmodule.cxx as messages to STDOUT\n";
  }
}
main();
