Skip to content
This repository was archived by the owner on Dec 8, 2024. It is now read-only.

No way to instrument directories with absolute filenames #110

Open
Nomeasmo opened this issue Oct 20, 2013 · 3 comments
Open

No way to instrument directories with absolute filenames #110

Nomeasmo opened this issue Oct 20, 2013 · 3 comments

Comments

@Nomeasmo
Copy link

E.g. Karma's preprocessor instruments file by file. In this case the instrumentation is done with absolute path. Whereas the cli allows instrumentation off directories which are enforced by code to be relative.

instrument.js:#204                relative: true

Merging these results with a middleware does not work. It is desired to expose the option relative to the cli.

@gotwarlost
Copy link
Owner

I don't quite understand the problem. Could you explain with an example?

@Nomeasmo
Copy link
Author

In an Meteor project called RTD we have a mix of instrumentation for acceptance tests and unit tests. The one uses Karma, which instruments the files file-by-file. This results into instrumentations having an absolute path. For the other method we use Istanbul directly by passing an directory. In this case all directories are relative.

If we merge these friends together in order to get a full coverage result for both tests, the results are not merged and each file is listed twice, since they're instrumented differently. (side-note: istanbul-middleware-port is used)

We fix this currently with preprocessing the report data using the following statement.

   var re = /\.\/app/g;
        data = data.replace(re, PROJECT_BASE_PATH.substring(0, PROJECT_BASE_PATH.indexOf('/test/rtd')) + '/app');

Hence it would be cleaner, if Istanbul could expose the option to instrument using absolute paths also for directory instrumentation.

(Hope these picture make it clear)

unbenannt-1
Above without path correction
unbenannt-2
Above with path correction

carneiror added a commit to carneiror/istanbul that referenced this issue Jan 4, 2017
@carneiror
Copy link

I add this problem and forked the source-map branch and force the collector to use always absolute paths: carneiror/istanbul#source-map

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants