Mercurial > hg > nginx-tests
annotate xslt.t @ 1263:ea3c7659b6c1
Tests: handled early pidfile write on win32 in the run() routine.
In addition to the present waiting for pidfile, which is insufficient on win32
due to the CreateProcess model, and may lead to rare startup races, search now
for the certain error message which indicates started worker process.
This change allows tolerating moderate hiccups on win32 hosts.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 19 Dec 2017 19:55:01 +0300 |
parents | 882267679006 |
children | 829467f8d696 |
rev | line source |
---|---|
208 | 1 #!/usr/bin/perl |
2 | |
3 # (C) Maxim Dounin | |
4 | |
5 # Tests for nginx xslt filter 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(qw/http xslt/)->plan(5); | |
25 | |
26 $t->write_file_expand('nginx.conf', <<'EOF'); | |
27 | |
28 %%TEST_GLOBALS%% | |
29 | |
249
6a0d934950bc
Tests: remove extra spaces in "daemon off".
Maxim Dounin <mdounin@mdounin.ru>
parents:
224
diff
changeset
|
30 daemon off; |
208 | 31 |
32 events { | |
33 } | |
34 | |
35 http { | |
36 %%TEST_GLOBALS_HTTP%% | |
37 | |
38 server { | |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
39 listen 127.0.0.1:8080; |
208 | 40 server_name localhost; |
41 | |
42 default_type text/xml; | |
43 | |
44 location /x1 { | |
45 xslt_stylesheet %%TESTDIR%%/test.xslt; | |
46 } | |
47 location /x2 { | |
48 xslt_stylesheet %%TESTDIR%%/test.xslt | |
211
ee8fee3c4ae8
Tests: fix xslt tests for CentOS 5.
Maxim Dounin <mdounin@mdounin.ru>
parents:
208
diff
changeset
|
49 param1='value1':param2=/root param3='value%33'; |
208 | 50 } |
51 location /x3 { | |
52 xml_entities %%TESTDIR%%/entities.dtd; | |
53 xslt_stylesheet %%TESTDIR%%/test.xslt; | |
54 } | |
55 location /x4 { | |
56 xslt_stylesheet %%TESTDIR%%/first.xslt; | |
57 xslt_stylesheet %%TESTDIR%%/test.xslt; | |
58 } | |
59 } | |
60 } | |
61 | |
62 EOF | |
63 | |
64 $t->write_file('test.xslt', <<'EOF'); | |
65 | |
66 <xsl:stylesheet version="1.0" | |
67 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
68 | |
69 <xsl:output method="html"/> | |
70 | |
71 <xsl:param name="param1"/> | |
72 <xsl:param name="param2"/> | |
73 <xsl:param name="param3"/> | |
74 | |
75 <xsl:template match="/"> | |
76 test xslt result | |
77 param1=<xsl:value-of select="$param1"/> | |
78 param2=<xsl:value-of select="$param2"/> | |
79 param3=<xsl:value-of select="$param3"/> | |
211
ee8fee3c4ae8
Tests: fix xslt tests for CentOS 5.
Maxim Dounin <mdounin@mdounin.ru>
parents:
208
diff
changeset
|
80 data=<xsl:value-of select="/root"/> |
208 | 81 </xsl:template> |
82 | |
83 </xsl:stylesheet> | |
84 | |
85 EOF | |
86 | |
87 $t->write_file('first.xslt', <<'EOF'); | |
88 | |
89 <xsl:stylesheet version="1.0" | |
90 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
91 | |
92 <xsl:template match="/"> | |
211
ee8fee3c4ae8
Tests: fix xslt tests for CentOS 5.
Maxim Dounin <mdounin@mdounin.ru>
parents:
208
diff
changeset
|
93 <root>other <xsl:value-of select="/root"/></root> |
208 | 94 </xsl:template> |
95 | |
96 </xsl:stylesheet> | |
97 | |
98 EOF | |
99 | |
100 $t->write_file('entities.dtd', '<!ENTITY test "test entity">' . "\n"); | |
101 $t->write_file('x1', '<empty/>'); | |
102 $t->write_file('x2', '<root>data</root>'); | |
103 $t->write_file('x3', '<!DOCTYPE root><root>&test;</root>'); | |
104 $t->write_file('x4', '<root>data</root>'); | |
105 | |
106 $t->run(); | |
107 | |
108 ############################################################################### | |
109 | |
110 like(http_get("/x1"), qr!200 OK.*test xslt result!ms, 'simple'); | |
111 like(http_get("/x1"), qr!200 OK.*Content-Type: text/html!ms, 'content type'); | |
112 like(http_get("/x2"), qr!200 OK.*param1=value1.*param2=data.*param3=value3!ms, | |
113 'params'); | |
114 like(http_get("/x3"), qr!200 OK.*data=test entity!ms, 'entities'); | |
115 like(http_get("/x4"), qr!200 OK.*data=other data!ms, 'several stylesheets'); | |
116 | |
117 ############################################################################### |