From: Niko Tyni Date: Tue, 14 Apr 2009 19:55:33 +0000 (+0300) Subject: Add tests to verify that h2ph output compiles and is warning free X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c1a2df7619e7315b8fccef3b9fa56bb8d7df3845;p=p5sagit%2Fp5-mst-13.2.git Add tests to verify that h2ph output compiles and is warning free The #include directives are #ifdef'd out so that running the resulting code does not actually need the headers. We still get the same effect from comparing with the expected h2ph output. --- diff --git a/lib/h2ph.t b/lib/h2ph.t index 7b339b3..e303406 100755 --- a/lib/h2ph.t +++ b/lib/h2ph.t @@ -15,7 +15,7 @@ if (!(-e $extracted_program)) { exit 0; } -print "1..2\n"; +print "1..4\n"; # quickly compare two text files sub txt_compare { @@ -32,6 +32,14 @@ print(($ok == 0 ? "" : "not "), "ok 1\n"); $ok = txt_compare("lib/h2ph.ph", "lib/h2ph.pht"); print(($ok == 0 ? "" : "not "), "ok 2\n"); +# does the output compile? +$ok = system($^X, "-I../lib", "lib/h2ph.pht"); +print(($ok == 0 ? "" : "not "), "ok 3\n"); + +# is the output warning free? +$ok = system($^X, "-w", "-I../lib", "-e", '$SIG{__WARN__} = sub { die $_[0] }; require "lib/h2ph.pht"'); +print(($ok == 0 ? "" : "not "), "ok 4\n"); + # cleanup - should this be in an END block? unlink("lib/h2ph.ph"); unlink("_h2ph_pre.ph"); diff --git a/t/lib/h2ph.h b/t/lib/h2ph.h index 495789a..23f259e 100644 --- a/t/lib/h2ph.h +++ b/t/lib/h2ph.h @@ -68,9 +68,11 @@ function Tru64_Pascal(n: Integer): Integer; * with `use lib qw(/opt/perl5/lib/site_perl/i586-linux/linux);' or whatever * your equivalent is... */ +#if 0 #include #import "sys/ioctl.h" #include_next +#endif /* typedefs should be ignored */ typedef struct a_struct { diff --git a/t/lib/h2ph.pht b/t/lib/h2ph.pht index 145e682..01db98d 100644 --- a/t/lib/h2ph.pht +++ b/t/lib/h2ph.pht @@ -47,15 +47,17 @@ unless(defined(&_H2PH_H_)) { } else { eval 'sub WHATEVER () {1000;}' unless defined(&WHATEVER); } - require 'sys/socket.ph'; - require 'sys/ioctl.ph'; - eval { - my(@REM); - my(%INCD) = map { $INC{$_} => 1 } (grep { $_ eq "sys/fcntl.ph" } keys(%INC)); - @REM = map { "$_/sys/fcntl.ph" } (grep { not exists($INCD{"$_/sys/fcntl.ph"}) and -f "$_/sys/fcntl.ph" } @INC); - require "$REM[0]" if @REM; - }; - warn($@) if $@; + if(0) { + require 'sys/socket.ph'; + require 'sys/ioctl.ph'; + eval { + my(@REM); + my(%INCD) = map { $INC{$_} => 1 } (grep { $_ eq "sys/fcntl.ph" } keys(%INC)); + @REM = map { "$_/sys/fcntl.ph" } (grep { not exists($INCD{"$_/sys/fcntl.ph"}) and -f "$_/sys/fcntl.ph" } @INC); + require "$REM[0]" if @REM; + }; + warn($@) if $@; + } eval("sub sun () { 0; }") unless defined(&sun); eval("sub mon () { 1; }") unless defined(&mon); eval("sub tue () { 2; }") unless defined(&tue);