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

feat(plugin): allow fileDescriptions to be injected #3582

Merged
merged 7 commits into from
Jun 23, 2022

Conversation

nicojs
Copy link
Member

@nicojs nicojs commented Jun 23, 2022

Allow fileDescriptions to be injected in plugins. File descriptions allow plugins to act on the file names discovered in the project under test (excluding any ignored files).

A FileDescriptions object contains file names as keys and a new FileDescription as a value. A file description currently only houses a mutate property (of type MutationDescription).

class MyChecker {
  static inject = [commonTokens.fileDescriptions] as const;
  constructor(fileDescriptions: FileDescriptions) { }
}

Also did some housekeeping.

  • Previously, StrykerJS would load all project files (excluding ignored files, like node_modules) into memory. This is now no longer the case, only the files being mutated (or otherwise needed) are loaded, and the rest are copied (using fs.promises.copyFile) to the sandbox. This is both a small performance improvement as well as a big memory improvement.\
  • Replaced the InputFileResolver and InputFileCollection with ProjectReader and Project abstractions. Also added a ProjectFile, responsible for keeping the in-memory state of a file.
  • Removed some unused interfaces from the @stryker-mutator/util
  • Slightly changed the API for @stryker-mutator/instrumenter. This is technically a breaking change, but since this package is not meant for public consumption this is not needed for a major version bump.
  • FIxed a small unrelated bug: Stryker instrumenter disable type checking doesn't insert @ts-nocheck after the jest env for subsequent files #3583

This PR is needed to finish #3474
Fixes #3583

nicojs added 7 commits June 11, 2022 15:24
Allow `fileDescriptions` to be injected in plugins. File descriptions allow plugins to act on the file names discovered in the project (excluding any ignored files).

A `FileDescriptions` object contain file names as keys and a new `FileDescription` as value. A file description currently only houses a `mutate` property (of type `MutationDescription`).

```ts
class MyChecker {
  static inject = [commonTokens.fileDescriptions] as const;
  constructor(fileDescriptions: FileDescriptions) { }
}
```
@nicojs nicojs enabled auto-merge (squash) June 23, 2022 21:34
@nicojs nicojs merged commit fa2b77e into master Jun 23, 2022
@nicojs nicojs deleted the feat/input-file-collection branch June 23, 2022 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stryker instrumenter disable type checking doesn't insert @ts-nocheck after the jest env for subsequent files
1 participant