Changeset 2142

Show
Ignore:
Timestamp:
04/29/08 21:36:05 (7 months ago)
Author:
mpaschal
Message:

Avoid real clock-time waits during the test by mocking 'time' and 'sleep'
Remove a sleep() we didn't even need

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/release-36/t/driver-tests.pl

    r2141 r2142  
    2323    $driver =~ s/\.t$//; 
    2424    $ENV{MT_CONFIG} = "$driver-test.cfg"; 
     25} 
     26 
     27BEGIN { 
     28    *CORE::GLOBAL::time  = sub { CORE::time }; 
     29    *CORE::GLOBAL::sleep = sub { CORE::sleep }; 
    2530} 
    2631 
     
    4449package main; 
    4550 
     51my $core_time = time; 
     52{ 
     53    no warnings 'redefine'; 
     54    *CORE::GLOBAL::time  = sub { $core_time }; 
     55    *CORE::GLOBAL::sleep = sub { $core_time += shift }; 
     56} 
     57 
    4658if (-r $ENV{MT_CONFIG}) { 
    4759    plan tests => TESTS(); 
     
    98110is_first_foo(scalar Foo->load({ created_on => $foo[0]->created_on }), 'Foo #1 by created_on hash'); 
    99111is_first_foo(scalar Foo->load({ status => $foo[0]->status }), 'Foo #1 by status hash'); 
    100  
    101 ## Sleep first so that they get different created_on timestamps. 
    102 # TODO: can we replace CORE::time to fake this? 
    103 sleep(2); 
    104112 
    105113##     Change column value, save, try to load using old value (fail?),