Skip to content

Commit

Permalink
test(mutation): fix mutation testing workflow (#2046)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicojs committed Feb 15, 2020
1 parent 49c5162 commit 2ab176d
Show file tree
Hide file tree
Showing 34 changed files with 72 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Expand Up @@ -60,7 +60,7 @@ module.exports = {
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-parameter-properties': 'off',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-this-alias': 'off',
Expand Down
42 changes: 4 additions & 38 deletions .github/workflows/mutation-testing.yml
Expand Up @@ -5,8 +5,6 @@ on:
branches:
- master
- test/**
paths:
- 'packages/**/*.ts'

jobs:
core:
Expand All @@ -21,9 +19,7 @@ jobs:
npm install
npm run build
- name: Run Stryker
run: |
cd packages/core
npm run stryker
run: npx lerna run --scope "@stryker-mutator/core" --concurrency 1 --stream stryker
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}

Expand All @@ -40,17 +36,7 @@ jobs:
npm install
npm run build
- name: Run Stryker
run: |
cd packages/api
npm run stryker
cd ../babel-transpiler
npm run stryker
cd ../html-reporter
npm run stryker
cd ../jasmine-framework
npm run stryker
cd ../javascript-mutator
npm run stryker
run: npx lerna run --scope "@stryker-mutator/{api,babel-transpiler,jasmine-framework,javascript-mutator}" --concurrency 1 --stream stryker
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}

Expand All @@ -67,17 +53,7 @@ jobs:
npm install
npm run build
- name: Run Stryker
run: |
cd packages/jasmine-runner
npm run stryker
cd ../jest-runner
npm run stryker
cd ../karma-runner
npm run stryker
cd ../mocha-framework
npm run stryker
cd ../mocha-runner
npm run stryker
run: npx lerna run --scope "@stryker-mutator/{jasmine-runner,jest-runner,karma-runner,mocha-framework,mocha-runner}" --concurrency 1 --stream stryker
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}

Expand All @@ -94,16 +70,6 @@ jobs:
npm install
npm run build
- name: Run Stryker
run: |
cd packages/typescript
npm run stryker
cd ../vue-mutator
npm run stryker
cd ../webpack-transpiler
npm run stryker
cd ../wct-runner
npm run stryker
cd ../util
npm run stryker
run: npx lerna run --scope "@stryker-mutator/{typescript,vue-mutator,webpack-transpiler,wct-runner,util}" --concurrency 1 --stream stryker
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -10,7 +10,7 @@
"@types/lodash": "^4.14.110",
"@types/mkdirp": "1.0.0",
"@types/mocha": "^2.2.44",
"@types/node": "^10.11.5",
"@types/node": "^13.7.1",
"@types/rimraf": "2.0.3",
"@types/sinon": "5.0.5",
"@types/sinon-chai": "3.2.3",
Expand Down
1 change: 1 addition & 0 deletions packages/api/package.json
Expand Up @@ -43,6 +43,7 @@
"tslib": "~1.10.0"
},
"devDependencies": {
"@types/node": "^13.7.1",
"surrial": "~1.0.0",
"typed-inject": "~2.1.1"
}
Expand Down
14 changes: 11 additions & 3 deletions packages/api/stryker.conf.js
@@ -1,7 +1,15 @@
const { execSync } = require('child_process');
const path = require('path');
const settings = require('../../stryker.parent.conf');
const moduleName = __dirname.split(path.sep).pop();
settings.dashboard.module = moduleName;
module.exports = function (config) {
config.set(settings);
};

// Add src-generated to the files list, since it isn't in git
const files = execSync('git ls-files --others --exclude-standard --cached --exclude .stryker-tmp')
.toString()
.split('\n')
.map(file => file.trim())
.filter(Boolean);
files.push('src-generated/**/*.*');
settings.files = files;
module.exports = settings;
1 change: 1 addition & 0 deletions packages/babel-transpiler/package.json
Expand Up @@ -66,6 +66,7 @@
"@types/babel__traverse": "~7.0.5",
"@types/glob": "~7.1.0",
"@types/minimatch": "~3.0.3",
"@types/node": "^13.7.1",
"babel-plugin-transform-es2015-spread": "~6.22.0",
"glob": "~7.1.2"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Expand Up @@ -85,7 +85,7 @@
"@types/istanbul-lib-instrument": "~1.7.0",
"@types/lodash.flatmap": "^4.5.6",
"@types/lodash.groupby": "^4.6.6",
"@types/node": "~10.17.13",
"@types/node": "^13.7.1",
"@types/progress": "~2.0.1",
"flatted": "^2.0.0"
}
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/test-runner/CommandTestRunner.ts
Expand Up @@ -59,10 +59,10 @@ export default class CommandTestRunner implements TestRunner {
const result = completeResult(code, timer);
handleResolve(result);
});
childProcess.stdout.on('data', chunk => {
childProcess.stdout!.on('data', chunk => {
output.push(chunk);
});
childProcess.stderr.on('data', chunk => {
childProcess.stderr!.on('data', chunk => {
output.push(chunk);
});

Expand All @@ -78,8 +78,8 @@ export default class CommandTestRunner implements TestRunner {
};

function removeAllListeners() {
childProcess.stderr.removeAllListeners();
childProcess.stdout.removeAllListeners();
childProcess.stderr!.removeAllListeners();
childProcess.stdout!.removeAllListeners();
childProcess.removeAllListeners();
}

Expand Down
Expand Up @@ -36,7 +36,7 @@ describe(ChildProcessProxyWorker.name, () => {
let processRemoveListenerStub: sinon.SinonStub;
let processChdirStub: sinon.SinonStub;
let logMock: Mock<Logger>;
let originalProcessSend: undefined | NodeJS.MessageListener;
let originalProcessSend: typeof process.send;
let processes: NodeJS.MessageListener[];
const workingDir = 'working dir';

Expand Down
3 changes: 2 additions & 1 deletion packages/grunt-stryker/package.json
Expand Up @@ -33,7 +33,8 @@
},
"main": "Gruntfile.js",
"devDependencies": {
"@stryker-mutator/api": "^2.5.0"
"@stryker-mutator/api": "^2.5.0",
"@types/node": "^13.7.1"
},
"peerDependencies": {
"@stryker-mutator/core": "^2.0.0",
Expand Down
8 changes: 5 additions & 3 deletions packages/html-reporter/package.json
Expand Up @@ -3,8 +3,7 @@
"version": "2.5.0",
"description": "An html reporter for the JavaScript mutation testing framework Stryker",
"main": "src/index.js",
"scripts": {
},
"scripts": {},
"repository": {
"type": "git",
"url": "https://github.com/stryker-mutator/stryker.git"
Expand All @@ -31,5 +30,8 @@
"contributors": [
"Nico Jansen <jansennico@gmail.com>",
"Simon de Lang <simondelang@gmail.com>"
]
],
"devDependencies": {
"@types/node": "^13.7.1"
}
}
3 changes: 3 additions & 0 deletions packages/jasmine-framework/package.json
Expand Up @@ -38,5 +38,8 @@
"contributors": [],
"engines": {
"node": ">=8"
},
"devDependencies": {
"@types/node": "^13.7.1"
}
}
3 changes: 2 additions & 1 deletion packages/jasmine-runner/package.json
Expand Up @@ -41,7 +41,8 @@
},
"devDependencies": {
"@stryker-mutator/jasmine-framework": "^2.5.0",
"@stryker-mutator/test-helpers": "^2.5.0"
"@stryker-mutator/test-helpers": "^2.5.0",
"@types/node": "^13.7.1"
},
"dependencies": {
"@stryker-mutator/api": "^2.5.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/jasmine-runner/test/unit/JasmineTestRunner.spec.ts
Expand Up @@ -54,8 +54,8 @@ describe('JasmineTestRunner', () => {
});

it('should clear require cache on run', async () => {
require.cache['foo.js'] = 'foo';
require.cache['bar.js'] = 'bar';
require.cache['foo.js'] = 'foo' as any;
require.cache['bar.js'] = 'bar' as any;
await actRunWithoutTests();
expect(require.cache['foo.js']).not.ok;
expect(require.cache['bar.js']).not.ok;
Expand Down
3 changes: 2 additions & 1 deletion packages/javascript-mutator/package.json
Expand Up @@ -51,6 +51,7 @@
"@stryker-mutator/test-helpers": "^2.5.0",
"@types/babel__generator": "^7.0.0",
"@types/babel__traverse": "^7.0.0",
"@types/lodash.clonedeep": "^4.5.6"
"@types/lodash.clonedeep": "^4.5.6",
"@types/node": "^13.7.1"
}
}
1 change: 1 addition & 0 deletions packages/jest-runner/package.json
Expand Up @@ -39,6 +39,7 @@
"homepage": "https://github.com/stryker-mutator/stryker/tree/master/packages/jest-runner#readme",
"devDependencies": {
"@stryker-mutator/test-helpers": "^2.5.0",
"@types/node": "^13.7.1",
"@types/semver": "~7.1.0",
"jest": "^25.1.0",
"react": "~16.12.0",
Expand Down
Expand Up @@ -2,6 +2,7 @@ import fs = require('fs');
import path from 'path';

import JestConfigLoader from './JestConfigLoader';
import { NodeRequireFunction } from './NodeRequireFunction';

/**
* The Default config loader will load the Jest configuration using the package.json in the package root
Expand Down
@@ -0,0 +1 @@
export type NodeRequireFunction = (moduleName: string) => any;
2 changes: 2 additions & 0 deletions packages/karma-runner/package.json
Expand Up @@ -33,9 +33,11 @@
"homepage": "https://github.com/stryker-mutator/stryker/tree/master/packages/karma-runner#readme",
"devDependencies": {
"@stryker-mutator/jasmine-framework": "^2.5.0",
"@stryker-mutator/mocha-framework": "^2.5.0",
"@stryker-mutator/test-helpers": "^2.5.0",
"@stryker-mutator/util": "^2.5.0",
"@types/express": "~4.17.0",
"@types/node": "^13.7.1",
"@types/semver": "~7.1.0",
"jasmine-core": "~3.5.0",
"karma": "~4.1.0",
Expand Down
Expand Up @@ -3,14 +3,14 @@ import * as http from 'http';

import { CoverageCollection, RunResult, RunStatus, TestStatus } from '@stryker-mutator/api/test_runner';
import JasmineTestFramework from '@stryker-mutator/jasmine-framework/src/JasmineTestFramework';
import MochaTestFramework from '@stryker-mutator/mocha-framework/src/MochaTestFramework';
import { testInjector } from '@stryker-mutator/test-helpers';
import { expect } from 'chai';
import { FilePattern } from 'karma';
import { TestSelection } from '@stryker-mutator/api/test_framework';

import KarmaTestRunner from '../../src/KarmaTestRunner';
import { expectTestResults } from '../helpers/assertions';
import MochaTestFramework from '../../../mocha-framework/src/MochaTestFramework';

function wrapInClosure(codeFragment: string) {
return `
Expand Down
1 change: 1 addition & 0 deletions packages/mocha-framework/package.json
Expand Up @@ -36,6 +36,7 @@
"homepage": "https://github.com/stryker-mutator/stryker/tree/master/packages/mocha-framework#readme",
"license": "Apache-2.0",
"devDependencies": {
"@types/node": "^13.7.1",
"tslib": "~1.10.0"
},
"peerDependencies": {
Expand Down
4 changes: 3 additions & 1 deletion packages/mocha-runner/package.json
Expand Up @@ -41,9 +41,11 @@
"tslib": "~1.10.0"
},
"devDependencies": {
"@stryker-mutator/core": "^2.5.0",
"@stryker-mutator/mocha-framework": "^2.5.0",
"@stryker-mutator/test-helpers": "^2.5.0",
"@types/multimatch": "~4.0.0",
"@stryker-mutator/mocha-framework": "^2.5.0"
"@types/node": "^13.7.1"
},
"peerDependencies": {
"@stryker-mutator/core": "^2.0.0",
Expand Down
@@ -1,14 +1,14 @@
import * as path from 'path';

import { expect } from 'chai';
import { TestSelection } from '@stryker-mutator/api/test_framework';
import { TestStatus, RunStatus } from '@stryker-mutator/api/test_runner';
import { expect } from 'chai';
import { LoggingServer, testInjector } from '@stryker-mutator/test-helpers';
import MochaTestFramework from '@stryker-mutator/mocha-framework/src/MochaTestFramework';
import ChildProcessProxy from '@stryker-mutator/core/src/child-proxy/ChildProcessProxy';
import { LogLevel } from '@stryker-mutator/api/core';
import { commonTokens } from '@stryker-mutator/api/plugin';

import ChildProcessProxy from '../../../core/src/child-proxy/ChildProcessProxy';
import { MochaTestRunner } from '../../src/MochaTestRunner';

const test0: Readonly<TestSelection> = Object.freeze({
Expand Down
6 changes: 3 additions & 3 deletions packages/mocha-runner/test/unit/MochaTestRunner.spec.ts
Expand Up @@ -217,9 +217,9 @@ describe(MochaTestRunner.name, () => {
sut = createSut({ fileNames: ['foo.js', 'bar.js'] });
discoveredFiles.push('foo.js'); // should still purge 'bar.js'
sut.init();
require.cache['foo.js'] = 'foo';
require.cache['bar.js'] = 'bar';
require.cache['baz.js'] = 'baz';
require.cache['foo.js'] = 'foo' as any;
require.cache['bar.js'] = 'bar' as any;
require.cache['baz.js'] = 'baz' as any;

// Act
await actRun();
Expand Down
5 changes: 4 additions & 1 deletion packages/mutator-specification/package.json
Expand Up @@ -18,5 +18,8 @@
"node": ">=8"
},
"homepage": "https://github.com/stryker-mutator/stryker/tree/master/packages/javascript-mutator#readme",
"license": "Apache-2.0"
"license": "Apache-2.0",
"devDependencies": {
"@types/node": "^13.7.1"
}
}
1 change: 1 addition & 0 deletions packages/test-helpers/package.json
Expand Up @@ -21,6 +21,7 @@
},
"devDependencies": {
"@stryker-mutator/api": "^2.5.0",
"@types/node": "^13.7.1",
"typed-inject": "~2.1.1"
}
}
1 change: 1 addition & 0 deletions packages/typescript/package.json
Expand Up @@ -45,6 +45,7 @@
"@stryker-mutator/mutator-specification": "^2.5.0",
"@stryker-mutator/test-helpers": "^2.5.0",
"@types/lodash.flatmap": "~4.5.3",
"@types/node": "^13.7.1",
"@types/semver": "~7.1.0",
"surrial": "~1.0.0"
},
Expand Down
5 changes: 4 additions & 1 deletion packages/util/package.json
Expand Up @@ -24,5 +24,8 @@
"bugs": {
"url": "https://github.com/stryker-mutator/stryker/issues"
},
"homepage": "https://github.com/stryker-mutator/stryker/tree/master/packages/util#readme"
"homepage": "https://github.com/stryker-mutator/stryker/tree/master/packages/util#readme",
"devDependencies": {
"@types/node": "^13.7.1"
}
}
1 change: 1 addition & 0 deletions packages/vue-mutator/package.json
Expand Up @@ -36,6 +36,7 @@
"@stryker-mutator/javascript-mutator": "^2.5.0",
"@stryker-mutator/test-helpers": "^2.5.0",
"@stryker-mutator/typescript": "^2.5.0",
"@types/node": "^13.7.1",
"vue-template-compiler": "^2.0.0"
},
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/wct-runner/package.json
Expand Up @@ -27,6 +27,7 @@
},
"devDependencies": {
"@stryker-mutator/test-helpers": "^2.5.0",
"@types/node": "^13.7.1",
"@types/socket.io": "^2.1.0",
"chai": "~4.2.0",
"mocha": "~5.2.0",
Expand Down
1 change: 1 addition & 0 deletions packages/webpack-transpiler/package.json
Expand Up @@ -37,6 +37,7 @@
"devDependencies": {
"@stryker-mutator/test-helpers": "^2.5.0",
"@types/memory-fs": "~0.3.0",
"@types/node": "^13.7.1",
"@types/webpack": "~4.41.0",
"raw-loader": "~4.0.0",
"webpack": "~4.41.0"
Expand Down

0 comments on commit 2ab176d

Please sign in to comment.