[perl #118817] avoid using 2 handles to write to the debug output
authorTony Cook <tony@develop-help.com>
Mon, 13 Jan 2014 22:24:40 +0000 (09:24 +1100)
committerTony Cook <tony@develop-help.com>
Tue, 14 Jan 2014 21:38:21 +0000 (08:38 +1100)
Previously the tests were run with the following config:

  NonStop=0 TTY=db.out LineInfo=db.out

This meant that the debugger would write the prologue, command prompts
and their results and the epilogue to one handle, and any line trace
information to the second handle.  Since those handles didn't share a
file position, the line trace info would overwrite the prologue, and
the epilogue would overwrite part of the line trace info.

When TTY=vt100 on Redhat systems this made the epilogue just long
enough to overwrite the line trace data that a test matched against,
causing the test to fail.

To fix this, I avoided setting LineInfo:

  NonStop=0 TTY=db.out

and since LineInfo defaults to using the TTY handle, both types of
content are written to db.out *without* overwriting each other.

Unfortunately this broke some other tests, since the command prompts
which were overwritten by line trace information are now mixed in with
the line traces - I've modified the tests that failed to account for
the included command lines.

lib/perl5db.t

index 17fa744..95d2030 100644 (file)
@@ -72,7 +72,7 @@ sub _out_contents
     rc(
         <<'EOF',
 
-&parse_options("NonStop=0 ReadLine=0 TTY=db.out LineInfo=db.out");
+&parse_options("NonStop=0 ReadLine=0 TTY=db.out");
 
 sub afterinit {
     push(@DB::typeahead,
@@ -267,7 +267,7 @@ sub _quote
 sub _run {
     my $self = shift;
 
-    my $rc = qq{&parse_options("NonStop=0 TTY=db.out LineInfo=db.out");\n};
+    my $rc = qq{&parse_options("NonStop=0 TTY=db.out");\n};
 
     $rc .= join('',
         map { "$_\n"}
@@ -1235,6 +1235,7 @@ DebugWrap->new({
     $wrapper->contents_like(
         qr/
             $line_out
+            auto\(-\d+\)\s+DB<\d+>\s+\.\n
             $line_out
         /msx,
         'Test the "." command',
@@ -2380,6 +2381,10 @@ DebugWrap->new({
     $wrapper->contents_like(qr/
         ^main::\([^:]+:28\):\n
         28:\s+myfunc\(\);\n
+        auto\(-\d+\)\s+DB<1>\s+t\n
+        Trace\ =\ on\n
+        auto\(-\d+\)\s+DB<1>\s+b\ 18\n
+        auto\(-\d+\)\s+DB<2>\s+c\n
         main::myfunc\([^:]+:25\):\n
         25:\s+bar\(\);\n
         /msx,
@@ -2407,10 +2412,14 @@ DebugWrap->new({
     $wrapper->contents_like(qr/
         ^main::\([^:]+:28\):\n
         28:\s+myfunc\(\);\n
+        auto\(-\d+\)\s+DB<1>\s+o\ AutoTrace\n
+        \s+AutoTrace\s+=\s+'1'\n
+        auto\(-\d+\)\s+DB<2>\s+b\ 18\n
+        auto\(-\d+\)\s+DB<3>\s+c\n
         main::myfunc\([^:]+:25\):\n
         25:\s+bar\(\);\n
         /msx,
-        'Test the t command with function calls.',
+        'Test the o AutoTrace command with function calls.',
     );
 }