Initial import from FreeBSD RELENG_4:
[dragonfly.git] / contrib / perl5 / t / lib / h2ph.t
1 #!./perl
2
3 # quickie tests to see if h2ph actually runs and does more or less what is
4 # expected
5
6 BEGIN {
7     chdir 't' if -d 't';
8     @INC = '../lib';
9 }
10
11 print "1..2\n";
12
13 # quickly compare two text files
14 sub txt_compare {
15     local ($/, $A, $B);
16     for (($A,$B) = @_) { open(_,"<$_") ? $_ = <_> : die "$_ : $!"; close _ }
17     $A cmp $B;
18 }
19
20 unless(-e '../utils/h2ph') {
21     print("ok 1\nok 2\n");
22     # i'll probably get in trouble for this :)
23 } else {
24     # does it run?
25     $ok = system("./perl -I../lib ../utils/h2ph -d. -Q lib/h2ph.h");
26     print(($ok == 0 ? "" : "not "), "ok 1\n");
27     
28     # does it work? well, does it do what we expect? :-)
29     $ok = txt_compare("lib/h2ph.ph", "lib/h2ph.pht");
30     print(($ok == 0 ? "" : "not "), "ok 2\n");
31     
32     # cleanup - should this be in an END block?
33     unlink("lib/h2ph.ph");
34 }