From 60a69b8f918875039b23e8b9127e5df4d0befba2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 10:03:04 +0200 Subject: [PATCH 1/4] Bump actions/download-artifact from 2 to 4.1.7 in /.github/workflows (#88) Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 2 to 4.1.7. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/v2...v4.1.7) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 25ba774..696c91a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -48,7 +48,7 @@ jobs: steps: - name: Download build artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4.1.7 with: name: release-binaries From 55b9fe08a494c4336567f869cad36b5a9c49a082 Mon Sep 17 00:00:00 2001 From: Niall Crowe Date: Wed, 18 Sep 2024 10:39:29 +0100 Subject: [PATCH 2/4] Drop support for EOL .NET versions, remove obsolete tests (#89) and update test matrix. Dropping support from tests for versions of .NET that are now EOL. Removing tests that are rendered obsolete by recent changes. Updating the test matrix for the latest OS releases. Closes #76 --- .github/workflows/ci.yml | 84 ++++++++++++++----- .../test.json | 4 +- .../test.sh | 0 .../CsprojCompatibilityPatcherTest.cs | 36 -------- Turkey.Tests/SourceBuildTest.cs | 11 --- Turkey/CsprojCompatibilityPatcher.cs | 33 -------- Turkey/Program.cs | 30 ------- Turkey/SourceBuild.cs | 14 +--- Turkey/Test.cs | 56 ------------- Turkey/resources/project10xunit.json | 27 ------ Turkey/resources/project11xunit.json | 27 ------ 11 files changed, 66 insertions(+), 256 deletions(-) rename Samples/{BashTestSpecificToDotNet2x => BashTestSpecificToDotNet6x}/test.json (68%) rename Samples/{BashTestSpecificToDotNet2x => BashTestSpecificToDotNet6x}/test.sh (100%) delete mode 100644 Turkey.Tests/CsprojCompatibilityPatcherTest.cs delete mode 100644 Turkey/CsprojCompatibilityPatcher.cs delete mode 100644 Turkey/resources/project10xunit.json delete mode 100644 Turkey/resources/project11xunit.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 462c69f..1efdc42 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,20 +14,29 @@ jobs: fail-fast: false matrix: container_image: - - quay.io/centos/centos:stream8 - quay.io/centos/centos:stream9 - - registry.fedoraproject.org/fedora:37 - - registry.fedoraproject.org/fedora:38 + - quay.io/centos/centos:stream10-development - registry.fedoraproject.org/fedora:39 + - registry.fedoraproject.org/fedora:40 - registry.fedoraproject.org/fedora:rawhide - registry.access.redhat.com/ubi8 - registry.access.redhat.com/ubi9 dotnet_version: - "6.0" - - "7.0" + - "8.0" + exclude: + - container_image: registry.fedoraproject.org/fedora:rawhide + dotnet_version: "6.0" + - container_image: quay.io/centos/centos:stream10-development + dotnet_version: "6.0" include: - - container_image: quay.io/centos/centos:stream9 - dotnet_version: "8.0" + - container_image: registry.fedoraproject.org/fedora:40 + dotnet_version: "9.0" + - container_image: registry.fedoraproject.org/fedora:rawhide + dotnet_version: "9.0" + - container_image: quay.io/centos/centos:stream10-development + dotnet_version: "9.0" + container: image: ${{ matrix.container_image }} @@ -38,13 +47,22 @@ jobs: timeout-minutes: 5 run: | set -euo pipefail - if command -v dnf; then - dnf install -y dotnet-sdk-${{ matrix.dotnet_version }} git make - elif command -v apk; then - apk add bash curl git icu-libs krb5-libs libgcc libintl libssl1.1 libstdc++ make zlib - curl -sSLO https://dot.net/v1/dotnet-install.sh - chmod +x ./dotnet-install.sh - ./dotnet-install.sh --channel ${{ matrix.dotnet_version }} + if [[ ${{ matrix.dotnet_version }} == 9.* ]]; then + dnf install 'dnf-command(copr)' -y + cat /etc/os-release + if grep centos /etc/os-release ; then + dnf copr enable @dotnet-sig/dotnet-preview centos-stream-10-x86_64 -y + else + dnf copr enable @dotnet-sig/dotnet-preview -y + fi + dnf install -y dotnet-sdk-aot-${{ matrix.dotnet_version }} + fi + dnf install -y dotnet-sdk-${{ matrix.dotnet_version }} git make + if [[ ! ${{ matrix.dotnet_version }} == *6* ]]; then + dnf install -y \ + dotnet-sdk-dbg-${{ matrix.dotnet_version }} \ + dotnet-runtime-dbg-${{ matrix.dotnet_version }} \ + aspnetcore-runtime-dbg-${{ matrix.dotnet_version }} fi - uses: actions/checkout@v2 @@ -80,20 +98,28 @@ jobs: fail-fast: false matrix: container_image: - - quay.io/centos/centos:stream8 - quay.io/centos/centos:stream9 - - registry.fedoraproject.org/fedora:37 - - registry.fedoraproject.org/fedora:38 + - quay.io/centos/centos:stream10-development - registry.fedoraproject.org/fedora:39 + - registry.fedoraproject.org/fedora:40 - registry.fedoraproject.org/fedora:rawhide - registry.access.redhat.com/ubi8 - registry.access.redhat.com/ubi9 dotnet_version: - "6.0" - - "7.0" + - "8.0" + exclude: + - container_image: registry.fedoraproject.org/fedora:rawhide + dotnet_version: "6.0" + - container_image: quay.io/centos/centos:stream10-development + dotnet_version: "6.0" include: - - container_image: quay.io/centos/centos:stream9 - dotnet_version: "8.0" + - container_image: registry.fedoraproject.org/fedora:40 + dotnet_version: "9.0" + - container_image: registry.fedoraproject.org/fedora:rawhide + dotnet_version: "9.0" + - container_image: quay.io/centos/centos:stream10-development + dotnet_version: "9.0" container: @@ -105,7 +131,23 @@ jobs: timeout-minutes: 5 run: | set -euo pipefail + if [[ ${{ matrix.dotnet_version }} == 9.* ]]; then + dnf install 'dnf-command(copr)' -y + cat /etc/os-release + if grep centos /etc/os-release ; then + dnf copr enable @dotnet-sig/dotnet-preview centos-stream-10-x86_64 -y + else + dnf copr enable @dotnet-sig/dotnet-preview -y + fi + dnf install -y dotnet-sdk-aot-${{ matrix.dotnet_version }} + fi dnf install -y dotnet-sdk-${{ matrix.dotnet_version }} git make + if [[ ! ${{ matrix.dotnet_version }} == *6* ]]; then + dnf install -y \ + dotnet-sdk-dbg-${{ matrix.dotnet_version }} \ + dotnet-runtime-dbg-${{ matrix.dotnet_version }} \ + aspnetcore-runtime-dbg-${{ matrix.dotnet_version }} + fi # We need to fetch the tags, so 'git tag' in 'make publish' below works - uses: actions/checkout@v2 @@ -127,9 +169,7 @@ jobs: - name: Install Test dependencies timeout-minutes: 2 run: | - dnf install -y python3 wget \ - $(grep '^Dependencies(dnf): ' dotnet-regular-tests/README.md | cut -d: -f2-) \ - --skip-broken + dnf install -y python3 wget $(grep '^Dependencies(dnf): ' dotnet-regular-tests/README.md | cut -d: -f2-) --skip-broken - name: Run reproducers run: | diff --git a/Samples/BashTestSpecificToDotNet2x/test.json b/Samples/BashTestSpecificToDotNet6x/test.json similarity index 68% rename from Samples/BashTestSpecificToDotNet2x/test.json rename to Samples/BashTestSpecificToDotNet6x/test.json index cfa7c79..71b38f6 100644 --- a/Samples/BashTestSpecificToDotNet2x/test.json +++ b/Samples/BashTestSpecificToDotNet6x/test.json @@ -1,8 +1,8 @@ { - "name": "BashTestSpecificToDotNet2x", + "name": "BashTestSpecificToDotNet6x", "enabled": true, "requiresSdk": true, - "version": "2.x", + "version": "6.x", "versionSpecific": true, "type": "bash", "cleanup": true, diff --git a/Samples/BashTestSpecificToDotNet2x/test.sh b/Samples/BashTestSpecificToDotNet6x/test.sh similarity index 100% rename from Samples/BashTestSpecificToDotNet2x/test.sh rename to Samples/BashTestSpecificToDotNet6x/test.sh diff --git a/Turkey.Tests/CsprojCompatibilityPatcherTest.cs b/Turkey.Tests/CsprojCompatibilityPatcherTest.cs deleted file mode 100644 index f69e0e8..0000000 --- a/Turkey.Tests/CsprojCompatibilityPatcherTest.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; - -using Turkey; - -using Xunit; - -namespace Turkey.Tests -{ - public class CsprojCompatibilityPatcherTest - { - [Theory] - [InlineData("netcoreapp1.0", "2.1", "netcoreapp2.1")] - [InlineData("netcoreapp2.1", "3.1", "netcoreapp3.1")] - [InlineData("netcoreapp3.1", "3.1", "netcoreapp3.1")] - [InlineData("net5.0", "3.1", "netcoreapp3.1")] - [InlineData("net5.0", "2.1", "netcoreapp2.1")] - public void TargetFrameworksAreReplacedCorrectly(string currentTfm, string runtimeVersion, string expectedTfm) - { - Version newRuntimeVersion = Version.Parse(runtimeVersion); - string csproj = $@" - - - - {currentTfm} - - -"; - string patched = new CsprojCompatibilityPatcher().Patch(csproj, newRuntimeVersion); - Assert.Contains(expectedTfm, patched); - if (currentTfm != expectedTfm) - { - Assert.DoesNotContain(currentTfm, patched); - } - } - } -} diff --git a/Turkey.Tests/SourceBuildTest.cs b/Turkey.Tests/SourceBuildTest.cs index 3ce5f0b..bf6b112 100644 --- a/Turkey.Tests/SourceBuildTest.cs +++ b/Turkey.Tests/SourceBuildTest.cs @@ -48,17 +48,6 @@ protected override Task SendAsync(HttpRequestMessage messag } } - [Fact] - public async Task VerifyProdConFeedIsLookedUpAndThenTheFeedIsVerifiedToResolve() - { - var messageHandler = new ProdConHandler(); - var client = new HttpClient(messageHandler); - var sourceBuild = new SourceBuild(client); - - var feed = await sourceBuild.GetProdConFeedAsync(Version.Parse("3.1")); - - Assert.Equal(FAKE_FEED, feed); - } [Fact] public async Task VerifyProdConFeedIsNotUsedForNewReleases() diff --git a/Turkey/CsprojCompatibilityPatcher.cs b/Turkey/CsprojCompatibilityPatcher.cs deleted file mode 100644 index c676965..0000000 --- a/Turkey/CsprojCompatibilityPatcher.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Text.RegularExpressions; -using System.Threading; -using System.Threading.Tasks; - -namespace Turkey -{ - public class CsprojCompatibilityPatcher - { - public string Patch(string originalCsprojContents, Version newRuntime) - { - var pattern = @"net(?:coreapp)?\d\.\d+"; - var versionString = newRuntime.MajorMinor; - string replacement = null; - if (newRuntime.Major < 4) - { - replacement = $"netcoreapp{versionString}"; - } - else - { - replacement = $"net{versionString}"; - } - var output = Regex.Replace(originalCsprojContents, pattern, replacement); - - return output; - } - - } - -} diff --git a/Turkey/Program.cs b/Turkey/Program.cs index 957a5aa..fba1d31 100644 --- a/Turkey/Program.cs +++ b/Turkey/Program.cs @@ -152,25 +152,6 @@ public static async Task GenerateNuGetConfigIfNeededAsync(string additio var nuget = new NuGet(client); var sourceBuild = new SourceBuild(client); - if (netCoreAppVersion.Major < 4) - { - try - { - var prodConUrl = await GetProdConFeedUrlIfNeededAsync(nuget, sourceBuild, netCoreAppVersion); - if (!string.IsNullOrEmpty(prodConUrl)) - { - prodConUrl = prodConUrl.Trim(); - Console.WriteLine($"Packages are not live on nuget.org; using {prodConUrl} as additional package source"); - urls.Add(prodConUrl); - } - } - catch (HttpRequestException exception) - { - Console.WriteLine("WARNING: failed to get ProdCon url. Ignoring Exception:"); - Console.WriteLine(exception.ToString()); - } - } - string nugetConfig = null; if (useSourceBuildNuGetConfig) { @@ -233,17 +214,6 @@ public static IReadOnlySet CreateTraits(Version runtimeVersion, Version return traits; } - public static async Task GetProdConFeedUrlIfNeededAsync(NuGet nuget, SourceBuild sourceBuild, Version netCoreAppVersion) - { - bool live = await nuget.IsPackageLiveAsync("runtime.linux-x64.Microsoft.NetCore.DotNetAppHost", netCoreAppVersion); - if (!live) - { - return await sourceBuild.GetProdConFeedAsync(netCoreAppVersion); - } - - return null; - } - static async Task Main(string[] args) { var rootCommand = new RootCommand(description: "A test runner for running standalone bash-based or xunit tests"); diff --git a/Turkey/SourceBuild.cs b/Turkey/SourceBuild.cs index d12965b..ce847d9 100644 --- a/Turkey/SourceBuild.cs +++ b/Turkey/SourceBuild.cs @@ -18,18 +18,8 @@ public SourceBuild(HttpClient client) public string GetBranchContentUrl(Version version) { - string url; - if (version.Major <= 3) - { - var branchName = "release/" + version.MajorMinor; - url = $"https://raw.githubusercontent.com/dotnet/source-build/{branchName}/"; - } - else - { - var branchName = "release/" + version.MajorMinor + ".1xx"; - url = $"https://raw.githubusercontent.com/dotnet/installer/{branchName}/"; - } - + var branchName = "release/" + version.MajorMinor + ".1xx"; + var url = $"https://raw.githubusercontent.com/dotnet/installer/{branchName}/"; return url; } diff --git a/Turkey/Test.cs b/Turkey/Test.cs index 523395f..dc4b8a7 100644 --- a/Turkey/Test.cs +++ b/Turkey/Test.cs @@ -61,8 +61,6 @@ public async Task RunAsync(Action logger, CancellationToken await File.WriteAllTextAsync(path, NuGetConfig); } - UpdateProjectFilesIfPresent(); - var testResult = await InternalRunAsync(logger, cancelltionToken); if (!string.IsNullOrEmpty(NuGetConfig)) @@ -73,60 +71,6 @@ public async Task RunAsync(Action logger, CancellationToken return testResult; } - private void UpdateProjectFilesIfPresent() - { - if (SystemUnderTest.RuntimeVersion < Version.Parse("2.0")) - { - var projectJsonPath = Path.Combine(this.Directory.FullName, "project.json"); - if (File.Exists(projectJsonPath)) - { - CopyProjectJsonFile(); - } - } - else - { - var csprojFile = $"{Directory.Name}.csproj"; - var csprojPath = Path.Combine(this.Directory.FullName, csprojFile); - if (File.Exists(csprojPath)) - { - UpdateCsprojVersion(csprojPath); - } - } - } - - private void CopyProjectJsonFile() - { - string majorMinor = "" + SystemUnderTest.RuntimeVersion.Major + SystemUnderTest.RuntimeVersion.Minor; - var fileName = $"resources/project{majorMinor}xunit.json"; - var resourceLocation = FindResourceFile(fileName); - var source = resourceLocation; - var dest = Path.Combine(this.Directory.FullName, "project.json"); - File.Copy(source, dest); - } - - private static string FindResourceFile(string name) - { - var assemblyLocation = Assembly.GetExecutingAssembly().Location; - var dir = Path.GetDirectoryName(assemblyLocation); - var resourceLocation = Path.Combine(dir, name); - if (!File.Exists(resourceLocation)) - { - throw new Exception($"Resource {name} at location {resourceLocation} does not exist"); - } - return resourceLocation; - } - - private void UpdateCsprojVersion(string csprojPath) - { - var contents = File.ReadAllText(csprojPath); - var updatedContents = UpdateCsprojContents(contents); - - File.WriteAllText(csprojPath, updatedContents); - } - - private string UpdateCsprojContents(string contents) => - new CsprojCompatibilityPatcher().Patch(contents, this.SystemUnderTest.RuntimeVersion); - protected abstract Task InternalRunAsync(Action logger, CancellationToken cancellationToken); } diff --git a/Turkey/resources/project10xunit.json b/Turkey/resources/project10xunit.json deleted file mode 100644 index cdd1bda..0000000 --- a/Turkey/resources/project10xunit.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "version": "1.0.0-*", - "buildOptions": { - "warningsAsErrors": true, - "debugType": "portable" - }, - "dependencies": { - "System.Runtime.Serialization.Primitives": "4.1.1", - "xunit": "2.1.0", - "dotnet-test-xunit": "1.0.0-rc2-192208-24" - }, - "testRunner": "xunit", - "frameworks": { - "netcoreapp1.0": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.10" - } - }, - "imports": [ - "dotnet5.4", - "portable-net451+win8" - ] - } - } -} diff --git a/Turkey/resources/project11xunit.json b/Turkey/resources/project11xunit.json deleted file mode 100644 index 88503da..0000000 --- a/Turkey/resources/project11xunit.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "version": "1.0.0-*", - "buildOptions": { - "warningsAsErrors": true, - "debugType": "portable" - }, - "dependencies": { - "System.Runtime.Serialization.Primitives": "4.3.0", - "xunit": "2.1.0", - "dotnet-test-xunit": "1.0.0-rc2-192208-24" - }, - "testRunner": "xunit", - "frameworks": { - "netcoreapp1.1": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.1.7" - } - }, - "imports": [ - "dotnet5.4", - "portable-net451+win8" - ] - } - } -} From 116605a69c423b737e31c61d62f37c4ed30ea280 Mon Sep 17 00:00:00 2001 From: Niall Crowe Date: Thu, 5 Dec 2024 09:53:25 +0000 Subject: [PATCH 3/4] Update ci matrix and .NET installation instructions. (#90) Adding Fedora41 to the CI matrix while also removing Fedora39. .NET 6 has also been removed. The installation steps for .NET 9 have been updated now that it has been publically released. --- .github/workflows/ci.yml | 76 +++++++++------------------------------- 1 file changed, 16 insertions(+), 60 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1efdc42..17d4eea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,29 +15,16 @@ jobs: matrix: container_image: - quay.io/centos/centos:stream9 - - quay.io/centos/centos:stream10-development - - registry.fedoraproject.org/fedora:39 + - quay.io/centos/centos:stream10 - registry.fedoraproject.org/fedora:40 + - registry.fedoraproject.org/fedora:41 - registry.fedoraproject.org/fedora:rawhide - registry.access.redhat.com/ubi8 - registry.access.redhat.com/ubi9 dotnet_version: - - "6.0" - "8.0" - exclude: - - container_image: registry.fedoraproject.org/fedora:rawhide - dotnet_version: "6.0" - - container_image: quay.io/centos/centos:stream10-development - dotnet_version: "6.0" - include: - - container_image: registry.fedoraproject.org/fedora:40 - dotnet_version: "9.0" - - container_image: registry.fedoraproject.org/fedora:rawhide - dotnet_version: "9.0" - - container_image: quay.io/centos/centos:stream10-development - dotnet_version: "9.0" + - "9.0" - container: image: ${{ matrix.container_image }} options: --security-opt seccomp=unconfined @@ -47,23 +34,14 @@ jobs: timeout-minutes: 5 run: | set -euo pipefail + dnf install -y dotnet-sdk-${{ matrix.dotnet_version }} git make + dnf install -y \ + dotnet-sdk-dbg-${{ matrix.dotnet_version }} \ + dotnet-runtime-dbg-${{ matrix.dotnet_version }} \ + aspnetcore-runtime-dbg-${{ matrix.dotnet_version }} if [[ ${{ matrix.dotnet_version }} == 9.* ]]; then - dnf install 'dnf-command(copr)' -y - cat /etc/os-release - if grep centos /etc/os-release ; then - dnf copr enable @dotnet-sig/dotnet-preview centos-stream-10-x86_64 -y - else - dnf copr enable @dotnet-sig/dotnet-preview -y - fi dnf install -y dotnet-sdk-aot-${{ matrix.dotnet_version }} fi - dnf install -y dotnet-sdk-${{ matrix.dotnet_version }} git make - if [[ ! ${{ matrix.dotnet_version }} == *6* ]]; then - dnf install -y \ - dotnet-sdk-dbg-${{ matrix.dotnet_version }} \ - dotnet-runtime-dbg-${{ matrix.dotnet_version }} \ - aspnetcore-runtime-dbg-${{ matrix.dotnet_version }} - fi - uses: actions/checkout@v2 with: @@ -99,28 +77,15 @@ jobs: matrix: container_image: - quay.io/centos/centos:stream9 - - quay.io/centos/centos:stream10-development - - registry.fedoraproject.org/fedora:39 + - quay.io/centos/centos:stream10 - registry.fedoraproject.org/fedora:40 + - registry.fedoraproject.org/fedora:41 - registry.fedoraproject.org/fedora:rawhide - registry.access.redhat.com/ubi8 - registry.access.redhat.com/ubi9 dotnet_version: - - "6.0" - "8.0" - exclude: - - container_image: registry.fedoraproject.org/fedora:rawhide - dotnet_version: "6.0" - - container_image: quay.io/centos/centos:stream10-development - dotnet_version: "6.0" - include: - - container_image: registry.fedoraproject.org/fedora:40 - dotnet_version: "9.0" - - container_image: registry.fedoraproject.org/fedora:rawhide - dotnet_version: "9.0" - - container_image: quay.io/centos/centos:stream10-development - dotnet_version: "9.0" - + - "9.0" container: image: ${{ matrix.container_image }} @@ -131,23 +96,14 @@ jobs: timeout-minutes: 5 run: | set -euo pipefail + dnf install -y dotnet-sdk-${{ matrix.dotnet_version }} git make + dnf install -y \ + dotnet-sdk-dbg-${{ matrix.dotnet_version }} \ + dotnet-runtime-dbg-${{ matrix.dotnet_version }} \ + aspnetcore-runtime-dbg-${{ matrix.dotnet_version }} if [[ ${{ matrix.dotnet_version }} == 9.* ]]; then - dnf install 'dnf-command(copr)' -y - cat /etc/os-release - if grep centos /etc/os-release ; then - dnf copr enable @dotnet-sig/dotnet-preview centos-stream-10-x86_64 -y - else - dnf copr enable @dotnet-sig/dotnet-preview -y - fi dnf install -y dotnet-sdk-aot-${{ matrix.dotnet_version }} fi - dnf install -y dotnet-sdk-${{ matrix.dotnet_version }} git make - if [[ ! ${{ matrix.dotnet_version }} == *6* ]]; then - dnf install -y \ - dotnet-sdk-dbg-${{ matrix.dotnet_version }} \ - dotnet-runtime-dbg-${{ matrix.dotnet_version }} \ - aspnetcore-runtime-dbg-${{ matrix.dotnet_version }} - fi # We need to fetch the tags, so 'git tag' in 'make publish' below works - uses: actions/checkout@v2 From 204dd740ad8cca9b4e10fba7d2c5a76b1e379b22 Mon Sep 17 00:00:00 2001 From: nicrowe00 Date: Thu, 5 Dec 2024 10:12:56 +0000 Subject: [PATCH 4/4] Remove warnings from terminal when compiling the test runner. A fix for the test runner that patches most of the warnings that are reported in the terminal when compiling the test runner. Some warnings were suppressed as it was too time-consuming or there were impacts to other parts of the test runner when they were fixed. --- Turkey/BashTest.cs | 2 +- Turkey/Cleaner.cs | 15 +++++++++---- Turkey/DotNet.cs | 6 +++-- Turkey/IEnumerableExtensions.cs | 2 +- Turkey/NuGet.cs | 32 +++++++++++++++++---------- Turkey/PlatformId.cs | 12 ++++++---- Turkey/ProcessExtensions.cs | 6 ++--- Turkey/Program.cs | 18 ++++++++++----- Turkey/SourceBuild.cs | 15 ++++++++----- Turkey/Test.cs | 8 +++++-- Turkey/TestOutputFormat.cs | 39 +++++++++++++++++++++++---------- Turkey/TestParser.cs | 13 +++++++---- Turkey/TestRunner.cs | 32 +++++++++++++-------------- Turkey/Version.cs | 2 ++ Turkey/XUnitTest.cs | 4 ++-- 15 files changed, 132 insertions(+), 74 deletions(-) diff --git a/Turkey/BashTest.cs b/Turkey/BashTest.cs index 3dd09ba..e6d490f 100644 --- a/Turkey/BashTest.cs +++ b/Turkey/BashTest.cs @@ -38,7 +38,7 @@ protected override async Task InternalRunAsync(Action logger startInfo.EnvironmentVariables.Add(key, value); } - int exitCode = await ProcessRunner.RunAsync(startInfo, logger, cancellationToken); + int exitCode = await ProcessRunner.RunAsync(startInfo, logger, cancellationToken).ConfigureAwait(false); return exitCode == 0 ? TestResult.Passed : TestResult.Failed; } diff --git a/Turkey/Cleaner.cs b/Turkey/Cleaner.cs index 7747152..d442ed4 100644 --- a/Turkey/Cleaner.cs +++ b/Turkey/Cleaner.cs @@ -36,7 +36,9 @@ public static IEnumerable LocalProjectCruft() yield return "project.lock.json"; } - public async Task CleanProjectLocalDotNetCruftAsync() +#pragma warning disable CA1822 // Mark members as static + public Task CleanProjectLocalDotNetCruftAsync() +#pragma warning restore CA1822 // Mark members as static { foreach(var name in LocalProjectCruft()) @@ -51,9 +53,12 @@ public async Task CleanProjectLocalDotNetCruftAsync() File.Delete(name); } } + return Task.CompletedTask; } - public async Task CleanLocalDotNetCacheAsync() +#pragma warning disable CA1822 // Mark members as static + public Task CleanLocalDotNetCacheAsync() +#pragma warning restore CA1822 // Mark members as static { foreach (var path in CruftDirectoryGlobs()) { @@ -77,12 +82,14 @@ public async Task CleanLocalDotNetCacheAsync() Console.WriteLine($"WARNING: unable to expand {path}"); } } - return; + return Task.CompletedTask; } +#pragma warning disable CA1822 // Mark members as static public IEnumerable ExpandPath(string pathWithGlob) +#pragma warning restore CA1822 // Mark members as static { - if (pathWithGlob.StartsWith("~")) + if (pathWithGlob.StartsWith("~", StringComparison.Ordinal)) { pathWithGlob = Environment.GetEnvironmentVariable("HOME") + pathWithGlob.Substring(1); } diff --git a/Turkey/DotNet.cs b/Turkey/DotNet.cs index 9cf4760..7a0bf10 100644 --- a/Turkey/DotNet.cs +++ b/Turkey/DotNet.cs @@ -43,7 +43,7 @@ public List RuntimeVersions string output = p.StandardOutput.ReadToEnd(); var list = output .Split("\n", StringSplitOptions.RemoveEmptyEntries) - .Where(line => line.StartsWith("Microsoft.NETCore.App")) + .Where(line => line.StartsWith("Microsoft.NETCore.App", StringComparison.Ordinal)) .Select(line => line.Split(" ")[1]) .Select(versionString => Version.Parse(versionString)) .OrderBy(x => x) @@ -137,7 +137,7 @@ private async Task RunDotNetCommandAsync(DirectoryInfo workingDirectory, st startInfo.EnvironmentVariables.Add(key, value); } - return await ProcessRunner.RunAsync(startInfo, logger, token); + return await ProcessRunner.RunAsync(startInfo, logger, token).ConfigureAwait(false); } private static bool IsCoreClrRuntime(string dotnetRoot, Version version) @@ -159,7 +159,9 @@ private static bool IsCoreClrRuntime(string dotnetRoot, Version version) return File.Exists(Path.Combine(runtimeDir, "libcoreclrtraceptprovider.so")); } + #nullable enable private static string? FindProgramInPath(string program) + #nullable disable { string[] paths = Environment.GetEnvironmentVariable("PATH")?.Split(':', StringSplitOptions.RemoveEmptyEntries) ?? Array.Empty(); foreach (string p in paths) diff --git a/Turkey/IEnumerableExtensions.cs b/Turkey/IEnumerableExtensions.cs index 023805e..7cea08b 100644 --- a/Turkey/IEnumerableExtensions.cs +++ b/Turkey/IEnumerableExtensions.cs @@ -10,7 +10,7 @@ public static async Task ForEachAsync(this IEnumerable items, Func IsPackageLiveAsync(string name, Version version) { var url = $"https://api-v2v3search-0.nuget.org/autocomplete?id={name}&prerelease=true"; - var result = await _client.GetStringAsync(url); - return await IsPackageLiveAsync(name, version, result); + Uri uri = new(url); + var result = await _client.GetStringAsync(uri).ConfigureAwait(false); + return await IsPackageLiveAsync(name, version, result).ConfigureAwait(false); } - public async Task IsPackageLiveAsync(string name, Version version, string json) +#pragma warning disable CA1801 // Remove unused parameter +#pragma warning disable CA1822 // Mark members as static + public Task IsPackageLiveAsync(string name, Version version, string json) +#pragma warning restore CA1822 // Mark members as static +#pragma warning restore CA1801 // Remove unused parameter { JObject deserialized = (JObject) JsonConvert.DeserializeObject(json); - JArray versions = (JArray) deserialized.GetValue("data"); + JArray versions = (JArray) deserialized.GetValue("data", StringComparison.Ordinal); var found = versions.Children() - .Where(v => v.Value().Equals(version.ToString())) + .Where(v => v.Value().Equals(version.ToString(), StringComparison.Ordinal)) .Any(); - return found; + return Task.FromResult(found); } - public async Task GenerateNuGetConfig(List urls, string nugetConfig = null) +#pragma warning disable CA1822 // Mark members as static + public Task GenerateNuGetConfig(List urls, string nugetConfig = null) +#pragma warning restore CA1822 // Mark members as static { - if( !urls.Any() && nugetConfig == null ) - throw new ArgumentNullException(); + if (!urls.Any()) + ArgumentNullException.ThrowIfNull(nugetConfig); string sources = null; - if( urls.Any() ) + if (urls.Any()) { var sourceParts = new List(urls.Count); for( int i = 0; i < urls.Count; i++ ) @@ -54,6 +61,7 @@ public async Task GenerateNuGetConfig(List urls, string nugetCon { sources = $" {sources}\n"; } + } if( string.IsNullOrWhiteSpace(nugetConfig) ) @@ -66,9 +74,9 @@ public async Task GenerateNuGetConfig(List urls, string nugetCon } if( !string.IsNullOrWhiteSpace(sources) ) - nugetConfig = nugetConfig.Replace("", sources + ""); + nugetConfig = nugetConfig.Replace("", sources + "", StringComparison.Ordinal); - return nugetConfig; + return Task.FromResult(nugetConfig); } } diff --git a/Turkey/PlatformId.cs b/Turkey/PlatformId.cs index cae1728..45a750c 100644 --- a/Turkey/PlatformId.cs +++ b/Turkey/PlatformId.cs @@ -18,7 +18,9 @@ public List CurrentIds public List ComputePlatformIds(string[] osReleaseLines, string lddVersionOutput) { - string arch = Enum.GetName(typeof(Architecture), RuntimeInformation.OSArchitecture).ToLowerInvariant(); + #pragma warning disable CA1308 // Normalize strings to uppercase + string arch = RuntimeInformation.OSArchitecture.ToString().ToLowerInvariant(); + #pragma warning restore CA1308 // Normalize strings to uppercase return ComputePlatformIds(osReleaseLines, arch, lddVersionOutput); } @@ -63,17 +65,17 @@ public List ComputePlatformIds(string[] osReleaseLines, string architect return platforms.ToList(); } - private string GetValue(string key, string[] lines) + private static string GetValue(string key, string[] lines) { return lines.Where(line => line.StartsWith(key + "=", StringComparison.Ordinal)).Last().Substring((key + "=").Length); } - private string Unquote(string text) + private static string Unquote(string text) { // TODO implement proper un-escaping // This is a limited shell-style syntax described at // https://www.freedesktop.org/software/systemd/man/os-release.html - if (text.StartsWith("\"") && text.EndsWith("\"")) + if (text.StartsWith("\"", StringComparison.Ordinal) && text.EndsWith("\"", StringComparison.Ordinal)) { return text.Substring(1, text.Length - 2); } @@ -81,7 +83,9 @@ private string Unquote(string text) return text; } +#pragma warning disable CA1822 // Mark members as static internal string GetLddVersion() +#pragma warning restore CA1822 // Mark members as static { using (Process p = new Process()) { diff --git a/Turkey/ProcessExtensions.cs b/Turkey/ProcessExtensions.cs index d02bb2a..dd8ee3a 100644 --- a/Turkey/ProcessExtensions.cs +++ b/Turkey/ProcessExtensions.cs @@ -12,7 +12,7 @@ public static async Task RunAsync(ProcessStartInfo psi, Action logg { logger($"Executing {psi.FileName} with arguments {psi.Arguments} in working directory {psi.WorkingDirectory}"); using var process = Process.Start(psi); - await process.WaitForExitAsync(logger, token); + await process.WaitForExitAsync(logger, token).ConfigureAwait(false); return process.ExitCode; } } @@ -43,11 +43,11 @@ public static async Task WaitForExitAsync(this Process process, Action l try { - await process.WaitForExitAsync(token); + await process.WaitForExitAsync(token).ConfigureAwait(false); logger($"Process Exit Code: {process.ExitCode}"); } - catch (OperationCanceledException ex) + catch (OperationCanceledException) { lock (logger) { diff --git a/Turkey/Program.cs b/Turkey/Program.cs index fba1d31..d9b52c1 100644 --- a/Turkey/Program.cs +++ b/Turkey/Program.cs @@ -12,7 +12,9 @@ namespace Turkey { +#pragma warning disable CA1052 // Static holder types should be Static or NotInheritable public class Program +#pragma warning restore CA1052 // Static holder types should be Static or NotInheritable { public static readonly Option verboseOption = new Option( new string[] { "--verbose", "-v" }, @@ -118,7 +120,7 @@ public static async Task Run(string testRoot, Version packageVersion = runtimeVersion; string nuGetConfig = await GenerateNuGetConfigIfNeededAsync(additionalFeed, packageVersion, - useSourceBuildNuGetConfig: false); + useSourceBuildNuGetConfig: false).ConfigureAwait(false); if (verbose && nuGetConfig != null) { Console.WriteLine("Using nuget.config: "); @@ -132,7 +134,7 @@ public static async Task Run(string testRoot, verboseOutput: verbose, nuGetConfig: nuGetConfig); - var results = await runner.ScanAndRunAsync(testOutputs, logDir.FullName, defaultTimeout); + var results = await runner.ScanAndRunAsync(testOutputs, logDir.FullName, defaultTimeout).ConfigureAwait(false); int exitCode = (results.Failed == 0) ? 0 : 1; return exitCode; @@ -157,7 +159,7 @@ public static async Task GenerateNuGetConfigIfNeededAsync(string additio { try { - nugetConfig = await sourceBuild.GetNuGetConfigAsync(netCoreAppVersion); + nugetConfig = await sourceBuild.GetNuGetConfigAsync(netCoreAppVersion).ConfigureAwait(false); } catch( HttpRequestException exception ) { @@ -173,14 +175,16 @@ public static async Task GenerateNuGetConfigIfNeededAsync(string additio // if the nugetConfig has a element that removes // it. urls.Add("https://api.nuget.org/v3/index.json"); - return await nuget.GenerateNuGetConfig(urls, nugetConfig); + return await nuget.GenerateNuGetConfig(urls, nugetConfig).ConfigureAwait(false); } } return null; } +#pragma warning disable CA1801 // Remove unused parameter public static IReadOnlySet CreateTraits(Version runtimeVersion, Version sdkVersion, List rids, bool isMonoRuntime, IEnumerable additionalTraits) +#pragma warning restore CA1801 // Remove unused parameter { var traits = new HashSet(StringComparer.OrdinalIgnoreCase); @@ -199,7 +203,9 @@ public static IReadOnlySet CreateTraits(Version runtimeVersion, Version } // Add 'arch=' trait. +#pragma warning disable CA1308 // Normalize strings to uppercase string arch = RuntimeInformation.OSArchitecture.ToString().ToLowerInvariant(); +#pragma warning restore CA1308 // Normalize strings to uppercase traits.Add($"arch={arch}"); // Add 'runtime=' trait. @@ -231,7 +237,7 @@ static async Task Main(string[] args) rootCommand.AddOption(traitOption); rootCommand.AddOption(timeoutOption); - return await rootCommand.InvokeAsync(args); + return await rootCommand.InvokeAsync(args).ConfigureAwait(false); } } -} +} \ No newline at end of file diff --git a/Turkey/SourceBuild.cs b/Turkey/SourceBuild.cs index ce847d9..daed9ab 100644 --- a/Turkey/SourceBuild.cs +++ b/Turkey/SourceBuild.cs @@ -16,11 +16,12 @@ public SourceBuild(HttpClient client) this._client = client; } - public string GetBranchContentUrl(Version version) + public static System.Uri GetBranchContentUrl(Version version) { var branchName = "release/" + version.MajorMinor + ".1xx"; var url = $"https://raw.githubusercontent.com/dotnet/installer/{branchName}/"; - return url; + Uri uri = new(url); + return uri; } public async Task GetProdConFeedAsync(Version version) @@ -31,9 +32,10 @@ public async Task GetProdConFeedAsync(Version version) } var url = GetBranchContentUrl(version) + "ProdConFeed.txt"; - var feedUrl = await _client.GetStringAsync(url); - - using(var response = await _client.GetAsync(feedUrl)) + Uri uri = new(url); + var feedUrl = await _client.GetStringAsync(uri).ConfigureAwait(false); + Uri feedUri = new(feedUrl); + using(var response = await _client.GetAsync(feedUri).ConfigureAwait(false)) { if (!response.IsSuccessStatusCode) { @@ -46,11 +48,12 @@ public async Task GetProdConFeedAsync(Version version) public async Task GetNuGetConfigAsync(Version version) { string url = GetBranchContentUrl(version) + "NuGet.config"; + Uri uri = new(url); string nugetConfig = null; try { - nugetConfig = await _client.GetStringAsync(url); + nugetConfig = await _client.GetStringAsync(uri).ConfigureAwait(false); } catch( HttpRequestException e ) { diff --git a/Turkey/Test.cs b/Turkey/Test.cs index dc4b8a7..afd0d1c 100644 --- a/Turkey/Test.cs +++ b/Turkey/Test.cs @@ -18,8 +18,12 @@ public class TestDescriptor public string Type { get; set; } public bool Cleanup { get; set; } public double TimeoutMultiplier { get; set; } = 1.0; + + #pragma warning disable CA2227 // Change to be read-only by removing the property setter. public List IgnoredRIDs { get; set; } = new(); public List SkipWhen { get; set; } = new(); + + #pragma warning restore CA2227 } // TODO is this a strongly-typed enum in C#? @@ -58,10 +62,10 @@ public async Task RunAsync(Action logger, CancellationToken { Console.WriteLine($"WARNING: overwriting {path}"); } - await File.WriteAllTextAsync(path, NuGetConfig); + await File.WriteAllTextAsync(path, NuGetConfig).ConfigureAwait(false); } - var testResult = await InternalRunAsync(logger, cancelltionToken); + var testResult = await InternalRunAsync(logger, cancelltionToken).ConfigureAwait(false); if (!string.IsNullOrEmpty(NuGetConfig)) { diff --git a/Turkey/TestOutputFormat.cs b/Turkey/TestOutputFormat.cs index 4f85e64..b88743c 100644 --- a/Turkey/TestOutputFormat.cs +++ b/Turkey/TestOutputFormat.cs @@ -11,9 +11,9 @@ namespace Turkey { - public class TestOutputFormats + public static class TestOutputFormats { - public class NewOutput : TestOutput + internal class NewOutput : TestOutput { public class FailedTest { @@ -23,16 +23,23 @@ public class FailedTest private List failedTests = new List(); - public async override Task AtStartupAsync(){ +#pragma warning disable CA1822 // Mark members as static + public void AtStartup() +#pragma warning restore CA1822 // Mark members as static + { Console.WriteLine("Running tests:"); + return; } - public async override Task AfterParsingTestAsync(string name, bool enabled) + public override Task AfterParsingTestAsync(string name, bool enabled) { + #pragma warning disable CA1305 var nameText = string.Format("{0,-60}", name); + #pragma warning restore CA1305 Console.Write(nameText); + return Task.CompletedTask; } - public async override Task AfterRunningTestAsync(string name, TestResult result, StringBuilder testLog, TimeSpan testTime) + public override Task AfterRunningTestAsync(string name, TestResult result, StringBuilder testLog, TimeSpan testTime) { int minutes = (int)testTime.TotalMinutes; int seconds = (int)Math.Ceiling(testTime.TotalSeconds - 60 * minutes); @@ -59,26 +66,31 @@ public async override Task AfterRunningTestAsync(string name, TestResult result, } Console.WriteLine($"[{resultOutput}]\t({elapsedTime})"); } + return Task.CompletedTask; } - public async override Task PrintFailedTests() + public override Task PrintFailedTests() { Console.WriteLine(); Console.WriteLine("The following tests failed: "); foreach(var test in failedTests) { + #pragma warning disable CA1305 Console.WriteLine($"{string.Format("{0,-30}", test.Name)}({test.Duration})"); + #pragma warning restore CA1305 } + return Task.CompletedTask; } - public async override Task AfterRunningAllTestsAsync(TestResults results) + public override Task AfterRunningAllTestsAsync(TestResults results) { Console.WriteLine(); Console.WriteLine($"Total: {results.Total} Passed: {results.Passed} Failed: {results.Failed}"); + return Task.CompletedTask; } } - public class JUnitOutput : TestOutput + internal class JUnitOutput : TestOutput { private struct TestCase { public string Name; @@ -102,7 +114,7 @@ public JUnitOutput(FileInfo resultsFile) _resultsFile = resultsFile; } - public async override Task AfterRunningTestAsync(string name, TestResult result, StringBuilder testLog, TimeSpan testTime) + public override Task AfterRunningTestAsync(string name, TestResult result, StringBuilder testLog, TimeSpan testTime) { var testCase = new TestCase(); testCase.Name = name; @@ -113,9 +125,11 @@ public async override Task AfterRunningTestAsync(string name, TestResult result, testCase.Log = testLog; _testCases.Add(testCase); + + return Task.CompletedTask; } - public async override Task AfterRunningAllTestsAsync(TestResults results) + public override Task AfterRunningAllTestsAsync(TestResults results) { var settings = new XmlWriterSettings(); settings.Indent = true; @@ -126,8 +140,10 @@ public async override Task AfterRunningAllTestsAsync(TestResults results) writer.WriteStartElement("testsuite"); writer.WriteAttributeString("name", "dotnet"); +#pragma warning disable CA1305 // Specify IFormatProvider writer.WriteAttributeString("tests", _testCases.Count.ToString()); writer.WriteAttributeString("failures", _testCases.Where(t => t.Failed).Count().ToString()); +#pragma warning restore CA1305 // Specify IFormatProvider writer.WriteAttributeString("errors", "0"); foreach (var testCase in _testCases) @@ -168,9 +184,10 @@ public async override Task AfterRunningAllTestsAsync(TestResults results) writer.WriteEndDocument(); writer.Close(); } + return Task.CompletedTask; } - private string RemoveInvalidXmlCharacters(string input) + private static string RemoveInvalidXmlCharacters(string input) { return Regex.Replace(input, @"[\u0000-\u0008,\u000B,\u000C,\u000E-\u001F]", ""); } diff --git a/Turkey/TestParser.cs b/Turkey/TestParser.cs index af59eda..71b25c7 100644 --- a/Turkey/TestParser.cs +++ b/Turkey/TestParser.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.Linq; +using System.Reflection.Metadata.Ecma335; using System.Threading.Tasks; using Newtonsoft.Json; @@ -15,7 +16,9 @@ public class TestParser return TryParseAsync(system, nuGetConfig, dir, File.ReadAllText(testConfiguration.FullName)); } - public async Task<(bool Success, Test Test)> TryParseAsync(SystemUnderTest system, string nuGetConfig, DirectoryInfo directory, string testConfiguration) +#pragma warning disable CA1801 // Remove unused parameter + public Task<(bool Success, Test Test)> TryParseAsync(SystemUnderTest system, string nuGetConfig, DirectoryInfo directory, string testConfiguration) +#pragma warning restore CA1801 // Remove unused parameter { // TODO: async var fileName = Path.Combine(directory.FullName, "test.json"); @@ -32,12 +35,12 @@ public class TestParser { case "xunit": test = new XUnitTest(directory, system, nuGetConfig, descriptor, enabled); - return (true, test); + return Task.FromResult((true, test)); case "bash": test = new BashTest(directory, system, nuGetConfig, descriptor, enabled); - return (true, test); + return Task.FromResult((true, test)); default: - return (false, null); + return Task.FromResult((false, (Test)null)); } } @@ -98,7 +101,9 @@ public bool ShouldRunTest(SystemUnderTest system, TestDescriptor test) } +#pragma warning disable CA1822 // Mark members as static private bool VersionMatches(TestDescriptor test, Version runtimeVersion) +#pragma warning restore CA1822 // Mark members as static { if (test.VersionSpecific) { diff --git a/Turkey/TestRunner.cs b/Turkey/TestRunner.cs index 13ce46b..929e13f 100644 --- a/Turkey/TestRunner.cs +++ b/Turkey/TestRunner.cs @@ -22,7 +22,7 @@ public class SystemUnderTest public Version RuntimeVersion { get; } public Version SdkVersion { get; } public List CurrentPlatformIds { get; } - public IReadOnlyDictionary EnvironmentVariables; + internal IReadOnlyDictionary EnvironmentVariables; public IReadOnlySet Traits { get; } public DotNet Dotnet { get; } @@ -44,12 +44,12 @@ public SystemUnderTest(DotNet dotnet, public class TestOutput { - public async virtual Task AtStartupAsync() {} - public async virtual Task BeforeTestAsync() {} - public async virtual Task AfterParsingTestAsync(string name, bool enabled) {} - public async virtual Task AfterRunningTestAsync(string name, TestResult result, StringBuilder testLog, TimeSpan testTime) {} - public async virtual Task PrintFailedTests() {} - public async virtual Task AfterRunningAllTestsAsync(TestResults results) {} + public virtual Task AtStartupAsync() { return Task.CompletedTask; } + public virtual Task BeforeTestAsync() { return Task.CompletedTask; } + public virtual Task AfterParsingTestAsync(string name, bool enabled) { return Task.CompletedTask; } + public virtual Task AfterRunningTestAsync(string name, TestResult result, StringBuilder testLog, TimeSpan testTime) { return Task.CompletedTask; } + public virtual Task PrintFailedTests() { return Task.CompletedTask; } + public virtual Task AfterRunningAllTestsAsync(TestResults results) { return Task.CompletedTask; } } public class TestRunner @@ -72,7 +72,7 @@ public TestRunner(SystemUnderTest system, DirectoryInfo root, bool verboseOutput public async Task ScanAndRunAsync(List outputs, string logDir, TimeSpan defaultTimeout) { - await outputs.ForEachAsync(output => output.AtStartupAsync()); + await outputs.ForEachAsync(output => output.AtStartupAsync()).ConfigureAwait(false); TestResults results = new TestResults(); @@ -93,10 +93,10 @@ public async Task ScanAndRunAsync(List outputs, string foreach (var file in sortedFiles) { testTimeWatch.Reset(); - await cleaner.CleanLocalDotNetCacheAsync(); + await cleaner.CleanLocalDotNetCacheAsync().ConfigureAwait(false); testTimeWatch.Start(); - var parsedTest = await parser.TryParseAsync(system, nuGetConfig, file); + var parsedTest = await parser.TryParseAsync(system, nuGetConfig, file).ConfigureAwait(false); if (!parsedTest.Success) { Console.WriteLine($"WARNING: Unable to parse {file}"); @@ -105,7 +105,7 @@ public async Task ScanAndRunAsync(List outputs, string var test = parsedTest.Test; string testName = test.Descriptor.Name; - await outputs.ForEachAsync(output => output.AfterParsingTestAsync(testName, !test.Skip)); + await outputs.ForEachAsync(output => output.AfterParsingTestAsync(testName, !test.Skip)).ConfigureAwait(false); TimeSpan testTimeout = test.Descriptor.TimeoutMultiplier * defaultTimeout; using var cts = testTimeout == TimeSpan.Zero ? null : new CancellationTokenSource(testTimeout); @@ -125,13 +125,13 @@ public async Task ScanAndRunAsync(List outputs, string if (test.Descriptor.Cleanup) { - await cleaner.CleanProjectLocalDotNetCruftAsync(); + await cleaner.CleanProjectLocalDotNetCruftAsync().ConfigureAwait(false); } TestResult testResult; try { - testResult = await test.RunAsync(testLogger, cancellationToken); + testResult = await test.RunAsync(testLogger, cancellationToken).ConfigureAwait(false); } catch (OperationCanceledException) { @@ -149,15 +149,15 @@ public async Task ScanAndRunAsync(List outputs, string case TestResult.Skipped: results.Skipped++; break; } - await outputs.ForEachAsync(output => output.AfterRunningTestAsync(testName, testResult, testLog, testTimeWatch.Elapsed)); + await outputs.ForEachAsync(output => output.AfterRunningTestAsync(testName, testResult, testLog, testTimeWatch.Elapsed)).ConfigureAwait(false); } if (results.Failed != 0 ) { - await outputs.ForEachAsync(outputs => outputs.PrintFailedTests()); + await outputs.ForEachAsync(outputs => outputs.PrintFailedTests()).ConfigureAwait(false); } - await outputs.ForEachAsync(output => output.AfterRunningAllTestsAsync(results)); + await outputs.ForEachAsync(output => output.AfterRunningAllTestsAsync(results)).ConfigureAwait(false); return results; } diff --git a/Turkey/Version.cs b/Turkey/Version.cs index 7b95170..0bcbd18 100644 --- a/Turkey/Version.cs +++ b/Turkey/Version.cs @@ -134,7 +134,9 @@ private static int CompareTo(Version v1, Version v2) public override int GetHashCode() { +#pragma warning disable CA1065 // Do not raise exceptions in unexpected locations throw new NotImplementedException(); +#pragma warning restore CA1065 // Do not raise exceptions in unexpected locations } } diff --git a/Turkey/XUnitTest.cs b/Turkey/XUnitTest.cs index 1834f82..2232407 100644 --- a/Turkey/XUnitTest.cs +++ b/Turkey/XUnitTest.cs @@ -16,8 +16,8 @@ public XUnitTest(DirectoryInfo directory, SystemUnderTest system, string nuGetCo protected override async Task InternalRunAsync(Action logger, CancellationToken cancellationToken) { - bool success = await BuildProjectAsync(logger, cancellationToken) == 0 - && await RunTestProjectAsync(logger, cancellationToken) == 0; + bool success = await BuildProjectAsync(logger, cancellationToken).ConfigureAwait(false) == 0 + && await RunTestProjectAsync(logger, cancellationToken).ConfigureAwait(false) == 0; return success ? TestResult.Passed : TestResult.Failed; }