| 1 | # Licensed to the Apache Software Foundation (ASF) under one or more | ||
| 2 | # contributor license agreements. See the NOTICE file distributed with | ||
| 3 | # this work for additional information regarding copyright ownership. | ||
| 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| 5 | # (the "License"); you may not use this file except in compliance with | ||
| 6 | # the License. You may obtain a copy of the License at | ||
| 7 | # | ||
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | # | ||
| 10 | # Unless required by applicable law or agreed to in writing, software | ||
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | # See the License for the specific language governing permissions and | ||
| 14 | # limitations under the License. | ||
| 15 | # | ||
| 16 | package Apache::TestConfigParrot; | ||
| 17 | |||
| 18 | #things specific to mod_parrot | ||
| 19 | |||
| 20 | use strict; | ||
| 21 | use warnings FATAL => 'all'; | ||
| 22 | use File::Spec::Functions qw(catfile splitdir abs2rel); | ||
| 23 | use File::Find qw(finddepth); | ||
| 24 | use Apache::TestTrace; | ||
| 25 | use Apache::TestRequest; | ||
| 26 | use Apache::TestConfig; | ||
| 27 | use Apache::TestConfigPerl; | ||
| 28 | use Config; | ||
| 29 | |||
| 30 | @Apache::TestConfigParrot::ISA = qw(Apache::TestConfig); | ||
| 31 | |||
| 32 | sub new { | ||
| 33 | return shift->SUPER::new(@_); | ||
| 34 | } | ||
| 35 | |||
| 36 | sub configure_parrot_tests_pick { | ||
| 37 | my($self, $entries) = @_; | ||
| 38 | |||
| 39 | for my $subdir (qw(Response)) { | ||
| 40 | my $dir = catfile $self->{vars}->{t_dir}, lc $subdir; | ||
| 41 | next unless -d $dir; | ||
| 42 | |||
| 43 | finddepth(sub { | ||
| 44 | return unless /\.pir$/; | ||
| 45 | |||
| 46 | my $file = catfile $File::Find::dir, $_; | ||
| 47 | my $module = abs2rel $file, $dir; | ||
| 48 | my $status = $self->run_apache_test_config_scan($file); | ||
| 49 | push @$entries, [$file, $module, $subdir, $status]; | ||
| 50 | }, $dir); | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
| 54 | sub configure_parrot_tests { | ||
| 55 | my $self = shift; | ||
| 56 | |||
| 57 | my @entries = (); | ||
| 58 | $self->configure_parrot_tests_pick(\@entries); | ||
| 59 | $self->configure_pm_tests_sort(\@entries); | ||
| 60 | |||
| 61 | my %seen = (); | ||
| 62 | |||
| 63 | for my $entry (@entries) { | ||
| 64 | my ($file, $module, $subdir, $status) = @$entry; | ||
| 65 | |||
| 66 | my @args = (); | ||
| 67 | |||
| 68 | my $directives = $self->add_module_config($file, \@args); | ||
| 69 | |||
| 70 | $module =~ s,\.pir$,,; | ||
| 71 | $module =~ s/^[a-z]://i; #strip drive if any | ||
| 72 | $module = join '::', splitdir $module; | ||
| 73 | |||
| 74 | my @base = map { s/^test//i; $_ } split '::', $module; | ||
| 75 | |||
| 76 | my $sub = pop @base; | ||
| 77 | |||
| 78 | debug "configuring mod_parrot test file $file"; | ||
| 79 | |||
| 80 | push @args, SetHandler => 'parrot-code'; | ||
| 81 | push @args, ParrotHandler => $module; | ||
| 82 | |||
| 83 | $self->postamble(ParrotLoad => $file); | ||
| 84 | $self->postamble($self->location_container($module), \@args); | ||
| 85 | |||
| 86 | $self->write_pm_test($module, lc $sub, map { lc } @base); | ||
| 87 | } | ||
| 88 | } | ||
| 89 | |||
| 90 | 1; | ||
| 91 | |||
| 92 | __DATA__ |