From 840ac0be536c0275f2919bee496de6217877134d Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Wed, 8 Jun 2016 10:16:10 -0700 Subject: [PATCH 1/3] Fix progress bar for projects test --- lib/fivemat_progress.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/fivemat_progress.js b/lib/fivemat_progress.js index d5e2997..4944176 100644 --- a/lib/fivemat_progress.js +++ b/lib/fivemat_progress.js @@ -88,9 +88,19 @@ function FivematProgress(runner, options) { completedTotal += complete; complete = 0; - // current project test count is 3372 but only 12 suites due to dynamic test creation - // total hack here to just call the total count ~ real total with headroom - total = newTitle === 'Projects tests' ? 3500 : suite.total(); + if (newTitle === 'Projects tests') { + // current project test count is 3372 but only 12 suites due to dynamic test creation + // Get the top level directory, the root of the TypeScript repository + var topLevelDirectory = __dirname.substring(0, __dirname.indexOf("node_modules")); + var projectDirectory = path.join(topLevelDirectory, path.normalize("tests/cases/project")); + var projectFiles = fs.readdirSync(projectDirectory); + // Get the number of project testcases then we multiply by the amount of suite each will be run + total = projectFiles.length * suite.total(); + } + else { + total = suite.total(); + } + lastN = -1; pass = 0; @@ -120,7 +130,7 @@ function FivematProgress(runner, options) { process.stdout.write('\u001b[J'); process.stdout.write(color('progress', ' ' + options.open)); process.stdout.write(color(fail > 0 ? 'fail' : 'pending', Array(n).join(options.complete))); - process.stdout.write(Array(i).join(options.incomplete)); + process.stdout.write(Array(i >= 0 ? i : 0).join(options.incomplete)); process.stdout.write(color('progress', options.close)); if (options.verbose) { process.stdout.write(color('progress', ' ' + complete + ' of ' + total)); From 6b289d0c41c39dab6e3df3c594b7e358c7ec338d Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Wed, 8 Jun 2016 10:18:57 -0700 Subject: [PATCH 2/3] Fix progress bar for projects test --- lib/fivemat_progress.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/fivemat_progress.js b/lib/fivemat_progress.js index d5e2997..0ee8b38 100644 --- a/lib/fivemat_progress.js +++ b/lib/fivemat_progress.js @@ -88,9 +88,19 @@ function FivematProgress(runner, options) { completedTotal += complete; complete = 0; - // current project test count is 3372 but only 12 suites due to dynamic test creation - // total hack here to just call the total count ~ real total with headroom - total = newTitle === 'Projects tests' ? 3500 : suite.total(); + if (newTitle === 'Projects tests') { + // current project test count is 3372 but only 12 suites due to dynamic test creation + // Get the top level directory, the root of the TypeScript repository + var topLevelDirectory = __dirname.substring(0, __dirname.indexOf("node_modules")); + var projectDirectory = path.join(topLevelDirectory, path.normalize("tests/cases/project")); + var projectFiles = fs.readdirSync(projectDirectory); + // Get the number of project testcases then we multiply by the amount of suite each will be run + total = projectFiles.length * suite.total(); + } + else { + total = suite.total(); + } + lastN = -1; pass = 0; @@ -120,7 +130,7 @@ function FivematProgress(runner, options) { process.stdout.write('\u001b[J'); process.stdout.write(color('progress', ' ' + options.open)); process.stdout.write(color(fail > 0 ? 'fail' : 'pending', Array(n).join(options.complete))); - process.stdout.write(Array(i).join(options.incomplete)); + process.stdout.write(Array(i >= 0 ? i : 0).join(options.incomplete)); process.stdout.write(color('progress', options.close)); if (options.verbose) { process.stdout.write(color('progress', ' ' + complete + ' of ' + total)); From f5131d1a6eedb81b62196ccb6e02c35dded4065a Mon Sep 17 00:00:00 2001 From: Yui Date: Wed, 8 Jun 2016 10:34:05 -0700 Subject: [PATCH 3/3] Update comment to reflect that change --- lib/fivemat_progress.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/fivemat_progress.js b/lib/fivemat_progress.js index 0ee8b38..e9d5f58 100644 --- a/lib/fivemat_progress.js +++ b/lib/fivemat_progress.js @@ -89,7 +89,8 @@ function FivematProgress(runner, options) { completedTotal += complete; complete = 0; if (newTitle === 'Projects tests') { - // current project test count is 3372 but only 12 suites due to dynamic test creation + // we have to compute how many projects tests from looking into how many files in the directory + // suite.total() only shows test suite per test-files // Get the top level directory, the root of the TypeScript repository var topLevelDirectory = __dirname.substring(0, __dirname.indexOf("node_modules")); var projectDirectory = path.join(topLevelDirectory, path.normalize("tests/cases/project"));