comparison perl.t @ 118:4bf7a819358c

Tests: add some embedded perl tests.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 22 Dec 2009 01:59:01 +0300
parents
children 8ac1faaddd2c
comparison
equal deleted inserted replaced
117:f2b8d86438ee 118:4bf7a819358c
1 #!/usr/bin/perl
2
3 # (C) Maxim Dounin
4
5 # Tests for embedded perl module.
6
7 ###############################################################################
8
9 use warnings;
10 use strict;
11
12 use Test::More;
13
14 BEGIN { use FindBin; chdir($FindBin::Bin); }
15
16 use lib 'lib';
17 use Test::Nginx;
18
19 ###############################################################################
20
21 select STDERR; $| = 1;
22 select STDOUT; $| = 1;
23
24 my $t = Test::Nginx->new()->has('perl')->has('rewrite')->plan(1)
25 ->write_file_expand('nginx.conf', <<'EOF');
26
27 %%TEST_GLOBALS%%
28
29 master_process off;
30 daemon off;
31
32 events {
33 }
34
35 http {
36 %%TEST_GLOBALS_HTTP%%
37
38 server {
39 listen 127.0.0.1:8080;
40 server_name localhost;
41
42 location / {
43 set $testvar "TEST";
44 perl 'sub {
45 use warnings;
46 use strict;
47
48 my $r = shift;
49
50 $r->send_http_header("text/plain");
51
52 return OK if $r->header_only;
53
54 my $v = $r->variable("testvar");
55
56 $r->print("$v");
57
58 return OK;
59 }';
60 }
61 }
62 }
63
64 EOF
65
66 $t->run();
67
68 ###############################################################################
69
70 like(http_get('/'), qr/TEST/, 'perl response');
71
72 ###############################################################################