Add ability to exclude files or directories #149

Closed
redking opened this Issue Jan 8, 2013 · 9 comments

Comments

Projects
None yet
3 participants
Contributor

redking commented Jan 8, 2013

Hey,

I have a feature request; I'm using globs to load a large source tree before executing all my Jasmine specs. There doesn't currently appear to be a way to exclude particular files or directories from being loaded into the test page.

For example, imagine a config file as below

 {
    "framework": "jasmine",
    "src_files": [
        "/javascript/someDir/**/*.js"
    ],
    "exclude_files": [
        "/javascript/someDir/someSubDir/file.js",
        "/javascript/someDir/someOtherSubDir/**/*.js"
    ]
 }

So all files in /javascript/someDir/ would be loaded, other than those described by the exclude_files option.

I need this as the source tree is not entirely under my control, shared amongst many collaborators, so there are occasionally files or directories that must be temporarily excluded from being loaded into the test page (as they interfere with other tests).

Moreover, there are too many subdirectories for me to remove the single-line glob and whitelist valid directories individually under src_files.

If this isn't something that is already planned or being worked on, then I'll implement it and submit a pull request.

Thanks!

Collaborator

airportyh commented Jan 8, 2013

I'd like to call it src_files_exclude to be more unambiguous, but I am fine with this. A pull request would be very appreciated.

Contributor

redking commented Jan 9, 2013

It's a bit more complicated than I'd originally thought it would be - reconciling two lists of globbed expressions, keeping asynchronicity - but I'll try to do something over the coming week. I thought to add it as early as possible, in config.js when the configuration params are first accessed, if that sounds reasonable.

Collaborator

airportyh commented Jan 9, 2013

Try using https://github.com/isaacs/minimatch for exclusion matching.

On Jan 9, 2013, at 4:59 AM, Cormac Flynn notifications@github.com wrote:

It's a bit more complicated than I'd originally thought it would be - reconciling two lists of globbed expressions, keeping asynchronicity - but I'll try to do something over the coming week. I thought to add it as early as possible, in config.js when the configuration params are first accessed, if that sounds reasonable.


Reply to this email directly or view it on GitHub.

Anything I could do to help? I'm looking for exactly this type of functionality, only in my case because I need to exclude a test-dir and srv-dir which contain node-files, while the rest of the app is front-facing (I know, I could also create separate projects....)

Collaborator

airportyh commented Jan 24, 2013

Yeah, I could use all the help I can get! This would involve using the minimatch library for exclusion matching after globbing the files. Ask if you have any questions here, on the mailing list or email me personally.

Contributor

redking commented Jan 24, 2013

I've implemented this in a fork (https://github.com/redking/testem/) but I haven't issued a pull request for two reasons

  1. The change adds the configuration key "src_files_ignore", excluding any matching files from being loaded into the test runner HTML. However, it does not exclude those files from being tracked for changes as, it seems to me, it would require a fair bit of refactoring to achieve this, and it isn't within the scope of what I'm working on. So it's a rather unsatisfying change - the files are no longer loaded, but any changes made to them will reload the test runner
  2. I haven't finished updating the unit tests yet

However, if airportyh is happy to accept this (limited) change, once the tests are finished I'll send a pull request.

Incidentally, the recent commit history of the fork is a little messy, due to my having committed webstorm artifacts, but the primary modification was a simple change to lib/config.js, using the "fileset" module

Collaborator

airportyh commented Jan 30, 2013

Sorry for the delay. I'll take a look at this tomorrow and hopefully get this in.

airportyh added a commit that referenced this issue Jan 31, 2013

@airportyh airportyh closed this Jan 31, 2013

airportyh added a commit that referenced this issue Jan 31, 2013

Collaborator

airportyh commented Jan 31, 2013

You can now use either src_files_ignore or serve_files_ignore. Please test!

Contributor

redking commented Feb 1, 2013

Hey,

I did a test and, since upgrading, my tests fail as the import order of dependencies in the src_files array is no longer respected! In fact, it appears it occurs since v0.2.58. I'll open a bug.

I know before you mentioned creating a custom runner to enforce the load order, but I would no longer benefit from wildcards and ** notation and would have to harcode the (large) list of source files under test, if that's correct ?

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