Catalyst-Plugin-Assets

 view release on metacpan or  search on metacpan

inc/Module/Install.pm  view on Meta::CPAN





# If the script that is loading Module::Install is from the future,
# then make will detect this and cause it to re-run over and over
# again. This is bad. Rather than taking action to touch it (which
# is unreliable on some platforms and requires write permissions)
# for now we should catch this and refuse to run.
if ( -f $0 ) {
	my $s = (stat($0))[9];

	# If the modification time is only slightly in the future,
	# sleep briefly to remove the problem.
	my $a = $s - time;
	if ( $a > 0 and $a < 5 ) { sleep 5 }

	# Too far in the future, throw an error.
	my $t = time;
	if ( $s > $t ) { die <<"END_DIE" }

t/004-caching.t  view on Meta::CPAN

ok($response = request('http://localhost/fruit-salad'));
compare($response->content, qw(  
    http://localhost/assets.css
    http://localhost/assets.js
));

is(sanitize $scratch->read("root/assets.css"), "div.auto{font-weight:bold;color:green}div.apple{color:red}div.apple{color:blue}");
is($scratch->read("root/assets.js"), 'function calculate(){return 1*30/23;}
var auto=8+4;alert("Automatically "+auto);var apple=1+4;alert("Apple is "+apple);');

my $mtime = $scratch->stat("root/assets.css")->mtime;

sleep 2;

ok($response = request('http://localhost/fruit-salad'));
compare($response->content, qw(  
    http://localhost/assets.css
    http://localhost/assets.js
));

is(sanitize $scratch->read("root/assets.css"), "div.auto{font-weight:bold;color:green}div.apple{color:red}div.apple{color:blue}");
is($scratch->stat("root/assets.css")->mtime, $mtime);

$scratch->write("root/static/auto.css", <<_END_);
/* New auto content! */

div.auto 

{
    border: 1px solid #aaa;
    color: black;
}
_END_

ok($response = request('http://localhost/fruit-salad'));
compare($response->content, qw(  
    http://localhost/assets.css
    http://localhost/assets.js
));

is(sanitize $scratch->read("root/assets.css"), "div.auto{border:1px solid #aaa;color:black}div.apple{color:red}div.apple{color:blue}");
isnt($scratch->stat("root/assets.css")->mtime, $mtime);

1;



( run in 1.284 second using v1.01-cache-2.11-cpan-49f99fa48dc )