📄 apache::testutil.3
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...de Sp \" Vertical space (when we can't use .PP).if t .sp .5v.if n .sp...de Vb \" Begin verbatim text.ft CW.nf.ne \\$1...de Ve \" End verbatim text.ft R.fi...\" Set up some character translations and predefined strings. \*(-- will.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left.\" double quote, and \*(R" will give a right double quote. \*(C+ will.\" give a nicer C++. Capital omega is used to do unbreakable dashes and.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,.\" nothing in troff, for use with C<>..tr \(*W-.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'.ie n \{\. ds -- \(*W-. ds PI pi. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch. ds L" "". ds R" "". ds C` "". ds C' ""'br\}.el\{\. ds -- \|\(em\|. ds PI \(*p. ds L" ``. ds R" '''br\}.\".\" Escape single quotes in literal strings from groff's Unicode transform..ie \n(.g .ds Aq \(aq.el .ds Aq '.\".\" If the F register is turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD. Of course, you'll have to process the.\" output yourself in some meaningful fashion..ie \nF \{\. de IX. tm Index:\\$1\t\\n%\t"\\$2"... nr % 0. rr F.\}.el \{\. de IX...\}.\".\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2)..\" Fear. Run. Save yourself. No user-serviceable parts.. \" fudge factors for nroff and troff.if n \{\. ds #H 0. ds #V .8m. ds #F .3m. ds #[ \f1. ds #] \fP.\}.if t \{\. ds #H ((1u-(\\\\n(.fu%2u))*.13m). ds #V .6m. ds #F 0. ds #[ \&. ds #] \&.\}. \" simple accents for nroff and troff.if n \{\. ds ' \&. ds ` \&. ds ^ \&. ds , \&. ds ~ ~. ds /.\}.if t \{\. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u". ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'.\}. \" troff and (daisy-wheel) nroff accents.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'.ds 8 \h'\*(#H'\(*b\h'-\*(#H'.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#].ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#].ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#].ds ae a\h'-(\w'a'u*4/10)'e.ds Ae A\h'-(\w'A'u*4/10)'E. \" corrections for vroff.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'. \" for low resolution devices (crt and lpr).if \n(.H>23 .if \n(.V>19 \\{\. ds : e. ds 8 ss. ds o a. ds d- d\h'-1'\(ga. ds D- D\h'-1'\(hy. ds th \o'bp'. ds Th \o'LP'. ds ae ae. ds Ae AE.\}.rm #[ #] #H #V #F C.\" ========================================================================.\".IX Title "Apache::TestUtil 3".TH Apache::TestUtil 3 "2005-10-21" "perl v5.10.0" "User Contributed Perl Documentation".\" For nroff, turn off justification. Always turn off hyphenation; it makes.\" way too many mistakes in technical documents..if n .ad l.nh.SH "NAME"Apache::TestUtil \- Utility functions for writing tests.SH "SYNOPSIS".IX Header "SYNOPSIS".Vb 2\& use Apache::Test;\& use Apache::TestUtil;\&\& ok t_cmp("foo", "foo", "sanity check");\& t_write_file("filename", @content);\& my $fh = t_open_file($filename);\& t_mkdir("/foo/bar");\& t_rmtree("/foo/bar");\& t_is_equal($a, $b);.Ve.SH "DESCRIPTION".IX Header "DESCRIPTION"\&\f(CW\*(C`Apache::TestUtil\*(C'\fR automatically exports a number of functions usefulin writing tests..PPAll the files and directories created using the functions from thispackage will be automatically destroyed at the end of the programexecution (via \s-1END\s0 block). You should not use these functions otherthan from within tests which should cleanup all the createddirectories and files at the end of the test..SH "FUNCTIONS".IX Header "FUNCTIONS".IP "\fIt_cmp()\fR" 4.IX Item "t_cmp()".Vb 1\& t_cmp($received, $expected, $comment);.Ve.Sp\&\fIt_cmp()\fR prints the values of \fI\f(CI$comment\fI\fR, \fI\f(CI$expected\fI\fR and\&\fI\f(CI$received\fI\fR. e.g.:.Sp.Vb 1\& t_cmp(1, 1, "1 == 1?");.Ve.Spprints:.Sp.Vb 3\& # testing : 1 == 1?\& # expected: 1\& # received: 1.Ve.Spthen it returns the result of comparison of the \fI\f(CI$expected\fI\fR and the\&\fI\f(CI$received\fI\fR variables. Usually, the return value of this function isfed directly to the \fIok()\fR function, like this:.Sp.Vb 1\& ok t_cmp(1, 1, "1 == 1?");.Ve.Spthe third argument (\fI\f(CI$comment\fI\fR) is optional, mostly useful fortelling what the comparison is trying to do..SpIt is valid to use \f(CW\*(C`undef\*(C'\fR as an expected value. Therefore:.Sp.Vb 2\& my $foo;\& t_cmp(undef, $foo, "undef == undef?");.Ve.Spwill return a \fItrue\fR value..SpYou can compare any two data-structures with \fIt_cmp()\fR. Just make surethat if you pass non-scalars, you have to pass their references. Thedatastructures can be deeply nested. For example you can compare:.Sp.Vb 3\& t_cmp({1 => [2..3,{5..8}], 4 => [5..6]},\& {1 => [2..3,{5..8}], 4 => [5..6]},\& "hash of array of hashes");.Ve.SpYou can also compare the second argument against the first as aregex. Use the \f(CW\*(C`qr//\*(C'\fR function in the second argument. For example:.Sp.Vb 1\& t_cmp("abcd", qr/^abc/, "regex compare");.Ve.Spwill do:.Sp.Vb 1\& "abcd" =~ /^abc/;.Ve.SpThis function is exported by default..IP "\fIt_filepath_cmp()\fR" 4.IX Item "t_filepath_cmp()"This function is used to compare two filepaths via \fIt_cmp()\fR.For non\-Win32, it simply uses \fIt_cmp()\fR for the comparison,but for Win32, \fIWin32::GetLongPathName()\fR is invoked to convertthe first two arguments to their \s-1DOS\s0 long pathname. This is usefulwhen there is a possibility the two paths being comparedare not both represented by their long or short pathname..SpThis function is exported by default..IP "\fIt_debug()\fR" 4.IX Item "t_debug()".Vb 2\& t_debug("testing feature foo");\& t_debug("test", [1..3], 5, {a=>[1..5]});.Ve.Sp\&\fIt_debug()\fR prints out any datastructure while prepending \f(CW\*(C`#\*(C'\fR at thebeginning of each line, to make the debug printouts comply with\&\f(CW\*(C`Test::Harness\*(C'\fR's requirements. This function should be always usedfor debug prints, since if in the future the debug printing willchange (e.g. redirected into a file) your tests won't need to bechanged..Spthe special global variable \f(CW$Apache::TestUtil::DEBUG_OUTPUT\fR canbe used to redirect the output from \fIt_debug()\fR and related callssuch as \fIt_write_file()\fR. for example, from a server-side testyou would probably need to redirect it to \s-1STDERR:\s0.Sp.Vb 2\& sub handler {\& plan $r, tests => 1;\&\& local $Apache::TestUtil::DEBUG_OUTPUT = \e*STDERR;\&\& t_write_file(\*(Aq/tmp/foo\*(Aq, \*(Aqbar\*(Aq);\& ...\& }.Ve.Spleft to its own devices, \fIt_debug()\fR will collide with the standard\&\s-1HTTP\s0 protocol during server-side tests, resulting in a situationboth confusing difficult to debug. but \s-1STDOUT\s0 is left as thedefault, since you probably don't want debug output under normalcircumstances unless running under verbose mode..SpThis function is exported by default..IP "\fIt_write_file()\fR" 4.IX Item "t_write_file()"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -