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