summaryrefslogtreecommitdiff
path: root/ngx_stream_lua-0.0.16/util/port-tests.pl
blob: 6142d88a79b300c65fc8ee6231a904c485ad6343 (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env perl

use strict;
use warnings;

my $ignore_value;
while (<>) {
    if (/use Test::Nginx::Socket::Lua([^:].*)/) {
        print "use Test::Nginx::Socket::Lua::Stream$1";
        next;
    }

    if ($ignore_value) {
        if (/^---/) {
            undef $ignore_value;
        } else {
            next;
        }
    }

    if (/^--- http_config\b(.*)/) {
        print "--- stream_config$1\n";
        next;
    }

    if (/^--- config\b(.*)/) {
        print "--- stream_server_config$1\n";
        next;
    }

    if (/^\s*location .*/) {
        next;
    }

    if (/^\s*(set|init|log|init_worker|content|rewrite|access)_by_lua (['"])(.*?)\2;/) {
        print "    ${1}_by_lua_block { $3 }\n";
        next;
    }

    if (/^\s*(set|init|log|init_worker|content|rewrite|access)_by_lua (['"])\s*$/) {
        print "    ${1}_by_lua_block {\n";
        next;
    }

    if (/^--- ignore_response$/) {
        print "--- stream_response\n";
        next;
    }

    if (/^--- error_code/) {
        next;
    }

    if (/^--- request[^:]*$/) {
        $ignore_value = 1;
        next;
    }

    if (/^\s*["'];$/) {
        next;
    }

    if (/^--- response_body\b(.*)/) {
        print "--- stream_response$1\n";
        next;
    }

    if (/^--- response_body_like\b(.*)/) {
        print "--- stream_response_like$1\n";
        next;
    }

    print;
}