-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor(karma) Remove karma runner * Move karma-runner from stryker repo to stryker-karma-runner * Make the install-module integration test depend on that module * Fix issues in PluginLoader: * Wrong plugin directory * Install only the basename of a module directory * fix(module-integration-test) Set stryker-karma-runner dependency to not-local * fix(module-integration-test) Set karma version * refactor(TestRunnerOrchestrator): Create one test selector for all tests * refactor(TestRunnerOrchestrator) Rename recordCoverage => initialRun * Renamed recordCoverage to initialRun, because it is more logical. There might not be a code coverage report. * feat(NoTestSelector) Initial run in TestRunnerOrchestrator * Make sure the TestRunnerOrchestrator can run the initial test run without testSelector * feat(NoTestSelector) Log correct number of tests in Stryker * feat(NoTestSelector) Make test selector optional for runMutations * fix(deps): Update stryker-api version * Needed to include the testSelector config option * feat(NoTestSelector): Add TestSelectorOrchestrator * The orchestrator is responsible for choosing the correct testSelector based on the testFramework and testSelector options. Also will log warning and debug messages whenever a test selector is chosen. * fixt(module-it) Up the version of stryker-api in IT deps * fix(deps) Update api and karma-runner * feat(NoTestSelector) Improve warning texts * feat(NoTestSelector) Use TestSelectorOrchestrator from Stryker * Make sure we use the configured test selector by using the orchestrator * refactor(testSelectorOrchestrator) Improve debug log * feat(NoTestSelector) Add testSelector to stryker args * docs(readme) Document the use of `testSelector` * fix(testSelector) Add option for testSelector "null" * When passing testSelector via command line arguments, it will always be passed as string. So 'null' as string will now also be interpreted as `null` * fix(dep) Set karma version to 1.0.0 * fix(build): Remove grunt-typings from build
- Loading branch information
Showing
11 changed files
with
472 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import {TestSelectorFactory, TestSelector} from 'stryker-api/test_selector'; | ||
import {StrykerOptions} from 'stryker-api/core'; | ||
import * as log4js from 'log4js'; | ||
|
||
const WARNING_RUNNING_WITHOUT_SELECTOR = 'Stryker will continue without the ability to select individual tests, thus running all test for every generated mutant.'; | ||
const IGNORE_WARNING = 'Set `testSelector` option explicitly to `null` to ignore this warning.'; | ||
const log = log4js.getLogger('TestSelectorOrchestrator'); | ||
|
||
export default class TestSelectorOrchestrator { | ||
|
||
constructor(private options: StrykerOptions) { | ||
} | ||
|
||
determineTestSelector(): TestSelector { | ||
let testSelector: TestSelector = null; | ||
if (this.options.testSelector && this.options.testSelector !== 'null') { | ||
testSelector = this.determineTestSelectorBasedOnTestSelectorSetting(); | ||
} else if (this.options.testSelector === null || this.options.testSelector === 'null') { | ||
log.debug('Running without testSelector (testSelector was null).'); | ||
} else { | ||
if (this.options.testFramework) { | ||
testSelector = this.determineTestSelectorBasedOnTestFrameworkSetting(); | ||
} else { | ||
log.warn(`Missing config settings \`testFramework\` or \`testSelector\`. ${WARNING_RUNNING_WITHOUT_SELECTOR} ${IGNORE_WARNING}`); | ||
} | ||
} | ||
return testSelector; | ||
} | ||
|
||
private determineTestSelectorBasedOnTestSelectorSetting(): TestSelector { | ||
if (this.testSelectorExists(this.options.testSelector)) { | ||
log.debug(`Using testSelector ${this.options.testSelector} based on \`testSelector\` setting`); | ||
return this.createTestSelector(this.options.testSelector); | ||
} else { | ||
log.warn(`Could not find test selector \`${this.options.testSelector}\`. ${WARNING_RUNNING_WITHOUT_SELECTOR} ${this.informAboutKnownTestSelectors()}`); | ||
return null; | ||
} | ||
} | ||
|
||
private determineTestSelectorBasedOnTestFrameworkSetting(): TestSelector { | ||
if (this.testSelectorExists(this.options.testFramework)) { | ||
log.debug(`Using testSelector ${this.options.testFramework} based on \`testFramework\` setting`); | ||
return this.createTestSelector(this.options.testFramework); | ||
} else { | ||
log.warn(`Could not find test selector \`${this.options.testFramework}\` (based on the configured testFramework). ${WARNING_RUNNING_WITHOUT_SELECTOR} ${IGNORE_WARNING} ${this.informAboutKnownTestSelectors()}`); | ||
return null; | ||
} | ||
} | ||
|
||
private informAboutKnownTestSelectors() { | ||
return `Did you forget to load a plugin? Known test selectors: ${JSON.stringify(TestSelectorFactory.instance().knownNames())}.`; | ||
} | ||
|
||
private createTestSelector(name: string) { | ||
return TestSelectorFactory.instance().create(name, this.createSettings()); | ||
} | ||
private testSelectorExists(maybeSelector: string) { | ||
return TestSelectorFactory.instance().knownNames().indexOf(maybeSelector) > -1; | ||
} | ||
|
||
private createSettings() { | ||
return { options: this.options }; | ||
} | ||
} |
Oops, something went wrong.