Default LOG_PRIMASK for Sys-Syslog in cases where it is not
[p5sagit/p5-mst-13.2.git] / ext / Devel / PPPort / parts / inc / ppphtest
CommitLineData
adfe19db 1################################################################################
2##
679ad62d 3## $Revision: 38 $
adfe19db 4## $Author: mhx $
679ad62d 5## $Date: 2007/08/12 23:58:29 +0200 $
adfe19db 6##
7################################################################################
8##
d2dacc4f 9## Version 3.x, Copyright (C) 2004-2007, Marcus Holland-Moritz.
adfe19db 10## Version 2.x, Copyright (C) 2001, Paul Marquess.
11## Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
12##
13## This program is free software; you can redistribute it and/or
14## modify it under the same terms as Perl itself.
15##
16################################################################################
17
679ad62d 18=tests plan => 221
0d0f8426 19
20BEGIN {
0c96388f 21 if ($ENV{'SKIP_SLOW_TESTS'}) {
679ad62d 22 for (1 .. 221) {
0c96388f 23 skip("skip: SKIP_SLOW_TESTS", 0);
0d0f8426 24 }
25 exit 0;
26 }
27}
adfe19db 28
29use File::Path qw/rmtree mkpath/;
96ad942f 30use Config;
adfe19db 31
32my $tmp = 'ppptmp';
96ad942f 33my $inc = '';
4a582685 34my $isVMS = $^O eq 'VMS';
35my $isMAC = $^O eq 'MacOS';
e8b5c247 36my $perl = find_perl();
adfe19db 37
38rmtree($tmp) if -d $tmp;
39mkpath($tmp) or die "mkpath $tmp: $!\n";
40chdir($tmp) or die "chdir $tmp: $!\n";
41
adfe19db 42if ($ENV{'PERL_CORE'}) {
87499469 43 if (-d '../../lib') {
4a582685 44 if ($isVMS) {
45 $inc = '"-I../../lib"';
46 }
47 elsif ($isMAC) {
48 $inc = '-I:::lib';
49 }
50 else {
51 $inc = '-I../../lib';
52 }
87499469 53 unshift @INC, '../../lib';
54 }
adfe19db 55}
96ad942f 56if ($perl =~ m!^\./!) {
57 $perl = ".$perl";
58}
adfe19db 59
60END {
cd266515 61 chdir('..') if !-d $tmp && -d "../$tmp";
62 rmtree($tmp) if -d $tmp;
adfe19db 63}
64
65ok(&Devel::PPPort::WriteFile("ppport.h"));
66
4a582685 67sub comment
68{
69 my $c = shift;
70 $c =~ s/^/# | /mg;
71 $c .= "\n" unless $c =~ /[\r\n]$/;
72 print $c;
73}
74
adfe19db 75sub ppport
76{
4a582685 77 my @args = ('ppport.h', @_);
78 unshift @args, $inc if $inc;
79 my $run = $perl =~ m/\s/ ? qq("$perl") : $perl;
80 $run .= ' -MMac::err=unix' if $isMAC;
81 for (@args) {
82 $_ = qq("$_") if $isVMS && /^[^"]/;
83 $run .= " $_";
84 }
85 print "# *** running $run ***\n";
86 $run .= ' 2>&1' unless $isMAC;
87 my @out = `$run`;
88 my $out = join '', @out;
89 comment($out);
90 return wantarray ? @out : $out;
adfe19db 91}
92
93sub matches
94{
95 my($str, $re, $mod) = @_;
96 my @n;
97 eval "\@n = \$str =~ /$re/g$mod;";
98 if ($@) {
99 my $err = $@;
100 $err =~ s/^/# *** /mg;
101 print "# *** ERROR ***\n$err\n";
102 }
103 return $@ ? -42 : scalar @n;
104}
105
106sub eq_files
107{
108 my($f1, $f2) = @_;
109 return 0 unless -e $f1 && -e $f2;
110 local *F;
111 for ($f1, $f2) {
112 print "# File: $_\n";
113 unless (open F, $_) {
114 print "# couldn't open $_: $!\n";
115 return 0;
116 }
117 $_ = do { local $/; <F> };
118 close F;
4a582685 119 comment($_);
adfe19db 120 }
121 return $f1 eq $f2;
122}
123
124my @tests;
125
126for (split /\s*={70,}\s*/, do { local $/; <DATA> }) {
127 s/^\s+//; s/\s+$//;
128 my($c, %f);
129 ($c, @f{m/-{20,}\s+(\S+)\s+-{20,}/g}) = split /\s*-{20,}\s+\S+\s+-{20,}\s*/;
130 push @tests, { code => $c, files => \%f };
131}
132
133my $t;
134for $t (@tests) {
135 my $f;
136 for $f (keys %{$t->{files}}) {
137 my @f = split /\//, $f;
138 if (@f > 1) {
139 pop @f;
140 my $path = join '/', @f;
141 mkpath($path) or die "mkpath('$path'): $!\n";
142 }
143 my $txt = $t->{files}{$f};
144 local *F;
145 open F, ">$f" or die "open $f: $!\n";
146 print F "$txt\n";
147 close F;
148 $txt =~ s/^/# | /mg;
149 print "# *** writing $f ***\n$txt\n";
150 }
151
152 eval $t->{code};
153 if ($@) {
154 my $err = $@;
155 $err =~ s/^/# *** /mg;
156 print "# *** ERROR ***\n$err\n";
157 }
158 ok($@, '');
159
160 for (keys %{$t->{files}}) {
161 unlink $_ or die "unlink('$_'): $!\n";
162 }
163}
164
96ad942f 165sub find_perl
166{
167 my $perl = $^X;
4a582685 168
169 return $perl if $isVMS;
170
96ad942f 171 my $exe = $Config{'_exe'} || '';
4a582685 172
96ad942f 173 if ($perl =~ /^perl\Q$exe\E$/i) {
174 $perl = "perl$exe";
175 eval "require File::Spec";
176 if ($@) {
177 $perl = "./$perl";
178 } else {
179 $perl = File::Spec->catfile(File::Spec->curdir(), $perl);
180 }
181 }
4a582685 182
96ad942f 183 if ($perl !~ /\Q$exe\E$/i) {
184 $perl .= $exe;
185 }
4a582685 186
96ad942f 187 warn "find_perl: cannot find $perl from $^X" unless -f $perl;
4a582685 188
96ad942f 189 return $perl;
190}
191
adfe19db 192__DATA__
193
194my $o = ppport(qw(--help));
195ok($o =~ /^Usage:.*ppport\.h/m);
196ok($o =~ /--help/m);
197
78b4ff79 198$o = ppport(qw(--version));
199ok($o =~ /^This is.*ppport.*\d+\.\d+(?:_?\d+)?\.$/);
200
adfe19db 201$o = ppport(qw(--nochanges));
4a582685 202ok($o =~ /^Scanning.*test\.xs/mi);
203ok($o =~ /Analyzing.*test\.xs/mi);
204ok(matches($o, '^Scanning', 'm'), 1);
205ok(matches($o, 'Analyzing', 'm'), 1);
adfe19db 206ok($o =~ /Uses Perl_newSViv instead of newSViv/);
207
208$o = ppport(qw(--quiet --nochanges));
209ok($o =~ /^\s*$/);
210
211---------------------------- test.xs ------------------------------------------
212
213Perl_newSViv();
214
215===============================================================================
216
217# check if C and C++ comments are filtered correctly
218
219my $o = ppport(qw(--copy=a));
4a582685 220ok($o =~ /^Scanning.*MyExt\.xs/mi);
221ok($o =~ /Analyzing.*MyExt\.xs/mi);
222ok(matches($o, '^Scanning', 'm'), 1);
adfe19db 223ok($o =~ /^Needs to include.*ppport\.h/m);
224ok($o !~ /^Uses grok_bin/m);
225ok($o !~ /^Uses newSVpv/m);
226ok($o =~ /Uses 1 C\+\+ style comment/m);
227ok(eq_files('MyExt.xsa', 'MyExt.ra'));
228
229# check if C++ are left untouched with --cplusplus
230
231$o = ppport(qw(--copy=b --cplusplus));
4a582685 232ok($o =~ /^Scanning.*MyExt\.xs/mi);
233ok($o =~ /Analyzing.*MyExt\.xs/mi);
234ok(matches($o, '^Scanning', 'm'), 1);
adfe19db 235ok($o =~ /^Needs to include.*ppport\.h/m);
236ok($o !~ /^Uses grok_bin/m);
237ok($o !~ /^Uses newSVpv/m);
238ok($o !~ /Uses \d+ C\+\+ style comment/m);
239ok(eq_files('MyExt.xsb', 'MyExt.rb'));
240
241unlink qw(MyExt.xsa MyExt.xsb);
242
243---------------------------- MyExt.xs -----------------------------------------
4a582685 244
adfe19db 245newSVuv();
246 // newSVpv();
247 XPUSHs(foo);
248/* grok_bin(); */
249
250---------------------------- MyExt.ra -----------------------------------------
4a582685 251
adfe19db 252#include "ppport.h"
253newSVuv();
254 /* newSVpv(); */
255 XPUSHs(foo);
256/* grok_bin(); */
257
258---------------------------- MyExt.rb -----------------------------------------
4a582685 259
adfe19db 260#include "ppport.h"
261newSVuv();
262 // newSVpv();
263 XPUSHs(foo);
264/* grok_bin(); */
265
266===============================================================================
267
268my $o = ppport(qw(--nochanges file1.xs));
4a582685 269ok($o =~ /^Scanning.*file1\.xs/mi);
270ok($o =~ /Analyzing.*file1\.xs/mi);
271ok($o !~ /^Scanning.*file2\.xs/mi);
adfe19db 272ok($o =~ /^Uses newCONSTSUB/m);
679ad62d 273ok($o =~ /^Uses SvPV_nolen.*depends.*sv_2pv_flags/m);
274ok($o =~ /WARNING: PL_expect/m);
adfe19db 275ok($o =~ /hint for newCONSTSUB/m);
adfe19db 276ok($o =~ /^Looks good/m);
277
278$o = ppport(qw(--nochanges --nohints file1.xs));
4a582685 279ok($o =~ /^Scanning.*file1\.xs/mi);
280ok($o =~ /Analyzing.*file1\.xs/mi);
281ok($o !~ /^Scanning.*file2\.xs/mi);
adfe19db 282ok($o =~ /^Uses newCONSTSUB/m);
679ad62d 283ok($o =~ /^Uses SvPV_nolen.*depends.*sv_2pv_flags/m);
284ok($o =~ /WARNING: PL_expect/m);
adfe19db 285ok($o !~ /hint for newCONSTSUB/m);
adfe19db 286ok($o =~ /^Looks good/m);
287
288$o = ppport(qw(--nochanges --nohints --nodiag file1.xs));
4a582685 289ok($o =~ /^Scanning.*file1\.xs/mi);
290ok($o =~ /Analyzing.*file1\.xs/mi);
291ok($o !~ /^Scanning.*file2\.xs/mi);
adfe19db 292ok($o !~ /^Uses newCONSTSUB/m);
293ok($o !~ /^Uses SvPV_nolen/m);
679ad62d 294ok($o =~ /WARNING: PL_expect/m);
adfe19db 295ok($o !~ /hint for newCONSTSUB/m);
adfe19db 296ok($o =~ /^Looks good/m);
297
298$o = ppport(qw(--nochanges --quiet file1.xs));
299ok($o =~ /^\s*$/);
300
301$o = ppport(qw(--nochanges file2.xs));
4a582685 302ok($o =~ /^Scanning.*file2\.xs/mi);
303ok($o =~ /Analyzing.*file2\.xs/mi);
304ok($o !~ /^Scanning.*file1\.xs/mi);
adfe19db 305ok($o =~ /^Uses mXPUSHp/m);
306ok($o =~ /^Needs to include.*ppport\.h/m);
307ok($o !~ /^Looks good/m);
308ok($o =~ /^1 potentially required change detected/m);
309
310$o = ppport(qw(--nochanges --nohints file2.xs));
4a582685 311ok($o =~ /^Scanning.*file2\.xs/mi);
312ok($o =~ /Analyzing.*file2\.xs/mi);
313ok($o !~ /^Scanning.*file1\.xs/mi);
adfe19db 314ok($o =~ /^Uses mXPUSHp/m);
315ok($o =~ /^Needs to include.*ppport\.h/m);
316ok($o !~ /^Looks good/m);
317ok($o =~ /^1 potentially required change detected/m);
318
319$o = ppport(qw(--nochanges --nohints --nodiag file2.xs));
4a582685 320ok($o =~ /^Scanning.*file2\.xs/mi);
321ok($o =~ /Analyzing.*file2\.xs/mi);
322ok($o !~ /^Scanning.*file1\.xs/mi);
adfe19db 323ok($o !~ /^Uses mXPUSHp/m);
324ok($o !~ /^Needs to include.*ppport\.h/m);
325ok($o !~ /^Looks good/m);
326ok($o =~ /^1 potentially required change detected/m);
327
328$o = ppport(qw(--nochanges --quiet file2.xs));
329ok($o =~ /^\s*$/);
330
331---------------------------- file1.xs -----------------------------------------
332
333#define NEED_newCONSTSUB
679ad62d 334#define NEED_sv_2pv_flags
adfe19db 335#include "ppport.h"
336
337newCONSTSUB();
338SvPV_nolen();
679ad62d 339PL_expect = 0;
adfe19db 340
341---------------------------- file2.xs -----------------------------------------
342
343mXPUSHp(foo);
344
345===============================================================================
346
347my $o = ppport(qw(--nochanges));
4a582685 348ok($o =~ /^Scanning.*FooBar\.xs/mi);
349ok($o =~ /Analyzing.*FooBar\.xs/mi);
350ok(matches($o, '^Scanning', 'm'), 1);
adfe19db 351ok($o !~ /^Looks good/m);
352ok($o =~ /^Uses grok_bin/m);
353
354---------------------------- FooBar.xs ----------------------------------------
355
356newSViv();
357XPUSHs(foo);
358grok_bin();
359
360===============================================================================
361
362my $o = ppport(qw(--nochanges));
4a582685 363ok($o =~ /^Scanning.*First\.xs/mi);
364ok($o =~ /Analyzing.*First\.xs/mi);
365ok($o =~ /^Scanning.*second\.h/mi);
366ok($o =~ /Analyzing.*second\.h/mi);
367ok($o =~ /^Scanning.*sub.*third\.c/mi);
368ok($o =~ /Analyzing.*sub.*third\.c/mi);
369ok($o !~ /^Scanning.*foobar/mi);
370ok(matches($o, '^Scanning', 'm'), 3);
adfe19db 371
372---------------------------- First.xs -----------------------------------------
373
374one
375
376---------------------------- foobar.xyz ---------------------------------------
377
378two
379
380---------------------------- second.h -----------------------------------------
381
382three
383
384---------------------------- sub/third.c --------------------------------------
385
386four
387
388===============================================================================
389
390my $o = ppport(qw(--nochanges));
391ok($o =~ /Possibly wrong #define NEED_foobar in.*test.xs/i);
392
393---------------------------- test.xs ------------------------------------------
394
395#define NEED_foobar
396
397===============================================================================
398
399# And now some complex "real-world" example
400
401my $o = ppport(qw(--copy=f));
402for (qw(main.xs mod1.c mod2.c mod3.c mod4.c mod5.c)) {
4a582685 403 ok($o =~ /^Scanning.*\Q$_\E/mi);
404 ok($o =~ /Analyzing.*\Q$_\E/i);
adfe19db 405}
4a582685 406ok(matches($o, '^Scanning', 'm'), 6);
adfe19db 407
4a582685 408ok(matches($o, '^Writing copy of', 'm'), 5);
adfe19db 409ok(!-e "mod5.cf");
410
411for (qw(main.xs mod1.c mod2.c mod3.c mod4.c)) {
412 ok($o =~ /^Writing copy of.*\Q$_\E.*with changes/mi);
413 ok(-e "${_}f");
414 ok(eq_files("${_}f", "${_}r"));
415 unlink "${_}f";
416}
417
418---------------------------- main.xs ------------------------------------------
419
420#include "EXTERN.h"
421#include "perl.h"
422#include "XSUB.h"
423
424#define NEED_newCONSTSUB
425#define NEED_grok_hex_GLOBAL
426#include "ppport.h"
427
428newCONSTSUB();
429grok_hex();
430Perl_grok_bin(aTHX_ foo, bar);
431
432/* some comment */
433
434perl_eval_pv();
435grok_bin();
436Perl_grok_bin(bar, sv_no);
437
438---------------------------- mod1.c -------------------------------------------
439
440#include "EXTERN.h"
441#include "perl.h"
442#include "XSUB.h"
443
444#define NEED_grok_bin_GLOBAL
445#define NEED_newCONSTSUB
446#include "ppport.h"
447
448newCONSTSUB();
449grok_bin();
450{
451 Perl_croak ("foo");
452 Perl_sv_catpvf(); /* I know it's wrong ;-) */
453}
454
455---------------------------- mod2.c -------------------------------------------
456
457#include "EXTERN.h"
458#include "perl.h"
459#include "XSUB.h"
460
461#define NEED_eval_pv
462#include "ppport.h"
463
464newSViv();
465
466/*
467 eval_pv();
468*/
469
470---------------------------- mod3.c -------------------------------------------
471
472#include "EXTERN.h"
473#include "perl.h"
474#include "XSUB.h"
475
476grok_oct();
477eval_pv();
478
479---------------------------- mod4.c -------------------------------------------
480
481#include "EXTERN.h"
482#include "perl.h"
483#include "XSUB.h"
484
485START_MY_CXT;
486
487---------------------------- mod5.c -------------------------------------------
488
489#include "EXTERN.h"
490#include "perl.h"
491#include "XSUB.h"
492
493#include "ppport.h"
494call_pv();
495
496---------------------------- main.xsr -----------------------------------------
497
498#include "EXTERN.h"
499#include "perl.h"
500#include "XSUB.h"
501
502#define NEED_eval_pv_GLOBAL
503#define NEED_grok_hex
504#define NEED_newCONSTSUB_GLOBAL
505#include "ppport.h"
506
507newCONSTSUB();
508grok_hex();
509grok_bin(foo, bar);
510
511/* some comment */
512
513eval_pv();
514grok_bin();
515grok_bin(bar, PL_sv_no);
516
517---------------------------- mod1.cr ------------------------------------------
518
519#include "EXTERN.h"
520#include "perl.h"
521#include "XSUB.h"
522
523#define NEED_grok_bin_GLOBAL
524#include "ppport.h"
525
526newCONSTSUB();
527grok_bin();
528{
529 Perl_croak (aTHX_ "foo");
530 Perl_sv_catpvf(aTHX); /* I know it's wrong ;-) */
531}
532
533---------------------------- mod2.cr ------------------------------------------
534
535#include "EXTERN.h"
536#include "perl.h"
537#include "XSUB.h"
538
539
540newSViv();
541
542/*
543 eval_pv();
544*/
545
546---------------------------- mod3.cr ------------------------------------------
547
548#include "EXTERN.h"
549#include "perl.h"
550#include "XSUB.h"
551#define NEED_grok_oct
552#include "ppport.h"
553
554grok_oct();
555eval_pv();
556
557---------------------------- mod4.cr ------------------------------------------
558
559#include "EXTERN.h"
560#include "perl.h"
561#include "XSUB.h"
562#include "ppport.h"
563
564START_MY_CXT;
565
566===============================================================================
567
568my $o = ppport(qw(--nochanges));
569ok($o =~ /Uses grok_hex/m);
570ok($o !~ /Looks good/m);
571
572$o = ppport(qw(--nochanges --compat-version=5.8.0));
573ok($o !~ /Uses grok_hex/m);
574ok($o =~ /Looks good/m);
575
576---------------------------- FooBar.xs ----------------------------------------
577
578grok_hex();
579
580===============================================================================
581
582my $o = ppport(qw(--nochanges));
583ok($o =~ /Uses SvPVutf8_force, which may not be portable/m);
584
4a582685 585$o = ppport(qw(--nochanges --compat-version=5.5.3));
586ok($o =~ /Uses SvPVutf8_force, which may not be portable/m);
587
588$o = ppport(qw(--nochanges --compat-version=5.005_03));
589ok($o =~ /Uses SvPVutf8_force, which may not be portable/m);
590
adfe19db 591$o = ppport(qw(--nochanges --compat-version=5.6.0));
592ok($o !~ /Uses SvPVutf8_force/m);
593
4a582685 594$o = ppport(qw(--nochanges --compat-version=5.006));
595ok($o !~ /Uses SvPVutf8_force/m);
596
597$o = ppport(qw(--nochanges --compat-version=5.999.999));
598ok($o !~ /Uses SvPVutf8_force/m);
599
600$o = ppport(qw(--nochanges --compat-version=6.0.0));
601ok($o =~ /Only Perl 5 is supported/m);
602
603$o = ppport(qw(--nochanges --compat-version=5.1000.999));
604ok($o =~ /Invalid version number: 5.1000.999/m);
605
606$o = ppport(qw(--nochanges --compat-version=5.999.1000));
607ok($o =~ /Invalid version number: 5.999.1000/m);
608
adfe19db 609---------------------------- FooBar.xs ----------------------------------------
610
611SvPVutf8_force();
612
96ad942f 613===============================================================================
614
615my $o = ppport(qw(--nochanges));
616ok($o !~ /potentially required change/);
4a582685 617ok(matches($o, '^Looks good', 'm'), 2);
96ad942f 618
619---------------------------- FooBar.xs ----------------------------------------
620
621#define NEED_grok_numeric_radix
622#define NEED_grok_number
623#include "ppport.h"
624
625GROK_NUMERIC_RADIX();
626grok_number();
627
628---------------------------- foo.c --------------------------------------------
629
630#include "ppport.h"
631
632call_pv();
633
4a582685 634===============================================================================
635
636# check --api-info option
637
638my $o = ppport(qw(--api-info=INT2PTR));
639my %found = map {($_ => 1)} $o =~ /^===\s+(\w+)\s+===/mg;
640ok(scalar keys %found, 1);
641ok(exists $found{INT2PTR});
642ok(matches($o, '^Supported at least starting from perl-5\.6\.0\.', 'm'), 1);
643ok(matches($o, '^Support by .*ppport.* provided back to perl-5\.003\.', 'm'), 1);
644
645$o = ppport(qw(--api-info=Zero));
646%found = map {($_ => 1)} $o =~ /^===\s+(\w+)\s+===/mg;
647ok(scalar keys %found, 1);
648ok(exists $found{Zero});
649ok(matches($o, '^No portability information available\.', 'm'), 1);
650
651$o = ppport(qw(--api-info=/Zero/));
652%found = map {($_ => 1)} $o =~ /^===\s+(\w+)\s+===/mg;
653ok(scalar keys %found, 2);
654ok(exists $found{Zero});
655ok(exists $found{ZeroD});
656
657===============================================================================
658
659# check --list-provided option
660
661my @o = ppport(qw(--list-provided));
662my %p;
663my $fail = 0;
664for (@o) {
665 my($name, $flags) = /^(\w+)(?:\s+\[(\w+(?:,\s+\w+)*)\])?$/ or $fail++;
666 exists $p{$name} and $fail++;
667 $p{$name} = defined $flags ? { map { ($_ => 1) } $flags =~ /(\w+)/g } : '';
668}
669ok(@o > 100);
670ok($fail, 0);
671
672ok(exists $p{call_sv});
673ok(not ref $p{call_sv});
674
675ok(exists $p{grok_bin});
676ok(ref $p{grok_bin}, 'HASH');
679ad62d 677ok(scalar keys %{$p{grok_bin}}, 2);
4a582685 678ok($p{grok_bin}{explicit});
679ad62d 679ok($p{grok_bin}{depend});
4a582685 680
681ok(exists $p{gv_stashpvn});
682ok(ref $p{gv_stashpvn}, 'HASH');
679ad62d 683ok(scalar keys %{$p{gv_stashpvn}}, 2);
684ok($p{gv_stashpvn}{depend});
4a582685 685ok($p{gv_stashpvn}{hint});
686
687ok(exists $p{sv_catpvf_mg});
688ok(ref $p{sv_catpvf_mg}, 'HASH');
689ok(scalar keys %{$p{sv_catpvf_mg}}, 2);
690ok($p{sv_catpvf_mg}{explicit});
691ok($p{sv_catpvf_mg}{depend});
692
679ad62d 693ok(exists $p{PL_signals});
694ok(ref $p{PL_signals}, 'HASH');
695ok(scalar keys %{$p{PL_signals}}, 1);
696ok($p{PL_signals}{explicit});
697
4a582685 698===============================================================================
699
700# check --list-unsupported option
701
702my @o = ppport(qw(--list-unsupported));
703my %p;
704my $fail = 0;
705for (@o) {
706 my($name, $ver) = /^(\w+)\s*\.+\s*([\d._]+)$/ or $fail++;
707 exists $p{$name} and $fail++;
708 $p{$name} = $ver;
709}
710ok(@o > 100);
711ok($fail, 0);
712
713ok(exists $p{utf8_distance});
714ok($p{utf8_distance}, '5.6.0');
715
716ok(exists $p{save_generic_svref});
717ok($p{save_generic_svref}, '5.005_03');
718
719===============================================================================
720
721# check --nofilter option
722
723my $o = ppport(qw(--nochanges));
724ok($o =~ /^Scanning.*foo\.cpp/mi);
725ok($o =~ /Analyzing.*foo\.cpp/mi);
726ok(matches($o, '^Scanning', 'm'), 1);
727ok(matches($o, 'Analyzing', 'm'), 1);
728
729$o = ppport(qw(--nochanges foo.cpp foo.o Makefile.PL));
730ok($o =~ /Skipping the following files \(use --nofilter to avoid this\):/m);
731ok(matches($o, '^\|\s+foo\.o', 'mi'), 1);
732ok(matches($o, '^\|\s+Makefile\.PL', 'mi'), 1);
733ok($o =~ /^Scanning.*foo\.cpp/mi);
734ok($o =~ /Analyzing.*foo\.cpp/mi);
735ok(matches($o, '^Scanning', 'm'), 1);
736ok(matches($o, 'Analyzing', 'm'), 1);
737
738$o = ppport(qw(--nochanges --nofilter foo.cpp foo.o Makefile.PL));
739ok($o =~ /^Scanning.*foo\.cpp/mi);
740ok($o =~ /Analyzing.*foo\.cpp/mi);
741ok($o =~ /^Scanning.*foo\.o/mi);
742ok($o =~ /Analyzing.*foo\.o/mi);
743ok($o =~ /^Scanning.*Makefile/mi);
744ok($o =~ /Analyzing.*Makefile/mi);
745ok(matches($o, '^Scanning', 'm'), 3);
746ok(matches($o, 'Analyzing', 'm'), 3);
747
748---------------------------- foo.cpp ------------------------------------------
749
750newSViv();
751
752---------------------------- foo.o --------------------------------------------
753
754newSViv();
755
756---------------------------- Makefile.PL --------------------------------------
757
758newSViv();
759
0d0f8426 760===============================================================================
761
762# check if explicit variables are handled propery
763
764my $o = ppport(qw(--copy=a));
765ok($o =~ /^Needs to include.*ppport\.h/m);
766ok($o =~ /^Uses PL_signals/m);
767ok($o =~ /^File needs PL_signals, adding static request/m);
768ok(eq_files('MyExt.xsa', 'MyExt.ra'));
769
770unlink qw(MyExt.xsa);
771
772---------------------------- MyExt.xs -----------------------------------------
773
774PL_signals = 123;
775if (PL_signals == 42)
776 foo();
777
778---------------------------- MyExt.ra -----------------------------------------
779
780#define NEED_PL_signals
781#include "ppport.h"
782PL_signals = 123;
783if (PL_signals == 42)
784 foo();
785
679ad62d 786===============================================================================
787
788my $o = ppport(qw(--nochanges file.xs));
789ok($o =~ /^Uses PL_copline/m);
790ok($o =~ /WARNING: PL_copline/m);
791ok($o =~ /^Uses SvUOK/m);
792ok($o =~ /WARNING: Uses SvUOK, which may not be portable/m);
793ok($o =~ /^Analysis completed \(2 warnings\)/m);
794ok($o =~ /^Looks good/m);
795
796$o = ppport(qw(--nochanges --compat-version=5.8.0 file.xs));
797ok($o =~ /^Uses PL_copline/m);
798ok($o =~ /WARNING: PL_copline/m);
799ok($o !~ /WARNING: Uses SvUOK, which may not be portable/m);
800ok($o =~ /^Analysis completed \(1 warning\)/m);
801ok($o =~ /^Looks good/m);
802
803---------------------------- file.xs -----------------------------------------
804
805#include "ppport.h"
806SvUOK
807PL_copline
808