Mercurial > hg > nginx-tests
comparison debug_connection.t @ 467:43e05ac6c23c
Tests: the read_file function added in Test::Nginx.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 22 Sep 2014 13:30:04 +0400 |
parents | 847ea345becb |
children | 089c4174e269 |
comparison
equal
deleted
inserted
replaced
466:a64b4057189c | 467:43e05ac6c23c |
---|---|
54 | 54 |
55 $t->try_run('no inet6 support')->plan(5); | 55 $t->try_run('no inet6 support')->plan(5); |
56 | 56 |
57 ############################################################################### | 57 ############################################################################### |
58 | 58 |
59 my $d = $t->testdir(); | |
60 | |
61 http_get('/'); | 59 http_get('/'); |
62 is(read_file("$d/debug1.log"), '', 'no debug_connection file 1'); | 60 is($t->read_file('debug1.log'), '', 'no debug_connection file 1'); |
63 is(read_file("$d/debug2.log"), '', 'no debug_connection file 1'); | 61 is($t->read_file('debug2.log'), '', 'no debug_connection file 1'); |
64 | 62 |
65 http_get('/debug'); | 63 http_get('/debug'); |
66 like(read_file("$d/debug1.log"), qr/\[debug\]/, 'debug_connection file 1'); | 64 like($t->read_file('debug1.log'), qr/\[debug\]/, 'debug_connection file 1'); |
67 like(read_file("$d/debug2.log"), qr/\[debug\]/, 'debug_connection file 2'); | 65 like($t->read_file('debug2.log'), qr/\[debug\]/, 'debug_connection file 2'); |
68 is(read_file("$d/debug1.log"), read_file("$d/debug2.log"), | 66 is($t->read_file('debug1.log'), $t->read_file('debug2.log'), |
69 'debug_connection file1 file2 match'); | 67 'debug_connection file1 file2 match'); |
70 | 68 |
71 ############################################################################### | 69 ############################################################################### |
72 | |
73 sub read_file { | |
74 my ($file) = shift; | |
75 open my $fh, '<', $file or return "$!"; | |
76 local $/; | |
77 my $content = <$fh>; | |
78 close $fh; | |
79 return $content; | |
80 } | |
81 | |
82 ############################################################################### |