From 384fca213d7aed065a218b548dc22fd394d69bd1 Mon Sep 17 00:00:00 2001 From: Nowell Strite Date: Wed, 21 Jan 2015 16:45:03 -0500 Subject: [PATCH 1/7] Initial work to cleanup output. --- bin/tap-difflet | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/bin/tap-difflet b/bin/tap-difflet index 196fd16..2a1326b 100755 --- a/bin/tap-difflet +++ b/bin/tap-difflet @@ -29,26 +29,18 @@ function output(str) { var timer = hirestime(); var errors = []; -var current = null; -var last = current; tap.on('comment', function(res) { - current = res; - output('\n' + chalk.white.bold(current)); + output(chalk.white.bold(res) + '\n'); }); tap.on('assert', function(res) { - if (current !== last) { - current = last; - output('\n'); - } - if (res.ok) { - output(chalk.green.bold('✓')); + output(' ' + chalk.green.bold('✓') + ' ' + chalk.gray(res.name) + '\n'); } else { - assert = chalk.red.bold('\n⨯ ' + res.name + '\n'); + assert = chalk.red.bold('⨯ ' + res.name + '\n'); errors.push(chalk.white(assert)); - output(errors[errors.length-1]); + output(' ' + errors[errors.length-1]); } }); @@ -68,11 +60,6 @@ tap.on('results', function(res) { var time = prettyms(timer()); out.push('\n'); - // errors.forEach(function(error) { - // output(error); - // output('\n'); - // }); - output(chalk.green(Math.max(0,count-errors.length) + ' passing') + chalk.gray(' (' + time + ')')); if (errors.length) { output(chalk.red('\n' + errors.length + ' failing')); @@ -103,7 +90,7 @@ tap.on('diag', function (diag) { gotActual = false; } - if (gotActual && gotExpected) { + if (gotActual && gotExpected) { if (typeof expected !== typeof actual || typeof expected === "object" && (!actual || !expected)) { str = 'Expected ' + typeof expected + ' but got ' + typeof actual; @@ -122,7 +109,7 @@ tap.on('diag', function (diag) { if (str) { str = '\n' + str; - str = str.replace(/\n/g, '\n '); + str = str.replace(/\n/g, '\n '); errors[errors.length-1] += str; output(str); output('\n'); From e5ec5f3fa0539390cf1b23567fe12c79c111a193 Mon Sep 17 00:00:00 2001 From: Nowell Strite Date: Wed, 21 Jan 2015 21:55:47 -0500 Subject: [PATCH 2/7] Added better comment output. --- bin/tap-difflet | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/tap-difflet b/bin/tap-difflet index 2a1326b..aae3de4 100755 --- a/bin/tap-difflet +++ b/bin/tap-difflet @@ -30,8 +30,14 @@ function output(str) { var timer = hirestime(); var errors = []; -tap.on('comment', function(res) { - output(chalk.white.bold(res) + '\n'); +tap.on('comment', function(comment) { + if (/^tests\s+[1-9]/gi.test(comment)) comment = chalk.white.bold(comment); + else if (/^pass\s+[1-9]/gi.test(comment)) comment = chalk.green.bold(comment); + else if (/^fail\s+[1-9]/gi.test(comment)) comment = chalk.red.bold(comment); + else if (/^ok$/gi.test(comment)) return; + else output('\n'); + + output(' ' + comment + '\n'); }); tap.on('assert', function(res) { From 63054e04911eb311c4b80cc67e796c9896e3387c Mon Sep 17 00:00:00 2001 From: Nowell Strite Date: Thu, 22 Jan 2015 00:19:59 -0500 Subject: [PATCH 3/7] Use fixed branch of tap-parser-yaml. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c2f2bde..9782de9 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "duplexer": "^0.1.1", "hirestime": "^0.2.4", "pretty-ms": "^1.0.0", - "tap-parser-yaml": "^0.7.0", + "tap-parser-yaml": "https://github.com/nowells/tap-parser-yaml/tarball/diag-fix", "through2": "^0.6.2" } } From 29652b90ac8bdcbab77c49fabeeb98f37c600802 Mon Sep 17 00:00:00 2001 From: Nowell Strite Date: Thu, 22 Jan 2015 08:47:10 -0500 Subject: [PATCH 4/7] More cleanup. --- bin/tap-difflet | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bin/tap-difflet b/bin/tap-difflet index aae3de4..01c9f2f 100755 --- a/bin/tap-difflet +++ b/bin/tap-difflet @@ -31,11 +31,11 @@ var timer = hirestime(); var errors = []; tap.on('comment', function(comment) { - if (/^tests\s+[1-9]/gi.test(comment)) comment = chalk.white.bold(comment); - else if (/^pass\s+[1-9]/gi.test(comment)) comment = chalk.green.bold(comment); - else if (/^fail\s+[1-9]/gi.test(comment)) comment = chalk.red.bold(comment); + if (/^tests\s+[0-9]+$/gi.test(comment)) comment = chalk.white.bold(comment); + else if (/^pass\s+[0-9]+$/gi.test(comment)) comment = chalk.green.bold(comment); + else if (/^fail\s+[0-9]+$/gi.test(comment)) comment = chalk.red.bold(comment); else if (/^ok$/gi.test(comment)) return; - else output('\n'); + else comment = chalk.white.bold(comment + '\n'); output(' ' + comment + '\n'); }); @@ -66,12 +66,12 @@ tap.on('results', function(res) { var time = prettyms(timer()); out.push('\n'); - output(chalk.green(Math.max(0,count-errors.length) + ' passing') + chalk.gray(' (' + time + ')')); + output(chalk.green.bold(Math.max(0,count-errors.length) + ' passing') + chalk.gray(' (' + time + ')')); if (errors.length) { - output(chalk.red('\n' + errors.length + ' failing')); + output(chalk.red.bold('\n' + errors.length + ' failing')); } - out.push('\n'); + out.push('\n\n'); }); tap.on('diag', function (diag) { @@ -118,7 +118,7 @@ tap.on('diag', function (diag) { str = str.replace(/\n/g, '\n '); errors[errors.length-1] += str; output(str); - output('\n'); + output('\n\n'); } }); From dc0a4122005032d33f7997caa7f37cb8d88b8110 Mon Sep 17 00:00:00 2001 From: Nowell Strite Date: Thu, 22 Jan 2015 09:07:05 -0500 Subject: [PATCH 5/7] Use newly published version. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9782de9..b90c69b 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "duplexer": "^0.1.1", "hirestime": "^0.2.4", "pretty-ms": "^1.0.0", - "tap-parser-yaml": "https://github.com/nowells/tap-parser-yaml/tarball/diag-fix", + "tap-parser-yaml": "^0.7.1", "through2": "^0.6.2" } } From 401effb3845ee5bd055fe34e22a9d1e23dcc444f Mon Sep 17 00:00:00 2001 From: Nowell Strite Date: Thu, 22 Jan 2015 09:25:41 -0500 Subject: [PATCH 6/7] Better newline handling for errors and test comments. --- bin/tap-difflet | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/bin/tap-difflet b/bin/tap-difflet index 01c9f2f..023e08e 100755 --- a/bin/tap-difflet +++ b/bin/tap-difflet @@ -31,11 +31,23 @@ var timer = hirestime(); var errors = []; tap.on('comment', function(comment) { - if (/^tests\s+[0-9]+$/gi.test(comment)) comment = chalk.white.bold(comment); - else if (/^pass\s+[0-9]+$/gi.test(comment)) comment = chalk.green.bold(comment); - else if (/^fail\s+[0-9]+$/gi.test(comment)) comment = chalk.red.bold(comment); - else if (/^ok$/gi.test(comment)) return; - else comment = chalk.white.bold(comment + '\n'); + if (/^tests\s+[0-9]+$/gi.test(comment)) { + output('\n'); + comment = chalk.white.bold(comment); + } + else if (/^pass\s+[0-9]+$/gi.test(comment)) { + comment = chalk.green.bold(comment); + } + else if (/^fail\s+[0-9]+$/gi.test(comment)) { + comment = chalk.red.bold(comment); + } + else if (/^ok$/gi.test(comment)) { + return; + } + else { + output('\n'); + comment = chalk.white.bold(comment); + } output(' ' + comment + '\n'); }); @@ -64,14 +76,14 @@ tap.on('extra', function(res) { tap.on('results', function(res) { var count = res.asserts.length; var time = prettyms(timer()); - out.push('\n'); + output('\n'); output(chalk.green.bold(Math.max(0,count-errors.length) + ' passing') + chalk.gray(' (' + time + ')')); if (errors.length) { output(chalk.red.bold('\n' + errors.length + ' failing')); } - out.push('\n\n'); + output('\n\n'); }); tap.on('diag', function (diag) { @@ -118,7 +130,7 @@ tap.on('diag', function (diag) { str = str.replace(/\n/g, '\n '); errors[errors.length-1] += str; output(str); - output('\n\n'); + output('\n'); } }); From 019f46978b381579f7875405f96089ab41fed768 Mon Sep 17 00:00:00 2001 From: Nowell Strite Date: Thu, 22 Jan 2015 10:47:04 -0500 Subject: [PATCH 7/7] Added at support to show line number of failure. --- bin/tap-difflet | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/bin/tap-difflet b/bin/tap-difflet index 023e08e..1faa85d 100755 --- a/bin/tap-difflet +++ b/bin/tap-difflet @@ -87,9 +87,10 @@ tap.on('results', function(res) { }); tap.on('diag', function (diag) { - var expected, actual, + var expected, actual, at, gotExpected = true, gotActual = true, + gotAt = true, str = ''; if (diag.hasOwnProperty('expected')) { @@ -108,6 +109,13 @@ tap.on('diag', function (diag) { gotActual = false; } + if (diag.hasOwnProperty('at')) { + at = diag.at; + } + else { + gotAt = false; + } + if (gotActual && gotExpected) { if (typeof expected !== typeof actual || typeof expected === "object" && (!actual || !expected)) { @@ -125,6 +133,10 @@ tap.on('diag', function (diag) { } } + if (gotAt) { + str = str + '\n\n' + chalk.grey('At: ' + at); + } + if (str) { str = '\n' + str; str = str.replace(/\n/g, '\n ');