Commit | Line | Data |
---|---|---|
1d2dff63 GS |
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 GS |
9 | } |
10 | ||
dc1ddadd CB |
11 | require './test.pl'; |
12 | ||
b7bcf494 PP |
13 | my $extracted_program = '../utils/h2ph'; # unix, nt, ... |
14 | if ($^O eq 'VMS') { $extracted_program = '[-.utils]h2ph.com'; } | |
15 | if (!(-e $extracted_program)) { | |
16 | print "1..0 # Skip: $extracted_program was not built\n"; | |
17 | exit 0; | |
18 | } | |
19 | ||
112a1457 | 20 | plan(6); |
1d2dff63 | 21 | |
a1737d5b GS |
22 | # quickly compare two text files |
23 | sub txt_compare { | |
dc1ddadd CB |
24 | local $/; |
25 | my ($A, $B); | |
1ae6ead9 | 26 | for (($A,$B) = @_) { open(_,"<",$_) ? $_ = <_> : die "$_ : $!"; close _ } |
a1737d5b GS |
27 | $A cmp $B; |
28 | } | |
29 | ||
112a1457 FR |
30 | my $result = runperl( progfile => $extracted_program, |
31 | stderr => 1, | |
dc1ddadd | 32 | args => ['-d.', '-Q', 'lib/h2ph.h']); |
112a1457 | 33 | is( $result, '', "output is free of warnings" ); |
dc1ddadd | 34 | is( $?, 0, "$extracted_program runs successfully" ); |
112a1457 FR |
35 | |
36 | is ( txt_compare("lib/h2ph.ph", "lib/h2ph.pht"), | |
dc1ddadd CB |
37 | 0, |
38 | "generated file has expected contents" ); | |
112a1457 FR |
39 | |
40 | $result = runperl( progfile => 'lib/h2ph.pht', | |
41 | switches => ['-c'], | |
dc1ddadd CB |
42 | stderr => 1 ); |
43 | like( $result, qr/syntax OK$/, "output compiles"); | |
44 | ||
8d66b3f9 RB |
45 | $result = runperl( progfile => '_h2ph_pre.ph', |
46 | switches => ['-c'], | |
47 | stderr => 1 ); | |
48 | like( $result, qr/syntax OK$/, "preamble compiles"); | |
49 | ||
33593911 | 50 | $result = runperl( switches => ['-I.', "-w"], |
8d66b3f9 RB |
51 | stderr => 1, |
52 | prog => <<'PROG' ); | |
53 | $SIG{__WARN__} = sub { die $_[0] }; require q(lib/h2ph.pht); | |
54 | PROG | |
dc1ddadd CB |
55 | is( $result, '', "output free of warnings" ); |
56 | ||
57 | # cleanup | |
58 | END { | |
59 | 1 while unlink("lib/h2ph.ph"); | |
60 | 1 while unlink("_h2ph_pre.ph"); | |
61 | } |