Commit | Line | Data |
1d2dff63 |
1 | #!./perl |
dc1ddadd |
2 | use strict; |
1d2dff63 |
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 |
10 | } |
11 | |
dc1ddadd |
12 | require './test.pl'; |
13 | |
b7bcf494 |
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 | |
8d66b3f9 |
21 | plan(5); |
1d2dff63 |
22 | |
a1737d5b |
23 | # quickly compare two text files |
24 | sub txt_compare { |
dc1ddadd |
25 | local $/; |
26 | my ($A, $B); |
a1737d5b |
27 | for (($A,$B) = @_) { open(_,"<$_") ? $_ = <_> : die "$_ : $!"; close _ } |
28 | $A cmp $B; |
29 | } |
30 | |
dc1ddadd |
31 | my $result = runperl( progfile => $extracted_program, |
32 | args => ['-d.', '-Q', 'lib/h2ph.h']); |
33 | is( $?, 0, "$extracted_program runs successfully" ); |
1d2dff63 |
34 | |
dc1ddadd |
35 | is ( txt_compare("lib/h2ph.ph", "lib/h2ph.pht"), |
36 | 0, |
37 | "generated file has expected contents" ); |
1d2dff63 |
38 | |
dc1ddadd |
39 | $result = runperl( progfile => 'lib/h2ph.pht', |
40 | switches => ['-c'], |
41 | stderr => 1 ); |
42 | like( $result, qr/syntax OK$/, "output compiles"); |
43 | |
8d66b3f9 |
44 | $result = runperl( progfile => '_h2ph_pre.ph', |
45 | switches => ['-c'], |
46 | stderr => 1 ); |
47 | like( $result, qr/syntax OK$/, "preamble compiles"); |
48 | |
dc1ddadd |
49 | $result = runperl( switches => ["-w"], |
8d66b3f9 |
50 | stderr => 1, |
51 | prog => <<'PROG' ); |
52 | $SIG{__WARN__} = sub { die $_[0] }; require q(lib/h2ph.pht); |
53 | PROG |
dc1ddadd |
54 | is( $result, '', "output free of warnings" ); |
55 | |
56 | # cleanup |
57 | END { |
58 | 1 while unlink("lib/h2ph.ph"); |
59 | 1 while unlink("_h2ph_pre.ph"); |
60 | } |