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