From: Peter Rabbitson Date: Mon, 15 Feb 2016 11:40:34 +0000 (+0100) Subject: Stop loading Time::HiRes in the base test schema - there is no need X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5a8d5308a40f3958a17335fdc35afddce7d4ae31;p=dbsrgits%2FDBIx-Class-Historic.git Stop loading Time::HiRes in the base test schema - there is no need Switch all spots to a select()-based sleep instead --- diff --git a/lib/DBIx/Class/Schema/Versioned.pm b/lib/DBIx/Class/Schema/Versioned.pm index d59961f..2f130f6 100644 --- a/lib/DBIx/Class/Schema/Versioned.pm +++ b/lib/DBIx/Class/Schema/Versioned.pm @@ -203,7 +203,6 @@ use base 'DBIx::Class::Schema'; use DBIx::Class::Carp; use DBIx::Class::_Util 'dbic_internal_try'; -use Time::HiRes qw/gettimeofday/; use Scalar::Util 'weaken'; use namespace::clean; @@ -710,7 +709,8 @@ sub _set_db_version { # not possible to format the string sanely, as the column is a varchar(20). # The 'v' character is added to the front of the string, so that any version # formatted by this new function will sort _after_ any existing 200... strings. - my @tm = gettimeofday(); + require Time::HiRes; + my @tm = Time::HiRes::gettimeofday(); my @dt = gmtime ($tm[0]); my $o = $vtable->new_result({ version => $version, diff --git a/t/39load_namespaces_stress.t b/t/39load_namespaces_stress.t index b688669..ff64dbf 100644 --- a/t/39load_namespaces_stress.t +++ b/t/39load_namespaces_stress.t @@ -3,8 +3,6 @@ BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } use strict; use warnings; use Test::More; -use Time::HiRes qw/gettimeofday/; - use DBICTest; # do not remove even though it is not used @@ -41,10 +39,7 @@ EOM is (DBICTest::NS::Stress::Schema->sources, 0, 'Start with no sources'); - -note gettimeofday . ":\tload_namespaces start"; DBICTest::NS::Stress::Schema->load_namespaces; -note gettimeofday . ":\tload_namespaces finished"; is (DBICTest::NS::Stress::Schema->sources, $src_count, 'All sources attached'); diff --git a/t/lib/DBICTest/BaseSchema.pm b/t/lib/DBICTest/BaseSchema.pm index 328b950..ac3cf8c 100644 --- a/t/lib/DBICTest/BaseSchema.pm +++ b/t/lib/DBICTest/BaseSchema.pm @@ -6,7 +6,6 @@ use warnings; use base qw(DBICTest::Base DBIx::Class::Schema); use Fcntl qw(:DEFAULT :seek :flock); -use Time::HiRes 'sleep'; use DBIx::Class::_Util 'scope_guard'; use DBICTest::Util::LeakTracer qw(populate_weakregistry assert_empty_weakregistry); use DBICTest::Util qw( local_umask tmpdir await_flock dbg DEBUG_TEST_CONCURRENCY_LOCKS ); @@ -273,7 +272,7 @@ sub connection { for (1..50) { kill (0, $old_pid) or last; - sleep 0.1; + select( undef, undef, undef, 0.1 ); } DEBUG_TEST_CONCURRENCY_LOCKS diff --git a/xt/dist/loadable_standalone_testschema_resultclasses.t b/xt/dist/loadable_standalone_testschema_resultclasses.t index 27629a7..5416df8 100644 --- a/xt/dist/loadable_standalone_testschema_resultclasses.t +++ b/xt/dist/loadable_standalone_testschema_resultclasses.t @@ -11,7 +11,6 @@ use if DBIx::Class::_ENV_::BROKEN_FORK, 'threads'; use Test::More; use File::Find; -use Time::HiRes 'sleep'; my $worker = sub { my $fn = shift; @@ -35,7 +34,7 @@ find({ if (DBIx::Class::_ENV_::BROKEN_FORK) { # older perls crash if threads are spawned way too quickly, sleep for 100 msecs my $t = threads->create(sub { $worker->($_) }); - sleep 0.1; + select( undef, undef, undef, 0.1); is ($t->join, 42, "Thread loading $_ did not finish successfully") || diag ($t->can('error') ? $t->error : 'threads.pm too old to retrieve the error :(' ); }