GeezerVison is showing github.com — test: fix invalid output TAP if there newline in test name · nodejs/node@38fb2c1
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/internal/test_runner/tap_stream.js +9-3Lines changed: 9 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -131,9 +131,15 @@ class TapStream extends Readable { | 131 | 131 |
| 132 | 132 | // In certain places, # and \ need to be escaped as \# and \\. | 133 | 133 | function tapEscape(input) { | 134 | | - return StringPrototypeReplaceAll( | 135 | | - StringPrototypeReplaceAll(input, '\\', '\\\\'), '#', '\\#' | 136 | | - ); | | 134 | + let result = StringPrototypeReplaceAll(input, '\\', '\\\\'); | | 135 | + result = StringPrototypeReplaceAll(result, '#', '\\#'); | | 136 | + result = StringPrototypeReplaceAll(result, '\b', '\\b'); | | 137 | + result = StringPrototypeReplaceAll(result, '\f', '\\f'); | | 138 | + result = StringPrototypeReplaceAll(result, '\t', '\\t'); | | 139 | + result = StringPrototypeReplaceAll(result, '\n', '\\n'); | | 140 | + result = StringPrototypeReplaceAll(result, '\r', '\\r'); | | 141 | + result = StringPrototypeReplaceAll(result, '\v', '\\v'); | | 142 | + return result; | 137 | 143 | } | 138 | 144 |
| 139 | 145 | function jsToYaml(indent, name, value) { | |
Collapse file Copy file name to clipboardExpand all lines: test/message/test_runner_output.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -213,7 +213,7 @@ test('test with a name and options provided', { skip: true }); | 213 | 213 | test({ skip: true }, function functionAndOptions() {}); | 214 | 214 |
| 215 | 215 | // A test whose description needs to be escaped. | 216 | | -test('escaped description \\ # \\#\\'); | | 216 | +test('escaped description \\ # \\#\\ \n \t \f \v \b \r'); | 217 | 217 |
| 218 | 218 | // A test whose skip message needs to be escaped. | 219 | 219 | test('escaped skip message', { skip: '#skip' }); | |
Collapse file Copy file name to clipboardExpand all lines: test/message/test_runner_output.out +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -127,9 +127,9 @@ not ok 13 - async assertion fail | 127 | 127 | failureType: 'testCodeFailure' | 128 | 128 | error: |- | 129 | 129 | Expected values to be strictly equal: | 130 | | - | | 130 | + | 131 | 131 | true !== false | 132 | | - | | 132 | + | 133 | 133 | code: 'ERR_ASSERTION' | 134 | 134 | expected: false | 135 | 135 | actual: true | @@ -353,8 +353,8 @@ ok 36 - functionAndOptions # SKIP | 353 | 353 | --- | 354 | 354 | duration_ms: * | 355 | 355 | ... | 356 | | -# Subtest: escaped description \\ \# \\\#\\ | 357 | | -ok 37 - escaped description \\ \# \\\#\\ | | 356 | +# Subtest: escaped description \\ \# \\\#\\ \n \t \f \v \b \r | | 357 | +ok 37 - escaped description \\ \# \\\#\\ \n \t \f \v \b \r | 358 | 358 | --- | 359 | 359 | duration_ms: * | 360 | 360 | ... | |
|