Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/utils/helpers.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ exports.excludeFile = (fileName, options) ->

# For each exclude value try to use it as a pattern to exclude files
exclude.map (pattern) ->
pattern = pattern[1..] if pattern[0] is "/"
if minimatch relativeFilename, pattern
excluded = true

Expand Down
17 changes: 17 additions & 0 deletions test/tests.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,23 @@ describe "Coverage tests", ->
expect(global[COVERAGE_VAR][pn 'a/foo.coffee'], "Should instrument a/foo.coffee").to.exist
expect(global[COVERAGE_VAR][pn 'b/bar.coffee'], "Should not instrument b/bar.coffee").to.not.exist

it "should exclude files based on globs with leading forward slash from project root when dynamically instrumenting code", ->

coffeeCoverage.register(
path: "relative"
basePath: path.resolve __dirname, '../testFixtures/testWithExcludes'
exclude: ["/b/*r.coffee"]
coverageVar: COVERAGE_VAR
log: log
)

require '../testFixtures/testWithExcludes/a/foo.coffee'
require '../testFixtures/testWithExcludes/b/bar.coffee'

expect(global[COVERAGE_VAR], "Code should have been instrumented").to.exist
expect(global[COVERAGE_VAR][pn 'a/foo.coffee'], "Should instrument a/foo.coffee").to.exist
expect(global[COVERAGE_VAR][pn 'b/bar.coffee'], "Should not instrument b/bar.coffee").to.not.exist

it "should handle nested recursion correctly", ->
# From https://github.com/benbria/coffee-coverage/pull/37
instrumentor = new coffeeCoverage.CoverageInstrumentor({
Expand Down