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