Skip to content

Commit

Permalink
feat: Add --skip-version-check flag to disable automatic version chec…
Browse files Browse the repository at this point in the history
…ks (#3045)

* Ddd --skip-version-check flag to bypass version updates checks

* Fixed docs

* PR suggestion

* Small refactoring

* Remove stryker input for skip version check

* Add suppression for unneccesary suppression..

* Add justification

---------

Co-authored-by: Martin Obrátil <[email protected]>
Co-authored-by: Rouke Broersma <[email protected]>
Co-authored-by: Rouke Broersma <[email protected]>
  • Loading branch information
4 people authored Sep 27, 2024
1 parent b7e1e7d commit db8e9e8
Show file tree
Hide file tree
Showing 4 changed files with 415 additions and 358 deletions.
9 changes: 9 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -683,3 +683,12 @@ Command line: `--break-on-initial-test-failure`
Config file: `break-on-initial-test-failure`

Instruct Stryker to break execution when at least one test failed on initial test run.

### `skip-version-check` &lt;`flag`&gt;

Default: `false`
Command line: `--skip-version-check`
Config file: `N/A`

This flag disables the automatic version check for Stryker updates when running the tool.
Use this option if you want to prevent Stryker from checking for newer versions, such as in environments with restricted internet access or where update checking is unnecessary.
35 changes: 33 additions & 2 deletions src/Stryker.CLI/Stryker.CLI.UnitTest/StrykerCLITests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -41,7 +40,6 @@ public StrykerCLITests()
.Returns(_runResults)
.Verifiable();
_nugetClientMock.Setup(x => x.GetLatestVersionAsync()).Returns(Task.FromResult(new SemanticVersion(10, 0, 0)));
_nugetClientMock.Setup(x => x.GetPreviewVersionAsync()).Returns(Task.FromResult(new SemanticVersion(20, 0, 0)));
_target = new StrykerCli(_strykerRunnerMock.Object, null, _loggingInitializerMock.Object, _nugetClientMock.Object);
}

Expand Down Expand Up @@ -86,6 +84,28 @@ public void ShouldDisplayLogo()

consoleOutput.ShouldContain("Version:");
consoleOutput.ShouldContain(@"A new version of Stryker.NET (10.0.0) is available. Please consider upgrading using `dotnet tool update -g dotnet-stryker`");

_nugetClientMock.Verify(x => x.GetLatestVersionAsync(), Times.Once);
}

[TestMethod]
public void ShouldCallNugetClient()
{
_target.Run([]);

_nugetClientMock.Verify(x => x.GetLatestVersionAsync(), Times.Once);
_nugetClientMock.VerifyNoOtherCalls();
}

[TestMethod]
public void OnAlreadyNewestVersion_ShouldCallNugetClientForPreview()
{
_nugetClientMock.Setup(x => x.GetLatestVersionAsync()).Returns(Task.FromResult(new SemanticVersion(0, 0, 0)));
_nugetClientMock.Setup(x => x.GetPreviewVersionAsync()).Returns(Task.FromResult(new SemanticVersion(20, 0, 0)));

_target.Run([]);

_nugetClientMock.VerifyAll();
}

[TestMethod]
Expand Down Expand Up @@ -455,4 +475,15 @@ public void ShouldSupplyTargetFrameworkWhenPassed(params string[] argName)

_inputs.TargetFrameworkInput.SuppliedInput.ShouldBe("net7.0");
}

[TestMethod]
[DataRow("--skip-version-check")]
public void ShouldSupplyDisableCheckForNewerVersion(params string[] argName)
{
_target.Run(argName);

_strykerRunnerMock.VerifyAll();

_nugetClientMock.VerifyNoOtherCalls();
}
}
Loading

0 comments on commit db8e9e8

Please sign in to comment.