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

fix(watcher): use correct file sha in url query string #2620

Merged
merged 1 commit into from
Apr 5, 2017
Merged
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
9 changes: 8 additions & 1 deletion lib/file-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ List.prototype._isRefreshing = function () {
List.prototype._refresh = function () {
var self = this
var buckets = this.buckets
var matchedFiles = new Set()

var promise = Promise.map(this._patterns, function (patternObject) {
var pattern = patternObject.pattern
Expand All @@ -174,6 +175,12 @@ List.prototype._refresh = function () {
return Promise.resolve()
}

if (matchedFiles.has(path)) {
return Promise.resolve()
}

matchedFiles.add(path)

var mtime = mg.statCache[path].mtime
var doNotCache = patternObject.nocache
var file = new File(path, mtime, doNotCache)
Expand All @@ -191,7 +198,7 @@ List.prototype._refresh = function () {
files = _.compact(files)

if (_.isEmpty(files)) {
log.warn('All files matched by "%s" were excluded.', pattern)
log.warn('All files matched by "%s" were excluded or matched by prior matchers.', pattern)
} else {
buckets.set(pattern, new Set(files))
}
Expand Down
38 changes: 30 additions & 8 deletions test/e2e/files.feature
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ Feature: Including files
];
"""
When I start Karma
Then it passes with:
Then it passes with like:
"""
.
PhantomJS
"""
And it passes with like:
"""
files/log_foo.js" were excluded or matched by prior matchers.
"""

Scenario: Execute a test excluding an explicitly included file in another order
Given a configuration with:
Expand All @@ -59,11 +63,15 @@ Feature: Including files
];
"""
When I start Karma
Then it passes with:
Then it passes with like:
"""
.
PhantomJS
"""
And it passes with like:
"""
files/log_foo.js" were excluded or matched by prior matchers.
"""

Scenario: Execute a test excluding an file included with brackets patterns
Given a configuration with:
Expand All @@ -80,11 +88,15 @@ Feature: Including files
];
"""
When I start Karma
Then it passes with:
Then it passes with like:
"""
.
PhantomJS
"""
And it passes with like:
"""
files/{log,bug}_foo.js" were excluded or matched by prior matchers.
"""

Scenario: Execute a test excluding an file included with wildcard
Given a configuration with:
Expand All @@ -101,11 +113,15 @@ Feature: Including files
];
"""
When I start Karma
Then it passes with:
Then it passes with like:
"""
.
PhantomJS
"""
And it passes with like:
"""
files/*.js" were excluded or matched by prior matchers.
"""

Scenario: Execute a test excluding an file included with glob-star
Given a configuration with:
Expand All @@ -122,12 +138,15 @@ Feature: Including files
];
"""
When I start Karma
Then it passes with:
Then it passes with like:
"""
.
PhantomJS
"""

And it passes with like:
"""
files/**" were excluded or matched by prior matchers.
"""

Scenario: Execute a test excluding an file included with ext. glob patterns
Given a configuration with:
Expand All @@ -145,9 +164,12 @@ Feature: Including files
];
"""
When I start Karma
Then it passes with:
Then it passes with like:
"""
.
PhantomJS
"""

And it passes with like:
"""
files/{log,bug}_foo.js" were excluded or matched by prior matchers.
"""
11 changes: 11 additions & 0 deletions test/unit/file-list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,17 @@ describe('FileList', () => {
})
})

it('uses the file from the first matcher if two matchers match the same file', () => {
list = new List(patterns('/a.*', '*.txt'), [], emitter, preprocess, 100)
return list.refresh().then(() => {
var first = pathsFrom(list.buckets.get('/a.*'))
var second = pathsFrom(list.buckets.get('*.txt'))

expect(first).to.contain('/a.txt')
expect(second).not.to.contain('/a.txt')
})
})

it('cancels refreshs', () => {
var checkResult = (files) => {
expect(_.pluck(files.served, 'path')).to.contain('/some/a.js', '/some/b.js', '/some/c.js')
Expand Down