This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: [PATCH@32279] Upgrade File::Fetch to 0.13_04 - fixed for VMS.
[perl5.git] / lib / perl5db.t
index 8735e87..4553e02 100644 (file)
@@ -14,6 +14,10 @@ BEGIN {
        print "1..0 # Skip: no /dev/null\n";
        exit 0;
     }
+    if (!-c "/dev/tty") {
+       print "1..0 # Skip: no /dev/tty\n";
+       exit 0;
+    }
 }
 
 plan(1);
@@ -22,25 +26,37 @@ sub rc {
     open RC, ">", ".perldb" or die $!;
     print RC @_;
     close(RC);
+    # overly permissive perms gives "Must not source insecure rcfile"
+    # and hangs at the DB(1> prompt
+    chmod 0644, ".perldb";
 }
 
+my $target = '../lib/perl5db/t/eval-line-bug';
+
 rc(
     qq|
-    &parse_options("NonStop=0 TTY=/dev/null LineInfo=db.out");
+    &parse_options("NonStop=0 TTY=db.out LineInfo=db.out");
     \n|,
 
     qq|
     sub afterinit {
        push(\@DB::typeahead,
-           "DB::print_lineinfo(\@{'main::_<perl5db/eval-line-bug'})",
            'b 23',
-           'c',
+           'n',
+           'n',
+           'n',
+           'c', # line 23
+           'n',
+           "p \\\@{'main::_<$target'}",
            'q',
        );
     }\n|,
 );
 
-runperl(switches => [ '-d' ], progfile => '../lib/perl5db/eval-line-bug');
+{
+    local $ENV{PERLDB_OPTS} = "ReadLine=0";
+    runperl(switches => [ '-d' ], progfile => $target);
+}
 
 my $contents;
 {
@@ -50,12 +66,12 @@ my $contents;
     close(I);
 }
 
-like($contents, qr/factorial/,
+like($contents, qr/sub factorial/,
     'The ${main::_<filename} variable in the debugger was not destroyed'
 );
 
 # clean up.
 
 END {
-    unlink '.perldb', 'db.out';
+    unlink qw(.perldb db.out);
 }