Author: tim.bunce
Date: Sun Mar  8 11:34:31 2009
New Revision: 705

Modified:
    trunk/t/lib/NYTProfTest.pm

Log:
Add savesrc, compress, and abort (on first error) options to tests.
Set $ENV{NYTPROF} once per test group/.


Modified: trunk/t/lib/NYTProfTest.pm
==============================================================================
--- trunk/t/lib/NYTProfTest.pm  (original)
+++ trunk/t/lib/NYTProfTest.pm  Sun Mar  8 11:34:31 2009
@@ -25,7 +25,7 @@
      profperlopts => '-d:NYTProf',
      html         => $ENV{NYTPROF_TEST_HTML},
  );
-GetOptions(\%opts, qw/p=s I=s v|verbose d|debug html open profperlopts=s  
leave=i use_db_sub=i/)
+GetOptions(\%opts, qw/p=s I=s v|verbose d|debug html open profperlopts=s  
leave=i use_db_sub=i savesrc=i compress=i abort/)
      or exit 1;

  $opts{v}    ||= $opts{d};
@@ -76,7 +76,7 @@
                      start      => 'init',
                      leave      => $leave,
                      use_db_sub => $use_db_sub,
-                    #    savesrc    => $savesrc,
+                    savesrc    => $savesrc,
                      compress   => $compress,
                  }
              }
@@ -117,8 +117,14 @@
      ok($^O eq "MSWin32" ? -f $nytprofcsv : -x $nytprofcsv, "Found  
nytprofcsv as $nytprofcsv");

      for my $env (@env_combinations) {
+
+        my %env = (%$env, %NYTPROF_TEST);
+        local $ENV{NYTPROF} = join ":", map {"$_=$env{$_}"} sort keys %env;
+        my $context = "NYTPROF=$ENV{NYTPROF}\n";
+        ($opts{v}) ? warn $context : print $context;
+
          for my $test (@tests) {
-            run_test_with_env($test, $env);
+            run_test($test);
          }

          if ($test_code) {
@@ -134,12 +140,8 @@
      }
  }

-sub run_test_with_env {
-    my ($test, $env, $test_code) = @_;
-
-    my %env = (%$env, %NYTPROF_TEST);
-    local $ENV{NYTPROF} = join ":", map {"$_=$env{$_}"} sort keys %env;
-    warn "NYTPROF=$ENV{NYTPROF}\n" if $opts{v};
+sub run_test {
+    my ($test) = @_;

      #print $test . '.'x (20 - length $test);
      $test =~ / (.+?) \. (?:(\d)\.)? (\w+) $/x or do {
@@ -175,6 +177,13 @@
      }
      else {
          warn "Unrecognized extension '$type' on test file '$test'\n";
+    }
+
+    if ($opts{abort}) {
+        my $test_builder = Test::More->builder;
+        my @summary = $test_builder->summary;
+        BAIL_OUT("Aborting after test failure")
+            if grep { !$_ } @summary;
      }
  }


--~--~---------~--~----~------------~-------~--~----~
You've received this message because you are subscribed to
the Devel::NYTProf Development User group.

Group hosted at:  http://groups.google.com/group/develnytprof-dev
Project hosted at:  http://perl-devel-nytprof.googlecode.com
CPAN distribution:  http://search.cpan.org/dist/Devel-NYTProf

To post, email:  [email protected]
To unsubscribe, email:  [email protected]
-~----------~----~----~----~------~----~------~--~---

Reply via email to