cenfun / monocart-coverage-reports

A code coverage tool to generate native V8 reports or Istanbul reports.
MIT License
31 stars 5 forks source link

minimatch failed to match #29

Closed fanksy closed 3 months ago

fanksy commented 3 months ago

version: 2.8.2

minimatch("node_modules/node_modules/.pnpm/rbush@3.0.1/node_modules/rbush/rbush.js", "/node_modules/")

the result is false.

cenfun commented 3 months ago

I am not an expert on minimatch, here are more explanations, see https://github.com/isaacs/minimatch

I think the pattern should be node_modules/* or **/node_modules/**

fanksy commented 3 months ago

I am not an expert on minimatch, here are more explanations, see https://github.com/isaacs/minimatch

I think the pattern should be node_modules/* or **/node_modules/**

我直接说中文吧,上面显示错了,符号被编辑器过滤了,`/node_modules/**`这样也是不行的,这个minimatch问题很大,可以换成别的

我正在把它集成到electron,做成本地收集数据的Agent,测试发现statement和branch划分的不太准确

cenfun commented 3 months ago

嗯,minimatch有它的规范,应该不是问题,只是要遵循这些写法而已,而且minimatch已经是使用最广泛的库来匹配路径,而且已经兼容可各种操作系统,所以没有必要自己弄一个。 如果不想用可以直接用回调函数,这样你可以换成任意自己想使用的匹配器

fanksy commented 3 months ago

这个都是小问题,statment和branch后续还有没有改进的计划呢,我正在计划把这个报告用在实际工作生产中,需要精确度尽可能好些

cenfun commented 3 months ago

只要能改进肯定是可以继续改的,欢迎使用到生产中 目前已经有很多项目已经使用到生产中了,包括自动化测试工具,比如CodeceptJS已经集成了本工具 目前,仅此工具支持原生V8覆盖率报告,包括V8覆盖率的开发作者也只提供了c8这个工具,但只是粗略的转换成了Istanbul,存在很多问题,后来干脆自己写了这个工具。 因为statment和branch包括部分function是V8原生覆盖率数据本身不支持的,这里是通过解析源代码的AST语法树换算过来的, 精度本身应该足够好了,但解析精度还取决于sourcemap的精度,众所周知,不同的构建工具,生成的sourcemap那是各不相同,经测试,类js语法的源文件精度完全没问题,但比如像xml,jsx,vue这些,根本就不是js语法,所以要支持精确覆盖率,除非他们把sourcemap写精确才行,但应该很难,也许需要等sourcemap下一代规范才能实现