Skip to content

Commit

Permalink
feat(multi-package): Migrate to multi-package repo (stryker-mutator#257)
Browse files Browse the repository at this point in the history
* refactor(stryker): Add stryker package
* refactor(stryker-api): Add stryker-api package
* Refactor estree types. Instead of extending every type and adding a `nodeID` property, create a new type `type IdentifiedNode = Node & Identified`.
* refactor(travis): Add travis config to lerna root
* docs(readme): Add root project readme
  • Loading branch information
nicojs authored and simondel committed Apr 4, 2017
1 parent 6911a0c commit 0c2fde5
Show file tree
Hide file tree
Showing 200 changed files with 2,564 additions and 502 deletions.
11 changes: 5 additions & 6 deletions .bithoundrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
"wc": { "limit": 3000 }
},
"test": [
"test/**",
"testResources/**"
"packages/**/test/**",
"packages/**/testResources/**"
],
"ignore": [
"src/TestFrameworkOrchestrator.ts",
"src/MutantTestMatcher.ts",
"testResources/config-reader/syntax-error.conf.js"
"ignore": [
"packages/**/Gruntfile.js",
"packages/stryker/testResources/config-reader/syntax-error.conf.js"
],
"dependencies": {
"unused-ignores": [
Expand Down
14 changes: 0 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1 @@
node_modules
/coverage
/testResources/module/coverage
.tscache
.stryker-tmp
reports
typings
*.js.map
src/**/*.js
test/**/*.js
src/**/*.d.ts
test/**/*.d.ts
.idea
*.iml
*.tmp.txt
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,5 @@ node_js:
- "6"
- "4"
before_install:
- npm install -g grunt-cli
- if [[ `npm -v` != 3* ]]; then npm i -g npm@3; fi
install: npm install
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
173 changes: 4 additions & 169 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
*Professor X: For someone who hates mutants... you certainly keep some strange company.*
*William Stryker: Oh, they serve their purpose... as long as they can be controlled.*

## Introduction
For an introduction to mutation testing and Stryker's features, see [stryker-mutator.github.io](http://stryker-mutator.github.io/).

## Getting started
Stryker is a mutation testing framework for JavaScript. It allows you to test your tests by temporarily inserting bugs.

Expand Down Expand Up @@ -60,172 +63,4 @@ Make sure you *at least* specify the `files` and the `testRunner` options when m
See our website for the [list of currently supported mutators](http://stryker-mutator.github.io/mutators.html).

## Configuration
All configuration options can either be set via the command line or via the `stryker.conf.js` config file.

`files` and `mutate` both support globbing expressions using [node glob](https://github.com/isaacs/node-glob).
This is the same globbing format you might know from [Grunt](https://github.com/gruntjs/grunt) or [Karma](https://github.com/karma-runner/karma).
You can *ignore* files by adding an exclamation mark (`!`) at the start of an expression.

#### Files required to run your tests
**Command line:** `[--files|-f] node_modules/a-lib/**/*.js,src/**/*.js,a.js,test/**/*.js`
**Config file:** `files: ['{ pattern: 'src/**/*.js', mutated: true }, '!src/**/index.js', 'test/**/*.js']`
**Default value:** *none*
**Mandatory**: yes
**Description:**
With `files` you specify all files needed to run your tests. If the test runner you use already provides the test framework (Jasmine, Mocha, etc.),
you should *not* include those files here as well.
The files will be loaded in the other in which they are specified.

When using the command line, the list can only contain a comma separated list of globbing expressions.
When using the config file you can provide an array with `string`s or `InputFileDescriptor` objects, like so:

* `string`: The globbing expression used for selecting the files needed to run the tests.
* `InputFileDescriptor` object: `{ pattern: 'pattern', included: true, mutated: false }`:
* The `pattern` property is mandatory and contains the globbing expression used for selecting the files. Using `!` to ignore files is *not* supported here.
* The `included` property is optional and determines whether or not this file should be loaded initially by the test-runner (default: true)
* The `mutated` property is optional and determines whether or not this file should be targeted for mutations (default: false)

*Note*: To include a file/folder which start with an exclamation mark (`!`), use the `InputFileDescriptor` syntax.

#### Source code files to mutate
**Command line:** `[--mutate|-m] src/**/*.js,a.js`
**Config file:** `mutate: ['src/**/*.js', 'a.js']`
**Default value:** *none*
**Mandatory**: no
**Description:**
With `mutate` you configure the subset of files to use for mutation testing. Generally speaking, these should be your own source files.
This is optional, as you can also use the `mutated` property with the `files` parameter or not mutate any files at all to perform a dry-run (test-run).
We expect a comma separated list of globbing expressions, which will be used to select the files to be mutated.

#### Test runner
**Command line:** `--testRunner karma`
**Config file:** `testRunner: 'karma'`
**Default value:** *none*
**Mandatory**: yes
**Description:**
With `testRunner` you specify the test runner to run your tests. This option is required.
Make sure the test runner plugin for Stryker is installed. E.g. we need the `stryker-karma-runner` to use `karma` as a test runner.
See the [list of plugins](http://stryker-mutator.github.io/plugins.html) for an up-to-date list of supported test runners and plugins.

#### Test framework
**Command line:** `--testFramework jasmine`
**Config file:** `testFramework: 'jasmine'`
**Default value:** *none*
**Mandatory**: yes
**Description:**
With `testFramework` you configure which test framework your tests are using. This value is directly consumed by the test runner and therefore
depends what framework that specific test runner supports. By default, this value is also used for `testFramework`.

#### Type of coverage analysis
**Full notation:** `--coverageAnalysis perTest`
**Config file key:** `coverageAnalysis: 'perTest'`
**Default value:** `perTest`
**Mandatory**: no
**Description:**
With `coverageAnalysis` you specify which coverage analysis strategy you want to use.
Stryker can analyse code coverage results. This can potentially speed up mutation testing a lot, as only the tests covering a
particular mutation are tested for each mutant.
This does *not* influence the resulting mutation testing score. It only improves performance, so we enable it by default.

The possible values are:
* **off**: Stryker will not determine the code covered by tests during the initial test run phase. All tests will be executed for each mutant
during the mutation testing phase.

* **all**: Stryker will determine the code covered by all tests during the initial test run phase. Only mutants actually covered by your
test suite are tested during the mutation testing phase. This setting requires your test runner to be able to report the code coverage back to Stryker.
Currently, only the `stryker-mocha-runner` and the `stryker-karma-runner` do this.

* **perTest**: Stryker will determine the code covered by your test per executed test during the initial test run phase. Only mutants actually covered by your
test suite are tested during the mutation testing phase.
Only the tests that cover a particular mutant are tested for each one. This requires your tests to be able to run independently of each other and in random order.
In addition to requiring your test runner to be able to report the code coverage back to Stryker, your chosen `testFramework` also needs to support running code
before and after each test, as well as test filtering.
Currently, `stryker-mocha-runner` as well as `stryker-karma-runner` support this. However, `stryker-karma-runner` support is limited to using it with `Jasmine` as the test framework
(`Mocha` is not yet supported).

#### Reporters
**Command line:** `--reporter clear-text,progress,dots`
**Config file:** `reporter: ['clear-text', 'progress', 'dots']`
**Default value:** `['clear-text', 'progress']`
**Mandatory**: no
**Description:**
With `reporter` you can set a reporter or group of reporters for stryker to use.
These reporters can be used out of the box: `clear-text`, `progress` and `event-recorder`.
By default `clear-text` and `progress` are active if no reporter is configured.
You can load additional plugins to get more reporters. See [stryker-mutator.github.io](http://stryker-mutator.github.io)
for an up-to-date list of supported reporter plugins and a description on each reporter.

The `clear-text` reporter supports an additional config option to show more tests that were executed to kill a mutant. The config for your config file is: `clearTextReporter: { maxTestsToLog: 3 },`

#### Plugins
**Command line:** `--plugins stryker-html-reporter,stryker-karma-runner`
**Config file:** `plugins: ['stryker-html-reporter', 'stryker-karma-runner']`
**Default value:** `['stryker-*']`
**Mandatory**: no
**Description:**
With `plugins` you can add additional Node modules for Stryker to load (or `require`).
By default, all `node_modules` starting with `stryker-` will be loaded, so you would normally not need to specify this option.
These modules should be installed right next to stryker. For a current list of plugins,
you can consult [npm](https://www.npmjs.com/search?q=%40stryker-plugin) or
[stryker-mutator.github.io](http://stryker-mutator.github.io).

#### Start of port range for test runners
**Command line:** `--port 9234`
**Config file:** `port: 9234`
**Default value:** `9234`
**Mandatory**: no
**Description:**
With `port` you specify the first port to pass on to the test runner to use. Any additional test runners will be spawned using ports n+1, n+2, etc.
For example, when you set to use port 9234 and Stryker decides to start four test runner processes, ports 9234, 9235, 9236 and 9237 will be passed to the test runner.
If the test runner decides to use the port it should be available for use.

#### Global timeout in milliseconds
**Command line:** `--timeoutMs 5000`
**Config file:** `timeoutMs: 5000`
**Default value:** `5000`
**Mandatory**: no
**Description:**
When Stryker is mutating code, it cannot determine indefinitely whether or not a code mutation results in an infinite loop (see [Halting problem](https://en.wikipedia.org/wiki/Halting_problem)).
In order to battle infinite loops, a test run gets killed after a certain period. This period is configurable with two settings: `timeoutMs` and `timeoutFactor`.
To calculate the actual timeout in milliseconds the, following formula is used:

```
timeoutForTestRunMs = timeOfTheInitialTestRunMs * timeoutFactor + timeoutMs
```

With `timeoutFactor` you can configure the allowed deviation relative to the time of a normal test run. Tweak this if you notice that mutants are prone to creating slower code, but not infinite loops.
`timeoutMs` let's you configure an absolute deviation. Use it, if you run Stryker on a busy machine and you need to wait longer to make sure that the code indeed entered an infinite loop.

#### Timeout factor
**Command line:** `--timeoutFactor 1.5`
**Config file:** `timeoutFactor: 1.5`
**Default value:** `1.5`
**Mandatory**: no
**Description:**
See [Timeout in milliseconds](#Timeout-in-milliseconds).

#### Number of maximum concurrent test runners
**Command line:** `--maxConcurrentTestRunners 3`
**Config file:** `maxConcurrentTestRunners: 3`
**Default value:** number of CPU cores
**Mandatory**: no
**Description:**
Specifies the maximum number of concurrent test runners to spawn.
Mutation testing is time consuming. By default Stryker tries to make the most of your CPU, by spawning as many test runners as you have CPU cores.
This setting allows you to override this default behavior.

Reasons you might want to lower this setting:

* Your test runner starts a browser (another CPU-intensive process)
* You're running on a shared server and/or
* Your hard disk cannot handle the I/O of all test runners

#### Log level
**Command line:** `--logLevel info`
**Config file:** `logLevel: 'info'`
**Default value:** `info`
**Mandatory**: no
**Description:**
Set the `log4js` log level that Stryker uses (default is `info`). Possible values: `fatal`, `error`, `warn`, `info`, `debug`, `trace`, `all` and `off`.
*Note*: Test runners are run as child processes of the Stryker Node process. All output (stdout) of the `testRunner` is logged as `trace`.
Thus, to see logging output from the test runner set the `logLevel` to `all` or `trace`.
See the [stryker's package readme](https://github.com/stryker-mutator/stryker/packages/stryker/README.md#Configuration) for all config options.
7 changes: 7 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"lerna": "2.0.0-beta.38",
"packages": [
"packages/*"
],
"version": "independent"
}
126 changes: 8 additions & 118 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,122 +1,12 @@
{
"name": "stryker",
"version": "0.5.9",
"description": "The extendable JavaScript mutation testing framework",
"main": "src/Stryker.js",
"typings": "src/Stryker.d.ts",
"scripts": {
"test": "grunt test",
"start": "tsc -w",
"sample": "node src/stryker-cli.js --configFile testResources/sampleProject/stryker.conf.js",
"preversion": "grunt",
"clean": "grunt clean",
"jshint": "grunt jshint",
"tslint": "grunt tslint",
"coverage": "grunt coverage",
"intergration": "grunt intergration",
"build": "grunt build",
"serve": "grunt serve",
"watch-test": "grunt watch-test",
"release": "grunt release"
},
"repository": {
"type": "git",
"url": "https://github.com/stryker-mutator/stryker"
},
"engines": {
"node": ">=4"
},
"keywords": [
"mutation testing",
"mutation",
"testing",
"test",
"js",
"stryker"
],
"author": "Simon de Lang",
"contributors": [
"Simon de Lang <[email protected]>",
"Nico Jansen <[email protected]>",
"Sander Koenders <[email protected]>",
"global <[email protected]>",
"Philipp Weissenbacher <[email protected]>",
"Jasper Catthoor <[email protected]>",
"Nico Stapelbroek <[email protected]>",
"Alex van Assem <[email protected]>",
"Jelle Peters <[email protected]>",
"Jeremy Nagel <[email protected]>",
"MarktHart <[email protected]>",
"Michael Williamson <[email protected]>",
"Willem Meints <[email protected]>"
],
"license": "Apache-2.0",
"bin": {
"stryker": "./bin/stryker"
},
"dependencies": {
"chalk": "^1.1.1",
"commander": "^2.9.0",
"es6-promise-pool": "^2.4.4",
"escodegen": "^1.8.0",
"esprima": "^2.7.0",
"glob": "^7.0.3",
"graceful-fs": "^4.1.11",
"istanbul": "^0.4.5",
"lodash": "^4.17.4",
"log4js": "^1.1.0",
"mkdirp": "^0.5.1",
"progress": "^1.1.8",
"serialize-javascript": "^1.3.0",
"tslib": "^1.5.0"
},
"private": true,
"devDependencies": {
"@types/chai-as-promised": "0.0.29",
"@types/chalk": "^0.4.28",
"@types/escodegen": "0.0.6",
"@types/esprima": "^2.1.31",
"@types/estree": "0.0.32",
"@types/glob": "^5.0.29",
"@types/graceful-fs": "^2.0.29",
"@types/istanbul": "^0.4.29",
"@types/karma": "^0.13.32",
"@types/lodash": "^4.14.34",
"@types/log4js": "0.0.32",
"@types/mkdirp": "^0.3.28",
"@types/mocha": "^2.2.34",
"@types/progress": "^1.1.28",
"@types/sinon": "^1.16.33",
"@types/sinon-as-promised": "^4.0.5",
"@types/sinon-chai": "^2.7.27",
"chai": "^3.4.1",
"chai-as-promised": "^6.0.0",
"grunt": "^1.0.1",
"grunt-bump": "^0.8.0",
"grunt-cli": "^1.2.0",
"grunt-contrib-clean": "^1.0.0",
"grunt-contrib-jshint": "^1.0.0",
"grunt-contrib-watch": "^1.0.0",
"grunt-conventional-changelog": "^6.1.0",
"grunt-mocha-istanbul": "^5.0.1",
"grunt-mocha-test": "^0.13.2",
"grunt-npm": "0.0.2",
"grunt-ts": "^6.0.0-beta.3",
"grunt-tslint": "^4.0.0",
"jasmine-core": "^2.4.1",
"karma": "1.0.0",
"karma-coverage": "^1.0.0",
"karma-jasmine": "^1.0.2",
"karma-phantomjs-launcher": "^1.0.1",
"load-grunt-tasks": "^3.5.0",
"mocha": "^3.2.0",
"sinon": "^1.17.2",
"sinon-as-promised": "^4.0.2",
"sinon-chai": "^2.8.0",
"stryker-api": "^0.5.0-rc0",
"tslint": "^4.4.2",
"typescript": "~2.2.1"
"lerna": "^2.0.0-beta.38",
"typescript": "^2.2.1"
},
"peerDependencies": {
"stryker-api": "^0.5.0-rc0"
"scripts": {
"postinstall": "lerna bootstrap",
"build": "lerna run build",
"test": "lerna run test"
}
}
}
File renamed without changes.
14 changes: 14 additions & 0 deletions packages/stryker-api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
node_modules
npm-debug.log
coverage
.tscache
typings
*.js.map
src/**/*.js
test/**/*.js
src/**/*.d.ts
test/**/*.d.ts
*.js
*.d.ts
!Gruntfile.js
!testResources
9 changes: 9 additions & 0 deletions packages/stryker-api/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.ts
!*.d.ts
*.js.map
Gruntfile.js
test
tsconfig.json
typings.json
testResources
typings
Loading

0 comments on commit 0c2fde5

Please sign in to comment.