File: setupenv.t

package info (click to toggle)
libapache2-mod-perl2 2.0.9~1624218-2%2Bdeb8u2
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 11,912 kB
  • ctags: 4,588
  • sloc: perl: 95,064; ansic: 14,527; makefile: 49; sh: 18
file content (46 lines) | stat: -rw-r--r-- 1,221 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# please insert nothing before this line: -*- mode: cperl; cperl-indent-level: 4; cperl-continued-statement-offset: 4; indent-tabs-mode: nil -*-
use strict;
use warnings FATAL => 'all';

use Apache::Test;
use Apache::TestRequest;
use Apache::TestUtil;

plan tests => 3;

my $location = '/TestDirective__setupenv';

my $env = GET_BODY $location;

ok $env;

my %env;

for my $line (split /\n/, $env) {
    next unless $line =~ /=/;
    my ($key, $val) = split /=/, $line, 2;
    $env{$key} = $val || '';
}

ok t_cmp $env{REQUEST_URI}, $location, "testing REQUEST_URI";

{
    # on Win32, some user environment variables, like HOME, may be
    # passed through (via Apache?) if set, while system environment
    # variables are not. so try to find an existing shell variable
    # (that is not passed by Apache) and use it in the test to make
    # sure mod_perl doesn't see it

    my $var;
    for (qw(SHELL USER OS)) {
        $var = $_, last if exists $ENV{$_};
    }

    if (defined $var) {
        ok t_cmp $env{$var}, undef, "env var $var=$ENV{$var} is ".
            "set in shell, but shouldn't be seen inside mod_perl";
    }
    else {
        skip "couldn't find a suitable env var to test against", 0;
    }
}