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

Harmonize test file & source pattern handling #736

Closed
novemberborn opened this issue Apr 7, 2016 · 9 comments · Fixed by #2103
Closed

Harmonize test file & source pattern handling #736

novemberborn opened this issue Apr 7, 2016 · 9 comments · Fixed by #2103
Labels

Comments

@novemberborn
Copy link
Member

Handling of test file patterns should be harmonized with how source patterns are handled (#614):

  • Use the default patterns if files is empty, or if it only contains negated patterns
  • Apply specified negated patterns together with the default exclusion patterns
  • Allow specified patterns to override the default exclusion patterns

The default exclusion patterns for source files are relative to the current working (node_modules/**/*) however the test file exclusion patterns can apply anywhere (**/node_modules/**). I guess that makes sense, though I'm not sure how to override the default exclusion patterns. Maybe that's not necessary for test files?

Should we change the source exclusion patterns? Or do those make more sense relative to the current working directory?


Implementation wise I think we can move the file selection tests in test/api.js to a new test/ava-files.js test file. We can set up a fixture directory to exercise the globbing behavior.

@jamestalmage
Copy link
Contributor

The default exclusion patterns for source files are relative to the current working (node_modules/**/*) however the test file exclusion patterns can apply anywhere (**/node_modules/**)

I think the source file pattern should be made to match the test file pattern.

I guess that makes sense, though I'm not sure how to override the default exclusion patterns. Maybe that's not necessary for test files?

Aren't you doing exactly that (overriding the defaults) in #614?

@novemberborn
Copy link
Member Author

I think the source file pattern should be made to match the test file pattern.

Yea maybe. Here's the list of source excludes. coverage may be tricky.

I guess that makes sense, though I'm not sure how to override the default exclusion patterns. Maybe that's not necessary for test files?

Aren't you doing exactly that (overriding the defaults) in #614?

Yes, but that's based on the path prefix. So node_modules/whatever maps to node_modules/**/*. That's trickier when the exclude patterns are recursive (**/node_modules/**). Now every path component needs to be checked. Though I guess that answers my question :)

Maybe we should move all this manipulation code into an external library.

@jamestalmage
Copy link
Contributor

coverage may be tricky.

Why?

@novemberborn
Copy link
Member Author

@jamestalmage it's a fairly generic name when ignoring deeply nested directories. I doubt anybody would put legitimate code in say .sass-cache.

@novemberborn
Copy link
Member Author

Allow specified patterns to override the default exclusion patterns

For example if you mimick your lib directory inside the test directory and you have actual helper modules inside lib/helpers, you may want to put their tests in test/helpers. You should be able to add test/helpers to the files pattern so that AVA looks for test files in that directory. See #909 (comment).

@buzinas
Copy link

buzinas commented Sep 25, 2016

@novemberborn Exactly this example is occurring in my project. Is there any way to bypass this?

@novemberborn
Copy link
Member Author

@buzinas not currently, no. You'll have to pick a different directory name.

@novemberborn
Copy link
Member Author

The default exclusion patterns for source files are relative to the current working (node_modules//*) however the test file exclusion patterns can apply anywhere (/node_modules/**). I guess that makes sense, though I'm not sure how to override the default exclusion patterns. Maybe that's not necessary for test files?

Currently this prevents tests from being shared through an npm package. Specifying an explicit node_modules/my-package/*.js pattern should select those tests in spite of the exclusion pattern. See #1136 (comment).

@novemberborn
Copy link
Member Author

There's more discussion in this PR: #1320 (comment)


At this point we're looking for help in summarizing the discussion into an actionable proposal, and then writing the code.

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

Successfully merging a pull request may close this issue.

3 participants