summaryrefslogtreecommitdiff
path: root/lib/h2ph.t
diff options
context:
space:
mode:
authorCraig A. Berry <craigberry@mac.com>2009-04-19 16:59:47 -0500
committerCraig A. Berry <craigberry@mac.com>2009-04-19 16:59:47 -0500
commitdc1ddadda044a4ff428f377d355d2ea53a195d16 (patch)
treebf9903ed801aeb8cf50ecdb6b5cc97bd2bef7f9b /lib/h2ph.t
parente0be038f1205193cc1aaea93032983c220ad6f39 (diff)
downloadperl-dc1ddadda044a4ff428f377d355d2ea53a195d16.tar.gz
Make lib/h2ph.t use t/test.pl.
This gives the Perl one-liners some chance of being portable.
Diffstat (limited to 'lib/h2ph.t')
-rwxr-xr-xlib/h2ph.t45
1 files changed, 26 insertions, 19 deletions
diff --git a/lib/h2ph.t b/lib/h2ph.t
index e303406380..27dd7b9d0a 100755
--- a/lib/h2ph.t
+++ b/lib/h2ph.t
@@ -1,4 +1,5 @@
#!./perl
+use strict;
# quickie tests to see if h2ph actually runs and does more or less what is
# expected
@@ -8,6 +9,8 @@ BEGIN {
@INC = '../lib';
}
+require './test.pl';
+
my $extracted_program = '../utils/h2ph'; # unix, nt, ...
if ($^O eq 'VMS') { $extracted_program = '[-.utils]h2ph.com'; }
if (!(-e $extracted_program)) {
@@ -15,31 +18,35 @@ if (!(-e $extracted_program)) {
exit 0;
}
-print "1..4\n";
+plan(4);
# quickly compare two text files
sub txt_compare {
- local ($/, $A, $B);
+ local $/;
+ my ($A, $B);
for (($A,$B) = @_) { open(_,"<$_") ? $_ = <_> : die "$_ : $!"; close _ }
$A cmp $B;
}
-# does it run?
-$ok = system("$^X \"-I../lib\" $extracted_program -d. \"-Q\" lib/h2ph.h");
-print(($ok == 0 ? "" : "not "), "ok 1\n");
+my $result = runperl( progfile => $extracted_program,
+ args => ['-d.', '-Q', 'lib/h2ph.h']);
+is( $?, 0, "$extracted_program runs successfully" );
-# does it work? well, does it do what we expect? :-)
-$ok = txt_compare("lib/h2ph.ph", "lib/h2ph.pht");
-print(($ok == 0 ? "" : "not "), "ok 2\n");
+is ( txt_compare("lib/h2ph.ph", "lib/h2ph.pht"),
+ 0,
+ "generated file has expected contents" );
-# 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");
+$result = runperl( progfile => 'lib/h2ph.pht',
+ switches => ['-c'],
+ stderr => 1 );
+like( $result, qr/syntax OK$/, "output compiles");
+
+$result = runperl( switches => ["-w"],
+ prog => '$SIG{__WARN__} = sub { die $_[0] }; require q(lib/h2ph.pht);');
+is( $result, '', "output free of warnings" );
+
+# cleanup
+END {
+ 1 while unlink("lib/h2ph.ph");
+ 1 while unlink("_h2ph_pre.ph");
+}