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

file paths that includes parentheses causes base directory to be wrong #728

Closed
Oobert opened this issue Aug 30, 2013 · 4 comments
Closed

Comments

@Oobert
Copy link

Oobert commented Aug 30, 2013

If a file paths for items listed in files configuration section contains parentheses, the base directory for those files is incorrectly inferred.

Example:
C:\path\to\my\files\something(other thing)\anotherDirectory*.js

Base directory is inferred as:
C:\path\to\my\files\

instead of:
C:\path\to\my\files\something(other thing)\anoterDirectory\

This causes karma to watch all files in the wrong directory and may cause high CPU useage. In my case it was 80% cpu usage because it was watching 1000s of files.

Windows 7
Karma: 0.10.2

The cause is the regex in function baseDirFromPattern in watch.js
https://github.com/karma-runner/karma/blob/master/lib/watcher.js#L11

If I knew regex better or what exactly this was doing, I would attempt to fix it.

@vojtajina
Copy link
Contributor

I don't understand this issue.

Why should ...\x\something(other thing)*.js produce base directory ...\x\something(other thing)*\ ? That makes no sense to me. This pattern means that any file in C:\path\to\my\files\ that matches something(other thing)*.js is matched. Therefore the whole C:\path/to\my\files\ directory has to be scanned.

@Oobert
Copy link
Author

Oobert commented Sep 3, 2013

doh! my \ before *.js disappeared. Edited issue to be more clear. Previously there was a \ before *.js but I added anotherDirectory to make the example more clear. I hope this helps!

@yngvark
Copy link

yngvark commented Oct 11, 2013

I have run into this or a similar problem. I have a very simple karma project generating very high CPU loads, but only when the project is located in a deep directory path, including space and parantheses.

Relevant Karma config:
files: [
'test/Spec.js', // Contains 1 test file
'src/
.js' // Contains 1 js-file
],

Running with --log-level debug reveals that Karma is watching lots of files in other directories on my hard drive.

I am running the Karma projects in these two locations:

  1. d:\Temp\karmatest-simple
  2. d:\Dropbox\LenovoT410 (1)\a\b\c\d\karmatest-simple\

Number one works fine, number two gives huge CPU load. This suggests that something with the path causes the problem. My gut feeling is that the space rather than parantheses is the problem.

Please tell if more details are required.

edit: spelling

@ghost ghost assigned vojtajina Nov 16, 2013
@vojtajina
Copy link
Contributor

Ok, I see now. Yep, the parentheses is the problem. I didn't know that just parenthesis does not mean any special glob/fnmatch pattern, so we can actually get parentheses to work.

I'm working on it.

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

No branches or pull requests

3 participants