Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverage not working on Windows #32

Closed
hueniverse opened this issue Sep 10, 2013 · 4 comments
Assignees
Labels
bug
Milestone

Comments

@hueniverse
Copy link
Member

@hueniverse hueniverse commented Sep 10, 2013

Replaces hapijs/boom#7

@geek

This comment has been minimized.

Copy link
Member

@geek geek commented Dec 11, 2013

Will this be possible with our make requirement?

@hueniverse

This comment has been minimized.

Copy link
Member Author

@hueniverse hueniverse commented Dec 11, 2013

No idea. Does it work manually?

@hueniverse

This comment has been minimized.

Copy link
Member Author

@hueniverse hueniverse commented Feb 25, 2014

We just can't support windows. If someone else wants to fix it, I'm open to a PR.

@paed01

This comment has been minimized.

Copy link
Contributor

@paed01 paed01 commented May 6, 2014

It seems to be a problem with the paths being messed up in Windows.

But I have a suggestion. If the current working directory is removed from the filename with the path.relative function you could simplify the filter pattern.

// lib/coverage.js #18
exports.instrument = function () {

    var currentDir = process.cwd();
    var pattern = /^((?!node_modules\/|test).).*$/i;

    var origLoader = require.extensions['.js'];
    require.extensions['.js'] = function (localModule, filename) {

        var originalFilename = filename;
        filename = filename.replace(/\\/g, '/');

        var relFilename = Path.relative(currentDir, originalFilename).replace(/\\/g, '/');

        if (!pattern.test(relFilename)) {
            return origLoader(localModule, originalFilename);
        }

        var baseDirPath = Path.dirname(filename).replace(/\\/g, '/') + '/.';

        var instrumented = internals.instrument(filename);
        instrumented = instrumented.replace(/require\s*\(\s*("|')\./g, 'require($1' + baseDirPath);
        localModule._compile(instrumented, originalFilename);
    };
};

It worked for me on Windows. Though I'm not sure how it would impact *ux environments.

@hueniverse hueniverse reopened this May 8, 2014
hueniverse added a commit that referenced this issue May 19, 2014
Coverage file filter function modified to support Windows paths #32
@hueniverse hueniverse added this to the 3.2.0 milestone May 19, 2014
@hueniverse hueniverse self-assigned this May 19, 2014
hueniverse added a commit that referenced this issue May 19, 2014
hueniverse added a commit that referenced this issue May 19, 2014
hueniverse added a commit that referenced this issue May 19, 2014
@hueniverse hueniverse closed this May 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.