Open shavo007 opened 9 years ago
This seems to indicate that "eventcode.extended.description.filter.js" is excluded from the files to be enforced. You're sure you don't have exclusion list defined else where?
Cheers for the reply mate.
I cant see any exclusion! BTW, my tests are side by side with my src code. The files end in _test.js.
I run the task as part of my custom test task:
grunt.registerTask('test', [
'clean:target',
'clean:server',
'wiredep',
'concurrent:test',
'autoprefixer',
'connect:test',
'karma',
'code-coverage-enforcer'
]);
Output for example is:
Running "code-coverage-enforcer" task
------------------------------------------------------------------
Running threshold checks for the following path config:app
------------------------------------------------------------------
------------------------------------------------------------------
Scanning folder for files
------------------------------------------------------------------
------------------------------------------------------------------
Threshold configuration: lines:85%, functions:85%, branches:85%
------------------------------------------------------------------
File:.\app\env\dev\trackConfig.js
lines:100% | functions:100% | branches:100% | >> EXCLUDED
File:.\app\components\constants\state-constants.js
lines:100% | functions:100% | branches:100% | >> EXCLUDED
File:.\app\components\directives\directives.module.js
lines:100% | functions:100% | branches:100% | >> EXCLUDED
File:.\app\components\directives\directives.js
lines:35% | functions:37.5% | branches:10% | >> EXCLUDED
File:.\app\app.module.js
lines:100% | functions:100% | branches:100% | >> EXCLUDED
File:.\app\app.config.js
lines:75% | functions:50% | branches:100% | >> EXCLUDED
File:.\app\components\cms\cms.module.js
Am i missing something!?
From what you show me, everything looks fine but the code obviously picks up the exclusion list some where.
You may have to debug in node-modules/grunt-code-coverage-enforcer/tasks/lib/code-coverage-enforcer-lib.js and put some logging in checkThresholdValidityForConfig() to see the exclusion list.
Cheers for the reply @lelong71 . I found the issue!
Ok, so if i look in my lcov.info file i have an entry like below: SF:./app/app.config.js
Then in the lib.js file, if i log output around isFileExcluded(), I see the entry in the console: File: .\app\app.config.js lines:75% | functions:50% | branches:100% I see that the filename is .\app\app.config.js. When it looks through the filelist, f is app\app.config.js.
So, my files will never be equal and will always be excluded.
Now in the method normalizeFileName if I add in condition for .\ it works.
exports.normalizeFileName = function(filename) {
if (filename.substring(0, 2) === "./") {
filename = filename.substring(2);
} else if (filename.substring(0, 2) === ".\\") {
filename = filename.substring(2);
}
else if (filename.substring(0, 1) === "/") {
filename = filename.substring(1);
}
return filename;
};
It will strip off the first two characters correctly and be equal.
Is this a valid change?
Thanks, Shane.
I think this is a bug, The fix is a valid. It looks like Karma generates os specific filenames unlike some other plugins, lcov supposedly requires unix style filenames, but plugins may not be following this.
Go ahead and send a pull request I will merge this in.
Thanks @lelong71 for suggesting the debug path and shane for getting to the root cause while im on vacation :-)
No problem Tapas. Hope you enjoy your vacation :) @shavo007 Glad you get to the root cause.
No worries.
Thanks for your help @lelong71 and @tapasvimoturu .
I will create a pull request Monday.
Cheers, Shane.
Created pull request guys. Let me know if its ok.
@lelong71 @tapasvimoturu :arrow_down:
Fantastic. What release will that be in guys? @tapasvimoturu
1.0.0
On Tuesday, January 26, 2016, shavo007 notifications@github.com wrote:
Fantastic. What release will that be in guys? @tapasvimoturu https://github.com/tapasvimoturu
— Reply to this email directly or view it on GitHub https://github.com/tapasvimoturu/grunt-code-coverage-enforcer/issues/11#issuecomment-175299224 .
Hi,
The version of module Im using is "grunt-code-coverage-enforcer": "^0.2.0", I am running this on windows 8.1 btw.
I have defined the reporter in karma.conf.js
Grunt config is
I run this command after generating the test reports.
In verbose mode I see for example:
File:.\app\components\filters\eventcode.extended.description.filter.js lines:83.33% | functions:100% | branches:50% | >> EXCLUDED
How come the task does not fail?
Thanks, Shane.