| 1 | package Mason::t::StaticSource; | ||
| 2 | 1 | $Mason::t::StaticSource::VERSION = '2.24'; | |
| 3 | 1 | ▶ | use Test::Class::Most parent => 'Mason::Test::Class'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use Mason::Util qw(write_file touch_file); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 4 | ▶ | sub setup : Test(setup) { |
|
Subroutine
setup: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 7 | 4 | my ($self) = @_; | |
| 8 | |||
| 9 | 4 | $self->setup_dirs(); | |
| 10 | 4 | $self->add_comp( | |
| 11 | path => "/ss/remove_component.mc", | ||
| 12 | src => "I will be removed.\n", | ||
| 13 | ); | ||
| 14 | 4 | $self->add_comp( | |
| 15 | path => "/ss/change_component.mc", | ||
| 16 | src => "I will be changed.\n", | ||
| 17 | ); | ||
| 18 | 1 | ▶ | } |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 19 | |||
| 20 | 2 | ▶ | sub write_comp { |
|
Subroutine
write_comp: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 21 | 2 | my ( $self, $path, $contents ) = @_; | |
| 22 | 2 | my $source_file = $self->interp->load($path)->cmeta->source_file; | |
| 23 | 2 | write_file( $source_file, $contents ); | |
| 24 | } | ||
| 25 | |||
| 26 | 2 | ▶ | sub remove_comp { |
|
Subroutine
remove_comp: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 27 | 2 | my ( $self, $path ) = @_; | |
| 28 | 2 | my $source_file = $self->interp->load($path)->cmeta->source_file; | |
| 29 | 2 | unlink($source_file); | |
| 30 | } | ||
| 31 | |||
| 32 | 1 | ▶ | sub test_change_no_ss : Tests { |
|
Subroutine
test_change_no_ss: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 33 | 1 | my $self = shift; | |
| 34 | 1 | $self->test_comp( | |
| 35 | src => '<& /ss/change_component.mc &>', | ||
| 36 | expect => 'I will be changed.', | ||
| 37 | ); | ||
| 38 | 1 | sleep(1); # Make sure timestamp changes | |
| 39 | 1 | $self->write_comp( "/ss/change_component.mc", "I have changed!\n" ); | |
| 40 | 1 | $self->test_comp( | |
| 41 | src => '<& /ss/change_component.mc &>', | ||
| 42 | expect => 'I have changed!', | ||
| 43 | ); | ||
| 44 | 1 | ▶ | } |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 45 | |||
| 46 | 1 | ▶ | sub test_change_and_touch_ss : Tests { |
|
Subroutine
test_change_and_touch_ss: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 47 | 1 | my $self = shift; | |
| 48 | 1 | my $touch_file = $self->temp_dir . "/purge.dat"; | |
| 49 | 1 | $self->setup_interp( static_source => 1, static_source_touch_file => $touch_file ); | |
| 50 | 1 | $self->test_comp( | |
| 51 | src => '<& /ss/change_component.mc &>', | ||
| 52 | expect => 'I will be changed.', | ||
| 53 | ); | ||
| 54 | 1 | sleep(1); # Make sure timestamp changes | |
| 55 | 1 | $self->interp->load('/ss/change_component.mc'); | |
| 56 | 1 | $self->write_comp( "/ss/change_component.mc", "I have changed!\n" ); | |
| 57 | 1 | $self->test_comp( | |
| 58 | src => '<& /ss/change_component.mc &>', | ||
| 59 | expect => 'I will be changed.', | ||
| 60 | ); | ||
| 61 | 1 | touch_file($touch_file); | |
| 62 | 1 | $self->test_comp( | |
| 63 | src => '<& /ss/change_component.mc &>', | ||
| 64 | expect => 'I have changed!', | ||
| 65 | ); | ||
| 66 | 1 | ▶ | } |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 67 | |||
| 68 | 1 | ▶ | sub test_remove_no_ss : Tests { |
|
Subroutine
test_remove_no_ss: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 69 | 1 | my $self = shift; | |
| 70 | 1 | $self->test_comp( | |
| 71 | src => '<& /ss/remove_component.mc &>', | ||
| 72 | expect => 'I will be removed.', | ||
| 73 | ); | ||
| 74 | 1 | $self->remove_comp("/ss/remove_component.mc"); | |
| 75 | 1 | $self->test_comp( | |
| 76 | src => '<& /ss/remove_component.mc &>', | ||
| 77 | expect_error => qr/could not find component/ | ||
| 78 | ); | ||
| 79 | 1 | ▶ | } |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 80 | |||
| 81 | 1 | ▶ | sub test_remove_and_touch_ss : Tests { |
|
Subroutine
test_remove_and_touch_ss: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 82 | 1 | my $self = shift; | |
| 83 | 1 | my $touch_file = $self->temp_dir . "/purge.dat"; | |
| 84 | 1 | $self->setup_interp( static_source => 1, static_source_touch_file => $touch_file ); | |
| 85 | 1 | $self->test_comp( | |
| 86 | src => '<& /ss/remove_component.mc &>', | ||
| 87 | expect => 'I will be removed.', | ||
| 88 | ); | ||
| 89 | 1 | $self->remove_comp("/ss/remove_component.mc"); | |
| 90 | 1 | $self->test_comp( | |
| 91 | src => '<& /ss/remove_component.mc &>', | ||
| 92 | expect => 'I will be removed.', | ||
| 93 | ); | ||
| 94 | 1 | touch_file($touch_file); | |
| 95 | 1 | $self->test_comp( | |
| 96 | src => '<& /ss/remove_component.mc &>', | ||
| 97 | expect_error => qr/could not find component/ | ||
| 98 | ); | ||
| 99 | 1 | ▶ | } |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 100 | |||
| 101 | 1 | 1; | |