fix t/lib/fields.t's @INC so make test runs
[p5sagit/p5-mst-13.2.git] / t / lib / h2ph.t
CommitLineData
1d2dff63 1#!./perl
2
3# quickie tests to see if h2ph actually runs and does more or less what is
4# expected
5
6BEGIN {
7 chdir 't' if -d 't';
8 @INC = '../lib';
9}
10
1d2dff63 11print "1..2\n";
12
a1737d5b 13# quickly compare two text files
14sub txt_compare {
15 local ($/, $A, $B);
16 for (($A,$B) = @_) { open(_,"<$_") ? $_ = <_> : die "$_ : $!"; close _ }
17 $A cmp $B;
18}
19
1d2dff63 20unless(-e '../utils/h2ph') {
21 print("ok 1\nok 2\n");
22 # i'll probably get in trouble for this :)
23} else {
24 # does it run?
1289a8b8 25 if ($^O ne 'dos') {
26 $ok = system("./perl -I../lib ../utils/h2ph -d. lib/h2ph.h");
27 } else {
28 # h2ph prints some info which confuses t/TEST on dos/djgpp
29 $ok = system("./perl -I../lib ../utils/h2ph -d. lib/h2ph.h >nul");
30 }
1d2dff63 31 print(($ok == 0 ? "" : "not "), "ok 1\n");
32
33 # does it work? well, does it do what we expect? :-)
a1737d5b 34 $ok = txt_compare("lib/h2ph.ph", "lib/h2ph.pht");
1d2dff63 35 print(($ok == 0 ? "" : "not "), "ok 2\n");
36
37 # cleanup - should this be in an END block?
38 unlink("lib/h2ph.ph");
39}