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

Add an option to include additional files #2739

Closed
EmmanuelRoux opened this issue Feb 9, 2021 · 7 comments
Closed

Add an option to include additional files #2739

EmmanuelRoux opened this issue Feb 9, 2021 · 7 comments
Labels
🚀 Feature request New feature request
Milestone

Comments

@EmmanuelRoux
Copy link

Is your feature request related to a problem? Please describe.

Related to: #2736

When some files ignores by git are needed to run Stryker, there are currently two workarounds:

  • use the inPlace option to avoid using the sandbox
  • use the files option to list all files that should be copied to sandbox

Describe the solution you'd like

Another nice option would be to have an option similar to files but allowing to specify only additional files.

@nicojs
Copy link
Member

nicojs commented Feb 12, 2021

Would you be helped by a custom .strykerignore file as well? I prefer that solution myself (decoupling Stryker from git). See #1593 (comment)

@EmmanuelRoux
Copy link
Author

@nicojs Yes, I think it would be a good option!

@nicojs nicojs added this to the 5.0 milestone Mar 26, 2021
@nicojs
Copy link
Member

nicojs commented Mar 26, 2021

I want to add this (breaking) change to Stryker v5

@nicojs
Copy link
Member

nicojs commented Mar 26, 2021

(I mean #1593)

@nicojs
Copy link
Member

nicojs commented Apr 29, 2021

@EmmanuelRoux I've opened #2848, please take a look. I think that should solve your issue.

I didn't want to go as far as to allow .strykerignore files, as that would add a lot of complexity (multiple .strykerignore files in multiple directories). Instead you can specify ignorePatterns in your stryker.conf.json.

nicojs added a commit that referenced this issue May 3, 2021
Add the ability to specify `ignorePatterns` in your Stryker configuration. This replaces `files` option which is now deprecated.

By specifying `ignorePatterns` you choose which files should not be copied to the Sandbox directory (inside the `.stryker-tmp` directory). This effectively excludes them from being used during mutation testing.

For example:

```json
{
  "ignorePatterns": ["dist"]
}
```

This will discover all files in your current working directory, _except_ for files matching the `"dist"` pattern. Stryker uses [.gitignore](https://git-scm.com/docs/gitignore) rules to resolve these patterns.

Stryker always adds `['.git', 'node_modules', '/reports', 'stryker.log', '.stryker-tmp']` when resolving these patterns. If you really want them in your sandbox, you can un-ignore them using a `!` prefix in your pattern, for example:

```json
{
  "ignorePatterns": ["!node_modules"]
}
```

The `ignorePatterns` is now also the default way files are discovered. Previously, Stryker used `git ls-files --others --exclude-standard --cached --exclude .stryker-tmp` to discover files by default. This had some limitations:

* ❌ It only worked inside a git repository and you had to have `git` installed. If not, you got an error and had to use `files`
* ❌ If a `.gitignore`'d file is needed to run your tests, you needed to fall back on `files`. 

Specifying `files` is now deprecated, but still works for the time being. Stryker will rewrite your file patterns internally to ignore patterns.

Closes #1593
Closes #2739

BREAKING CHANGE: Stryker will no longer use a git command to determine which files belong to your project. Instead, it will rely on sane defaults. You can change this behavior by defining [`ignorePatterns`](https://stryker-mutator.io/docs/stryker-js/configuration/#ignorepatterns-string).

BREAKING CHANGE: The `files` configuration option is deprecated and will be removed in a future release. Please use [`ignorePatterns`](https://stryker-mutator.io/docs/stryker-js/configuration/#ignorepatterns-string) instead.

This:

```json
{
  "files": ["foo.js"]
}
```

Is equivalent to:

```json
{
  "ignorePatterns": ["**", "!foo.js"]
}
```
@nicojs
Copy link
Member

nicojs commented May 7, 2021

Closed with #2848

@nicojs nicojs closed this as completed May 7, 2021
@EmmanuelRoux
Copy link
Author

@EmmanuelRoux I've opened #2848, please take a look. I think that should solve your issue.

I didn't want to go as far as to allow .strykerignore files, as that would add a lot of complexity (multiple .strykerignore files in multiple directories). Instead you can specify ignorePatterns in your stryker.conf.json.

@nicojs Thank you very much for this update, I’ll check that in a few weeks !

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

No branches or pull requests

2 participants