massive-oss / mcover

A cross platform code coverage framework for Haxe with testing and profiling applications. Supports AVM1, AVM2, JavaScript, C++, PHP and Neko.
Other
59 stars 9 forks source link

Methods using return expression (i.e. without braces) are not covered #53

Open cedx opened 4 years ago

cedx commented 4 years ago

I'm testing a Node.js application, and generating a LCOV report from the tests. See repo: https://github.com/cedx/setup-dart

If a class has methods without braces and covered by tests, these methods don't appear in the generated coverage report. See the DartSdk.download() method from file: https://github.com/cedx/setup-dart/blob/main/src/setup_dart/DartSdk.hx#L52

Without braces (i.e. method signature + return ...), Coveralls reports a code coverage of 44.44 %, and the LCOV report looks like this:

TN:setup_dart.DartSdk
SF:C:\Projets\haxe\setup-dart\src\setup_dart\DartSdk.hx

FN:37,new
FN:44,get_releaseUrl
FN:61,install
FN:76,__init__

FNDA:0,new
FNDA:0,get_releaseUrl
FNDA:1,install
FNDA:1,__init__

FNF:4
FNH:3

With braces (i.e. method signature + { return ...; }), Coveralls reports a code coverage of 45.65 %, and the LCOV report looks like this:

TN:setup_dart.DartSdk
SF:C:\Projets\haxe\setup-dart\src\setup_dart\DartSdk.hx

FN:37,new
FN:44,get_releaseUrl
FN:57,download
FN:62,install
FN:77,__init__

FNDA:0,new
FNDA:0,get_releaseUrl
FNDA:1,download
FNDA:1,install
FNDA:1,__init__

FNF:5
FNH:4

Haxe : 4.1.0 (x64) on Windows 10 MCover : 2.2.2

Off topic: is there a way to customize the path of the mcover.MCover.TEMP_DIR folder?

elsassph commented 4 years ago

Oof good find.

mcover was written before no-brace function syntax was a thing, and it seems to be more than just syntax sugar, so it doesn't know how to instrument them.