From: Karen Etheridge Date: Thu, 12 Jul 2012 23:04:37 +0000 (-0700) Subject: memoized the VCS check into a global variable X-Git-Tag: v1.004001~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=12b8f19b42aca2e4872678b720287e45e0ee2083;p=p5sagit%2Fstrictures.git memoized the VCS check into a global variable --- diff --git a/lib/strictures.pm b/lib/strictures.pm index 0628e31..0604746 100644 --- a/lib/strictures.pm +++ b/lib/strictures.pm @@ -23,6 +23,8 @@ sub VERSION { my $extras_load_warned; +our $Smells_Like_VCS = -e '.git' || -e '.svn'; + sub import { strict->import; warnings->import(FATAL => 'all'); @@ -36,7 +38,7 @@ sub import { $ENV{PERL_STRICTURES_EXTRA}; } elsif (! _PERL_LT_5_8_4) { !!((caller)[1] =~ /^(?:t|xt|lib|blib)/ - and (-e '.git' or -e '.svn')) + and $Smells_Like_VCS) } }; if ($extra_tests) { diff --git a/t/strictures.t b/t/strictures.t index eb110cf..aecf332 100644 --- a/t/strictures.t +++ b/t/strictures.t @@ -46,6 +46,7 @@ SKIP: { }; sub Foo::new { 1 } chdir("t/smells-of-vcs"); + local $strictures::Smells_Like_VCS = 1; foreach my $file (qw(lib/one.pm t/one.t)) { ok(!eval { require $file; 1 }, "Failed to load ${file}"); like($@, qr{Indirect call of method}, "Failed due to indirect.pm, ok");