This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
t/loc_tools.pl: Consider thread 0 always locale-safe
[perl5.git] / t / run / switchDx.t
1 #!./perl -w
2 BEGIN {
3     chdir 't' if -d 't';
4     @INC = '../lib';
5     require './test.pl';
6     skip_all_if_miniperl();
7 }
8
9 use Config;
10
11 my $perlio_log = "perlio$$.txt";
12
13 skip_all "DEBUGGING build required"
14   unless $::Config{ccflags} =~ /(?<!\S)-DDEBUGGING(?!\S)/
15          or $^O eq 'VMS' && $::Config{usedebugging_perl} eq 'Y';
16
17 plan tests => 8;
18
19 END {
20     unlink $perlio_log;
21 }
22 {
23     unlink $perlio_log;
24     local $ENV{PERLIO_DEBUG} = $perlio_log;
25     fresh_perl_is("print qq(hello\n)", "hello\n",
26                   { stderr => 1 },
27                   "No perlio debug file without -Di...");
28     ok(!-e $perlio_log, "...no perlio.txt found");
29     fresh_perl_like("print qq(hello\n)", qr/\nEXECUTING...\n{1,2}hello\n?/,
30                   { stderr => 1, switches => [ "-Di" ] },
31                   "Perlio debug file with both -Di and PERLIO_DEBUG...");
32     ok(-e $perlio_log, "... perlio debugging file found with -Di and PERLIO_DEBUG");
33
34     unlink $perlio_log;
35     fresh_perl_like("print qq(hello\n)", qr/define raw/,
36                   { stderr => 1, switches => [ "-TDi" ] },
37                   "Perlio debug output to stderr with -TDi (with PERLIO_DEBUG)...");
38     ok(!-e $perlio_log, "...no perlio debugging file found");
39 }
40
41 {
42     local $ENV{PERLIO_DEBUG};
43     fresh_perl_like("print qq(hello)", qr/define raw/,
44                     { stderr => 1, switches => [ '-Di' ] },
45                    "-Di defaults to stderr");
46     fresh_perl_like("print qq(hello)", qr/define raw/,
47                     { stderr => 1, switches => [ '-TDi' ] },
48                    "Perlio debug output to STDERR with -TDi (no PERLIO_DEBUG)");
49 }
50