This is an automated email from the git hooks/post-receive script.

abe pushed a commit to annotated tag 1.001002-source
in repository libdist-zilla-role-bootstrap-perl.

commit 66d4baf27ecd9538da46f0459cbbb5f9ae51d9ed
Author: Kent Fredric <kentfred...@gmail.com>
Date:   Wed Jul 1 15:44:14 2015 +1200

    Bodge around broken mtime implementations by skipping tests when found
---
 Changes                |  4 ++++
 t/02-try-built-mtime.t | 58 +++++++++++++++++++++++++++++++++++++++-----------
 2 files changed, 49 insertions(+), 13 deletions(-)

diff --git a/Changes b/Changes
index 56c6696..f7fe79b 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,10 @@
 Release history for Dist-Zilla-Role-Bootstrap
 
 {{$NEXT}}
+ [Bugfix]
+ - Bodge around testers with broken mtime implementations by agressively 
trying to make files with seperate mtimes and
+   then skipping all the tests if that isnt possible, with a grace window of 
up to 5 seconds to get it right.
+
  [Dependencies::Stats]
  - Dependencies changed since 1.001001, see misc/*.deps* for details
  - develop: +2 (suggests: ↑1)
diff --git a/t/02-try-built-mtime.t b/t/02-try-built-mtime.t
index 024c838..7b242be 100644
--- a/t/02-try-built-mtime.t
+++ b/t/02-try-built-mtime.t
@@ -42,12 +42,41 @@ use File::Copy::Recursive qw(rcopy);
 
 rcopy "$source", "$scratch";
 
-$scratch->child("Example-0.01")->child('lib')->mkpath;
-sleep 2;
-$scratch->child("Example-0.10")->child('lib')->mkpath;
-sleep 2;
-$scratch->child("Example-0.05")->child('lib')->mkpath;
+my (@scratches) = map { $scratch->child( 'Example-' . $_ ) } qw( 0.01 0.10 
0.05 );
 
+for my $scratch_id ( 0 .. $#scratches ) {
+  my $scratch = $scratches[$scratch_id];
+  if ( $scratch_id == 0 ) {
+    $scratch->child('lib')->mkpath;
+    next;
+  }
+  my $tries      = 0;
+  my $sleep_step = 0.3;    # Start intentionally slow to hopefully hit a 
subsecond transition.
+  my $elapsed    = 0.0;
+
+  while ( not -e $scratch or $scratch->stat->mtime <= $scratches[ $scratch_id 
- 1 ]->stat->mtime ) {
+    $tries++;
+    if ( $elapsed > 5 ) {
+      diag "Your system has a broken clock/filesystem and mtime based tests 
cant work";
+    SKIP: {
+        skip "Broken MTime", 8;
+      }
+      done_testing;
+      exit 0;
+    }
+    if ( $elapsed > 2 ) {
+      diag "mtime looks a bit wonky :/, this test will seem slow";
+    }
+
+    select( undef, undef, undef, $sleep_step );
+    $elapsed += $sleep_step;
+    note "Attempt " . ($tries) . " at creating " . $scratch . " @" . (gmtime) 
. "( elapsed: $elapsed )";
+    $scratch->remove_tree() if -e $scratch;
+    $scratch->child('lib')->mkpath;
+    $sleep_step = $sleep_step * 2;    # Exponentially larger steps to find 
clock slew as fast as possible
+  }
+  note "Succcess @" . (gmtime) . "( elapsed: $elapsed )";
+}
 chdir $scratch->stringify;
 
 $section->current_section->payload->{chrome} = $chrome;
@@ -81,14 +110,17 @@ is_deeply(
   'dump_config is expected'
 );
 
-is( $instance->distname,         'Example',          'distname is Example' );
-is( $instance->_cwd->realpath,   $scratch->realpath, 'cwd is project root/' );
-is( $instance->try_built,        1,                  'try_built is on' );
-is( $instance->try_built_method, 'mtime',            'try_built_method is 
mtime' );
-is( $instance->fallback,         1,                  'fallback is on' );
-is( $instance->_bootstrap_root->realpath, 
$scratch->child('Example-0.05')->realpath, '_bootstrap_root == _cwd' ) or diag 
explain [
-  map { { $_->stringify => $_->stat->mtime } } map { 
$scratch->child("Example-$_") } qw( 0.01 0.10 0.05 )
-];
+is( $instance->distname,                  'Example',                           
      'distname is Example' );
+is( $instance->_cwd->realpath,            $scratch->realpath,                  
      'cwd is project root/' );
+is( $instance->try_built,                 1,                                   
      'try_built is on' );
+is( $instance->try_built_method,          'mtime',                             
      'try_built_method is mtime' );
+is( $instance->fallback,                  1,                                   
      'fallback is on' );
+is( $instance->_bootstrap_root->realpath, 
$scratch->child('Example-0.05')->realpath, '_bootstrap_root == _cwd' )
+  or diag explain [
+  map {
+    { $_->stringify => $_->stat->mtime }
+  } @scratches
+  ];
 ok( $instance->can('_add_inc'), '_add_inc method exists' );
 
 chdir $cwd->stringify;

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-perl/packages/libdist-zilla-role-bootstrap-perl.git

_______________________________________________
Pkg-perl-cvs-commits mailing list
Pkg-perl-cvs-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits

Reply via email to