Commit | Line | Data |
1d2dff63 |
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'; |
20822f61 |
8 | @INC = '../lib'; |
1d2dff63 |
9 | } |
10 | |
b7bcf494 |
11 | my $extracted_program = '../utils/h2ph'; # unix, nt, ... |
12 | if ($^O eq 'VMS') { $extracted_program = '[-.utils]h2ph.com'; } |
13 | if (!(-e $extracted_program)) { |
14 | print "1..0 # Skip: $extracted_program was not built\n"; |
15 | exit 0; |
16 | } |
17 | |
c1a2df76 |
18 | print "1..4\n"; |
1d2dff63 |
19 | |
a1737d5b |
20 | # quickly compare two text files |
21 | sub txt_compare { |
22 | local ($/, $A, $B); |
23 | for (($A,$B) = @_) { open(_,"<$_") ? $_ = <_> : die "$_ : $!"; close _ } |
24 | $A cmp $B; |
25 | } |
26 | |
b7bcf494 |
27 | # does it run? |
28 | $ok = system("$^X \"-I../lib\" $extracted_program -d. \"-Q\" lib/h2ph.h"); |
29 | print(($ok == 0 ? "" : "not "), "ok 1\n"); |
1d2dff63 |
30 | |
b7bcf494 |
31 | # does it work? well, does it do what we expect? :-) |
32 | $ok = txt_compare("lib/h2ph.ph", "lib/h2ph.pht"); |
33 | print(($ok == 0 ? "" : "not "), "ok 2\n"); |
1d2dff63 |
34 | |
c1a2df76 |
35 | # does the output compile? |
36 | $ok = system($^X, "-I../lib", "lib/h2ph.pht"); |
37 | print(($ok == 0 ? "" : "not "), "ok 3\n"); |
38 | |
39 | # is the output warning free? |
40 | $ok = system($^X, "-w", "-I../lib", "-e", '$SIG{__WARN__} = sub { die $_[0] }; require "lib/h2ph.pht"'); |
41 | print(($ok == 0 ? "" : "not "), "ok 4\n"); |
42 | |
b7bcf494 |
43 | # cleanup - should this be in an END block? |
44 | unlink("lib/h2ph.ph"); |
45 | unlink("_h2ph_pre.ph"); |