gozer 2004/09/10 18:02:28
Modified: t/modules reload.t
Log:
Instead of sleeping to wait for a touch() to be detected, adjust mtime
forward in the future.
Obtained from: stas
Revision Changes Path
1.4 +14 -8 modperl-2.0/t/modules/reload.t
Index: reload.t
===================================================================
RCS file: /home/cvs/modperl-2.0/t/modules/reload.t,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- reload.t 9 Sep 2004 18:29:09 -0000 1.3
+++ reload.t 11 Sep 2004 01:02:28 -0000 1.4
@@ -8,6 +8,9 @@
plan tests => 3;
+my $test_file = catfile Apache::Test::vars("serverroot"),
+ qw(lib Apache Reload Test.pm);
+
my $module = 'TestModules::reload';
my $location = '/' . Apache::TestRequest::module2path($module);
@@ -27,7 +30,7 @@
sub prototype($$) { 'PROTOTYPE' }
EOF
-t_write_file(test_file(), $header, $initial);
+t_write_file($test_file, $header, $initial);
t_debug "getting the same interp ID for $location";
my $same_interp = Apache::TestRequest::same_interp_tie($location);
@@ -46,8 +49,8 @@
);
}
-sleep(2);
-t_write_file(test_file(), $header, $modified);
+t_write_file($test_file, $header, $modified);
+touch_mtime($test_file);
{
my $expected = join '', map { "$_:" . uc($_) . "\n" } sort @tests;
@@ -73,11 +76,6 @@
);
}
-sub test_file {
- return catfile Apache::Test::vars("serverroot"),
- qw(lib Apache Reload Test.pm);
-}
-
# if we fail to find the same interpreter, return undef (this is not
# an error)
sub get_body {
@@ -107,6 +105,14 @@
ok &t_cmp;
EOE
}
+}
+
+sub touch_mtime {
+ my $file = shift;
+ # push the mtime into the future (at least 2 secs to work on win32)
+ # so Apache::Reload will reload the package
+ my $time = time + 5; # make it 5 to be sure
+ utime $time, $time, $file;
}
__DATA__