Skip to content

Commit

Permalink
fix(validation): don't warn about the commandRunner options
Browse files Browse the repository at this point in the history
  • Loading branch information
nicojs committed Jul 3, 2020
1 parent 8aa2b8f commit 2128b9a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
16 changes: 16 additions & 0 deletions packages/api/schema/stryker-core.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
"description": "JSON schema for the Stryker Mutator configuration file",
"type": "object",
"definitions": {
"commandRunnerOptions": {
"title": "CommandRunnerOptions",
"type": "object",
"properties": {
"command": {
"description": "The command to test each mutant. For example \"npm run mocha\". Defaults to \"npm test\".",
"type": "string",
"default": "npm test"
}
}
},
"logLevel": {
"title": "LogLevel",
"type": "string",
Expand Down Expand Up @@ -200,6 +211,11 @@
"type": "boolean",
"default": true
},
"commandRunner": {
"description": "Options used by the command test runner. Note: these options will only be used when the command test runner is activated (this is the default)",
"$ref": "#/definitions/commandRunnerOptions",
"default": {}
},
"coverageAnalysis": {
"description": "Indicates which coverage analysis strategy to use. During mutation testing, stryker will try to only run the tests that cover a particular line of code.\n\n'perTest': Analyse coverage per test.\n'all': Analyse the coverage for the entire test suite.\n'off' (default): Don't use coverage analysis",
"type": "string",
Expand Down
15 changes: 3 additions & 12 deletions packages/core/src/test-runner/CommandTestRunner.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import { exec } from 'child_process';
import * as os from 'os';

import { StrykerOptions } from '@stryker-mutator/api/core';
import { StrykerOptions, CommandRunnerOptions } from '@stryker-mutator/api/core';
import { RunResult, RunStatus, TestRunner, TestStatus } from '@stryker-mutator/api/test_runner';
import { errorToString } from '@stryker-mutator/util';

import { kill } from '../utils/objectUtils';
import Timer from '../utils/Timer';

export interface CommandRunnerSettings {
command: string;
}

/**
* A test runner that uses a (bash or cmd) command to execute the tests.
* Does not know hom many tests are executed or any code coverage results,
Expand All @@ -32,17 +28,12 @@ export default class CommandTestRunner implements TestRunner {
return this.runnerName === name.toLowerCase();
}

private readonly settings: CommandRunnerSettings;
private readonly settings: CommandRunnerOptions;

private timeoutHandler: undefined | (() => Promise<void>);

constructor(private readonly workingDir: string, options: StrykerOptions) {
this.settings = Object.assign(
{
command: 'npm test',
},
options.commandRunner
);
this.settings = options.commandRunner;
}

public run(): Promise<RunResult> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { RunStatus, TestStatus } from '@stryker-mutator/api/test_runner';
import { factory } from '@stryker-mutator/test-helpers';
import { expect } from 'chai';
import * as sinon from 'sinon';
import { CommandRunnerOptions } from '@stryker-mutator/api/core';

import CommandTestRunner, { CommandRunnerSettings } from '../../../src/test-runner/CommandTestRunner';
import CommandTestRunner from '../../../src/test-runner/CommandTestRunner';
import * as objectUtils from '../../../src/utils/objectUtils';

describe(`${CommandTestRunner.name} integration`, () => {
Expand Down Expand Up @@ -48,7 +49,7 @@ describe(`${CommandTestRunner.name} integration`, () => {
expect(killSpy).called;
});

function createSut(settings?: CommandRunnerSettings) {
function createSut(settings?: CommandRunnerOptions) {
const strykerOptions = factory.strykerOptions();
if (settings) {
strykerOptions.commandRunner = settings;
Expand Down
5 changes: 3 additions & 2 deletions packages/core/test/unit/test-runner/CommandTestRunner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import { errorToString } from '@stryker-mutator/util';
import { expect } from 'chai';
import * as sinon from 'sinon';
import { factory } from '@stryker-mutator/test-helpers';
import { CommandRunnerOptions } from '@stryker-mutator/api/core';

import CommandTestRunner, { CommandRunnerSettings } from '../../../src/test-runner/CommandTestRunner';
import CommandTestRunner from '../../../src/test-runner/CommandTestRunner';
import * as objectUtils from '../../../src/utils/objectUtils';
import Timer, * as timerModule from '../../../src/utils/Timer';
import ChildProcessMock from '../../helpers/ChildProcessMock';
Expand Down Expand Up @@ -120,7 +121,7 @@ describe(CommandTestRunner.name, () => {
return resultPromise;
}

function createSut(settings?: CommandRunnerSettings, workingDir = 'workingDir') {
function createSut(settings?: CommandRunnerOptions, workingDir = 'workingDir') {
const strykerOptions = factory.strykerOptions();
if (settings) {
strykerOptions.commandRunner = settings;
Expand Down

0 comments on commit 2128b9a

Please sign in to comment.