Revision: 1213
Author: [email protected]
Date: Tue May  4 03:47:24 2010
Log: Factor out handling of $this_perl and usesitecustomize -f into new perl_command_words sub.

http://code.google.com/p/perl-devel-nytprof/source/detail?r=1213

Modified:
 /trunk/lib/Devel/NYTProf/Run.pm
 /trunk/t/lib/NYTProfTest.pm

=======================================
--- /trunk/lib/Devel/NYTProf/Run.pm     Mon May  3 14:44:45 2010
+++ /trunk/lib/Devel/NYTProf/Run.pm     Tue May  4 03:47:24 2010
@@ -35,6 +35,7 @@

 our @EXPORT_OK = qw(
     profile_this
+    perl_command_words
 );


@@ -42,6 +43,22 @@
$this_perl .= $Config{_exe} if $^O ne 'VMS' and $this_perl !~ m/$Config{_exe}$/i;


+sub perl_command_words {
+    my %opt = @_;
+
+    my @perl = ($this_perl);
+
+    # testing just $Config{usesitecustomize} isn't reliable for perl 5.11.x
+    if (($Config{usesitecustomize}||'') eq 'define'
+    or   $Config{ccflags} =~ /(?<!\w)-DUSE_SITECUSTOMIZE\b/
+    ) {
+        push @perl, '-f' if $opt{skip_sitecustomize};
+    }
+
+    return @perl;
+}
+
+
 # croaks on failure to execute
 # carps, not croak, if process has non-zero exit status
 # Devel::NYTProf::Data->new may croak, e.g., if data trucated
@@ -50,12 +67,7 @@

     my $out_file = $opt{out_file} || 'nytprof.out';

-    my @perl = ($this_perl, '-d:NYTProf');
-
-    # (sadly, testing $Config{usesitecustomize} isn't reliable)
- if ($Config{usesitecustomize} eq 'define' or $Config{ccflags} =~ /(?<!\w)-DUSE_SITECUSTOMIZE\b/) {
-        push @perl, '-f' if $opt{skip_sitecustomize};
-    }
+    my @perl = (perl_command_words(%opt), '-d:NYTProf');

     warn sprintf "profile_this() using %s with NYTPROF=%s\n",
             join(" ", @perl), $ENV{NYTPROF} || ''
=======================================
--- /trunk/t/lib/NYTProfTest.pm Mon May  3 14:44:45 2010
+++ /trunk/t/lib/NYTProfTest.pm Tue May  4 03:47:24 2010
@@ -21,6 +21,7 @@
 use Devel::NYTProf::Data;
 use Devel::NYTProf::Reader;
 use Devel::NYTProf::Util qw(strip_prefix_from_paths html_safe_filename);
+use Devel::NYTProf::Run qw(perl_command_words);


 my $this_perl = $^X;
@@ -352,10 +353,8 @@
 sub run_perl_command {
     my ($cmd, $show_stdout) = @_;
     local $ENV{PERL5LIB} = $perl5lib;
-    my @opts;
-    push @opts, '-f' if $Config{usesitecustomize} eq 'define'
-                     or $Config{ccflags} =~ /(?<!\w)-DUSE_SITECUSTOMIZE\b/;
-    run_command("$this_perl @opts $cmd", $show_stdout);
+    my @perl = perl_command_words(skip_sitecustomize => 1);
+    run_command("@perl $cmd", $show_stdout);
 }


--
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