@@ -1054,34 +1054,6 @@ func (o *outputWriter) Write(p []byte) (int, error) {
1054
1054
o .c .mu .Lock ()
1055
1055
defer o .c .mu .Unlock ()
1056
1056
1057
- doWrite := func (s string ) {
1058
- if o .c .done {
1059
- // This test has already finished. Try and log this message
1060
- // with our parent. If we don't have a parent, panic.
1061
- for parent := o .c .parent ; parent != nil ; parent = parent .parent {
1062
- parent .mu .Lock ()
1063
- defer parent .mu .Unlock ()
1064
- if ! parent .done {
1065
- parent .output = append (parent .output , s ... )
1066
- return
1067
- }
1068
- }
1069
- panic ("Log in goroutine after " + o .c .name + " has completed: " + string (p ))
1070
- } else {
1071
- if o .c .chatty != nil {
1072
- if o .c .bench {
1073
- // Benchmarks don't print === CONT, so we should skip the test
1074
- // printer and just print straight to stdout.
1075
- fmt .Print (s )
1076
- } else {
1077
- o .c .chatty .Printf (o .c .name , "%s" , s )
1078
- }
1079
- } else {
1080
- o .c .output = append (o .c .output , s ... )
1081
- }
1082
- }
1083
- }
1084
-
1085
1057
str := string (o .b )
1086
1058
lines := strings .Split (str , "\n " )
1087
1059
for i , line := range lines {
@@ -1091,7 +1063,7 @@ func (o *outputWriter) Write(p []byte) (int, error) {
1091
1063
if line != "" {
1092
1064
o .b = []byte (line )
1093
1065
if i > 0 {
1094
- doWrite ("\n " )
1066
+ o . doWrite ("\n " , p )
1095
1067
}
1096
1068
break
1097
1069
}
@@ -1112,11 +1084,39 @@ func (o *outputWriter) Write(p []byte) (int, error) {
1112
1084
1113
1085
buf .WriteString (line )
1114
1086
1115
- doWrite (buf .String ())
1087
+ o . doWrite (buf .String (), p )
1116
1088
}
1117
1089
return len (p ), nil
1118
1090
}
1119
1091
1092
+ func (o * outputWriter ) doWrite (s string , p []byte ) {
1093
+ if o .c .done {
1094
+ // This test has already finished. Try and log this message
1095
+ // with our parent. If we don't have a parent, panic.
1096
+ for parent := o .c .parent ; parent != nil ; parent = parent .parent {
1097
+ parent .mu .Lock ()
1098
+ defer parent .mu .Unlock ()
1099
+ if ! parent .done {
1100
+ parent .output = append (parent .output , s ... )
1101
+ return
1102
+ }
1103
+ }
1104
+ panic ("Log in goroutine after " + o .c .name + " has completed: " + string (p ))
1105
+ } else {
1106
+ if o .c .chatty != nil {
1107
+ if o .c .bench {
1108
+ // Benchmarks don't print === CONT, so we should skip the test
1109
+ // printer and just print straight to stdout.
1110
+ fmt .Print (s )
1111
+ } else {
1112
+ o .c .chatty .Printf (o .c .name , "%s" , s )
1113
+ }
1114
+ } else {
1115
+ o .c .output = append (o .c .output , s ... )
1116
+ }
1117
+ }
1118
+ }
1119
+
1120
1120
// Log formats its arguments using default formatting, analogous to Println,
1121
1121
// and records the text in the error log. For tests, the text will be printed only if
1122
1122
// the test fails or the -test.v flag is set. For benchmarks, the text is always
0 commit comments