-
Notifications
You must be signed in to change notification settings - Fork 188
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(baseline): Allow force creating fresh baseline #2124
base: master
Are you sure you want to change the base?
Changes from 41 commits
853cbd9
dc5686f
e986e68
89b9cb6
5c7705d
68d4e39
67db04d
4871f39
36a4ce9
e180534
f1f6cf3
7dd8a89
e44bb01
9ebf7f7
e1b4d14
ca9b354
60d6d41
02193a7
8f39401
938920d
dc0f060
4d5303b
97d5c54
0d9a5e6
b530afa
4f6c3cc
a02f5c9
548d06b
ef6392f
552c9a3
0d62dda
e51eebd
937f26f
d0fa85a
d7ac653
079311a
e87f5bb
4c21604
1202182
0380d09
0ba1d08
0dc89f4
20cab04
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -452,7 +452,7 @@ Config file: `"since": { }` | |||||
|
||||||
Use git information to test only code changes since the given target. Stryker will only report on mutants within the changed code. All other mutants will not have a result. | ||||||
|
||||||
If you wish to test only changed sources and tests but would like to have a complete mutation report see [with-baseline](#with-baseline-flag-committish). | ||||||
If you wish to test only changed sources and tests but would like to have a complete mutation report see [with-baseline](#with-baseline-committish). | ||||||
|
||||||
Set the diffing target on the command line by passing a committish with the since flag in the format `--since:<committish>`. | ||||||
Set the diffing target in the config file by setting the [since target](#sincetarget-committish) option. | ||||||
|
@@ -492,36 +492,26 @@ Use [globbing syntax](https://en.wikipedia.org/wiki/Glob_(programming)) for wild | |||||
|
||||||
## Baseline | ||||||
|
||||||
### `with-baseline` <`flag`> [`:committish`] | ||||||
### `with-baseline` <`committish`> | ||||||
|
||||||
Default: `false` | ||||||
Command line: `--with-baseline:feat-2` | ||||||
Config file: `"baseline": { }` | ||||||
Command line: `with-baseline feat-2` | ||||||
Config file: `"baseline": { }` | ||||||
|
||||||
Enabling `with-baseline` saves the mutation report to a storage location such as the filesystem. The mutation report is loaded at the start of the next mutation run. Any changed source code or unit test results in a reset of the mutants affected by the change. For unchanged mutants the previous result is reused. This feature expands on the [since](#since-flag-committish) feature by providing you with a full report after a partial mutation testrun. | ||||||
Enabling `baseline`, alias `with-baseline`, saves the mutation report to a storage location such as the filesystem. The mutation report is loaded at the start of the next mutation run. Any changed source code or unit test results in a reset of the mutants affected by the change. For unchanged mutants the previous result is reused. This feature expands on the [since](#since-flag-committish) feature by providing you with a full report after a partial mutation testrun. The target of the baseline is a `committish` passed as an extra argument. The target determines which committish is used to establish or locate a baseline. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does not still need to be a committish? We are trying to move away from git for baseline. |
||||||
|
||||||
The report name is based on the current branch name or the [project-info.version](#project-infoversion-committish). | ||||||
|
||||||
Set the diffing target on the command line by passing a committish with the since flag. | ||||||
Set the diffing target in the config file by setting the [since target](#sincetarget-committish) option. | ||||||
|
||||||
*\* The baseline and since features are mutually exclusive. This feature implicitly enables the [since](#since-flag-committish) feature for now.* | ||||||
|
||||||
### `baseline.enabled` <`flag`> | ||||||
|
||||||
Default: `null` | ||||||
Command line: `N/A` | ||||||
Config file: `"baseline": { "enabled": false }` | ||||||
|
||||||
Enable or disable [with-baseline](#with-baseline-flag-committish). If the enabled property is not set but the `baseline` object exists in the config file it is assumed to be enabled. Use this option to (temporarily) disable `with-baseline` without having to delete the other baseline configuration. | ||||||
|
||||||
### `baseline.fallback-version` <`string`> | ||||||
|
||||||
Default: [since-target](#since-flag-committish) | ||||||
Command line: `N/A` | ||||||
Config file: `"baseline": { "fallback-version": 'develop' }` | ||||||
Config file: `"baseline": { "fallback-version": 'develop' }` | ||||||
|
||||||
When [with-baseline](#with-baseline-flag-committish) is enabled and Stryker cannot find an existing report for the current branch the fallback version is used. When Stryker is still unable to find a baseline we will do a complete instead of partial testrun. The complete testrun will then be saved as the new baseline for the next mutation testrun. | ||||||
When [with-baseline](#with-baseline-committish) is enabled and Stryker cannot find an existing report for the current branch the fallback version is used. When Stryker is still unable to find a baseline we will do a complete instead of partial testrun. The complete testrun will then be saved as the new baseline for the next mutation testrun. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
**Example**: | ||||||
```json | ||||||
|
@@ -556,9 +546,9 @@ new baseline saved to: feat-2 | |||||
|
||||||
Default: `Disk` | ||||||
Command line: `N/A` | ||||||
Config file: `"baseline": { "provider": 'AzureFileStorage'}` | ||||||
Config file: `"baseline": { "provider": 'AzureFileStorage'}` | ||||||
|
||||||
Sets the storage provider for the baseline used by [with-baseline](#with-baseline-flag-committish). By default this is set to disk, when the dashboard [reporter](#reporter-string) is enabled this is automatically set to Dashboard. | ||||||
Sets the storage provider for the baseline used by [with-baseline](#with-baseline-committish). By default this is set to disk, when the dashboard [reporter](#reporter-string) is enabled this is automatically set to Dashboard. | ||||||
|
||||||
Supported storage providers are: | ||||||
|
||||||
|
@@ -601,6 +591,14 @@ Allowed permissions: `Read`, `Write`, `Create` | |||||
|
||||||
For more information on how to configure a SAS check the [Azure documentation](https://docs.microsoft.com/en-us/azure/storage/common/storage-sas-overview). | ||||||
|
||||||
### `baseline recreate` | ||||||
|
||||||
Default: `false` | ||||||
Command line: `with-baseline main recreate` | ||||||
Config file: `N/A` | ||||||
|
||||||
Sometimes your baseline can get corrupted or out of touch with reality. In that case the baseline can be recreated using this command. This will test all mutations in your project and save the result as the new baseline. | ||||||
|
||||||
## Troubleshooting | ||||||
|
||||||
### `verbosity` <`log-level`> | ||||||
|
@@ -620,7 +618,7 @@ All available loglevels are | |||||
|
||||||
### `log-to-file` <`flag`> | ||||||
|
||||||
Default: `false` | ||||||
Default: `false` | ||||||
Command line: `[-L|--log-to-file]` | ||||||
Config file: `N/A` | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,8 @@ public void RegisterInitCommand(CommandLineApplication app, IFileSystem fileSyst | |
{ | ||
RegisterCliInputs(initCommandApp); | ||
|
||
initCommandApp.HelpOption(); | ||
|
||
initCommandApp.OnExecute(() => | ||
{ | ||
_console.WriteLine($"Initializing new config file."); | ||
|
@@ -68,6 +70,45 @@ public void RegisterInitCommand(CommandLineApplication app, IFileSystem fileSyst | |
}); | ||
} | ||
|
||
public void RegisterBaselineCommand(CommandLineApplication app, IStrykerInputs inputs, string[] args, StrykerCli strykerCli) | ||
{ | ||
app.Command("baseline", baselineCmd => | ||
{ | ||
baselineCmd.AddName("with-baseline"); | ||
RegisterCliInputs(baselineCmd); | ||
|
||
var committishArg = baselineCmd.Argument("committish", "The committish to compare with the current HEAD. This can be a branch, tag or commit id."); | ||
committishArg.IsRequired(true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we not using a default target version anymore? |
||
|
||
baselineCmd.HelpOption(); | ||
|
||
baselineCmd.OnExecute(() => | ||
{ | ||
inputs.BaselineTargetInput.SuppliedInput = committishArg.Value; | ||
inputs.BaselineEnabledInput.SuppliedInput = true; | ||
baselineCmd.Description = "Starts a stryker run based on the results of a previous run."; | ||
return strykerCli.StartApp(inputs, args, app, this); | ||
}); | ||
|
||
baselineCmd.Command("recreate", createCmd => | ||
{ | ||
RegisterCliInputs(createCmd); | ||
|
||
createCmd.HelpOption(); | ||
|
||
createCmd.OnExecute(() => | ||
{ | ||
inputs.BaselineTargetInput.SuppliedInput = committishArg.Value; | ||
inputs.BaselineEnabledInput.SuppliedInput = true; | ||
createCmd.Description = "Creates a new baseline by doing a full stryker run"; | ||
// Enable recreate | ||
inputs.BaselineRecreateEnabledInput.SuppliedInput = true; | ||
return strykerCli.StartApp(inputs, args, app, this); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
public CommandOption GetConfigFileOption(string[] args, CommandLineApplication app) | ||
{ | ||
var commands = app.Parse(args); | ||
|
@@ -146,8 +187,8 @@ private static void HandleSingleOrNoValue(IInput strykerInput, CommandOption cli | |
inputs.SinceTargetInput.SuppliedInput = cliInput.Value(); | ||
break; | ||
|
||
case WithBaselineInput withBaselineInput: | ||
withBaselineInput.SuppliedInput = true; | ||
case BaselineEnabledInput baselineEnabledInput: | ||
baselineEnabledInput.SuppliedInput = true; | ||
inputs.SinceTargetInput.SuppliedInput = cliInput.Value(); | ||
break; | ||
|
||
|
@@ -182,7 +223,7 @@ private void PrepareCliOptions(IStrykerInputs inputs) | |
AddCliInput(inputs.MutateInput, "mutate", "m", optionType: CommandOptionType.MultipleValue, argumentHint: "glob-pattern", category: InputCategory.Mutation); | ||
AddCliInput(inputs.MutationLevelInput, "mutation-level", "l", category: InputCategory.Mutation); | ||
AddCliInput(inputs.SinceInput, "since", "", optionType: CommandOptionType.SingleOrNoValue, argumentHint: "committish", category: InputCategory.Mutation); | ||
AddCliInput(inputs.WithBaselineInput, "with-baseline", "", optionType: CommandOptionType.SingleOrNoValue, argumentHint: "committish", category: InputCategory.Mutation); | ||
AddCliInput(inputs.BaselineEnabledInput, "with-baseline", "", optionType: CommandOptionType.SingleOrNoValue, argumentHint: "committish", category: InputCategory.Mutation); | ||
// Category: Reporting | ||
AddCliInput(inputs.OpenReportInput, "open-report", "o", CommandOptionType.SingleOrNoValue, argumentHint: "report-type", category: InputCategory.Reporting); | ||
AddCliInput(inputs.ReportersInput, "reporter", "r", optionType: CommandOptionType.MultipleValue, category: InputCategory.Reporting); | ||
|
@@ -195,7 +236,7 @@ private void PrepareCliOptions(IStrykerInputs inputs) | |
AddCliInput(inputs.DevModeInput, "dev-mode", null, optionType: CommandOptionType.NoValue, category: InputCategory.Misc); | ||
} | ||
|
||
private void RegisterCliInput(CommandLineApplication app, CliInput option) | ||
public void RegisterCliInput(CommandLineApplication app, CliInput option) | ||
{ | ||
var argumentHint = option.OptionType switch | ||
{ | ||
|
@@ -230,7 +271,7 @@ private CliInput AddCliOnlyInput(string argumentName, string argumentShortName, | |
return cliOption; | ||
} | ||
|
||
private void AddCliInput(IInput input, string argumentName, string argumentShortName, | ||
public void AddCliInput(IInput input, string argumentName, string argumentShortName, | ||
CommandOptionType optionType = CommandOptionType.SingleValue, InputCategory category = InputCategory.Generic, string argumentHint = null) | ||
{ | ||
var cliOption = new CliInput | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.