Skip to content

Commit

Permalink
Infra: Update the UTs and ITs to be able to run on .NET 9 preview (#2166
Browse files Browse the repository at this point in the history
)
  • Loading branch information
costin-zaharia-sonarsource authored Sep 4, 2024
1 parent ebdc8b9 commit 951bb9f
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ public void E2E_TestProjects_ProtobufsUpdated()
// Assert
result.AssertTargetExecuted("FixUpTestProjectOutputs");

var protobufDir = Path.Combine(result.GetPropertyValue("ProjectSpecificOutDir"), "subdir1");
var protobufDir = Path.Combine(result.GetPropertyValue(TargetProperties.ProjectSpecificOutDir), "subdir1");

AssertFilesExistsAndAreNotEmpty(protobufDir, "encoding.pb", "file-metadata.pb", "symrefs.pb", "token-type.pb");
AssertFilesExistsAndAreEmpty(protobufDir, "metrics.pb", "token-cpd.pb");
Expand All @@ -841,7 +841,7 @@ public void E2E_NonTestProjects_ProtobufsNotUpdated()
// Assert
result.AssertTargetNotExecuted("FixUpTestProjectOutputs");

var protobufDir = Path.Combine(result.GetPropertyValue("ProjectSpecificOutDir"), "subdir2");
var protobufDir = Path.Combine(result.GetPropertyValue(TargetProperties.ProjectSpecificOutDir), "subdir2");

// Protobufs should not changed for non-test project
AssertFilesExistsAndAreNotEmpty(protobufDir, protobufFileNames);
Expand Down Expand Up @@ -899,7 +899,7 @@ but before the targets that modify the protobufs are executed -->
// Sanity check that the above target was executed
result.AssertTargetExecuted("CreateDummyProtobufFiles");

var projectSpecificOutputDir2 = result.GetPropertyValue("ProjectSpecificOutDir");
var projectSpecificOutputDir2 = result.GetPropertyValue(TargetProperties.ProjectSpecificOutDir);
projectSpecificOutputDir2.Should().Be(actualStructure.ProjectSpecificOutputDir);

AssertNoAdditionalFilesInFolder(actualStructure.ProjectSpecificOutputDir, protobufFileNames.Concat(new[] { ExpectedAnalysisFilesListFileName, ExpectedIssuesFileName, FileConstants.ProjectInfoFileName }).ToArray());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ internal static class TargetProperties
public const string AdditionalFilesItemType = "AdditionalFiles";

public const string SonarProjectOutFolderFilePath = "SonarProjectOutFolderFilePath";
public const string SonarProjectConfigFilePath = "SonarProjectConfigFilePath";
public const string ProjectSpecificOutDir = "ProjectSpecificOutDir";
public const string SonarProjectConfigFilePath = "SonarProjectConfigFilePath from parameter ProjectConfigFilePath"; // Issue in the MsBuild structured logger.
public const string ProjectSpecificOutDir = "ProjectSpecificOutDir from parameter UniquePath"; // Issue in the MsBuild structured logger.
public const string ProjectSpecificConfDir = "ProjectSpecificConfDir";

// Legacy TeamBuild environment variables (XAML Builds)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Build.Framework" Version="17.8.3" />
<PackageReference Include="MSBuild.StructuredLogger" Version="2.2.243" />
<PackageReference Include="MSBuild.StructuredLogger" Version="2.2.291" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.5.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.5.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ public void TargetExecutionOrder()
private static void AssertErrorLogIsSetBySonarQubeTargets(BuildLog result)
{
var projectSpecificOutDir = result.GetPropertyValue(TargetProperties.ProjectSpecificOutDir);
AssertExpectedErrorLog(result, projectSpecificOutDir + @"\Issues.json");
AssertExpectedErrorLog(result, Path.Combine(projectSpecificOutDir, "Issues.json"));
}

private static void AssertExpectedErrorLog(BuildLog result, string expectedErrorLog) =>
Expand Down
6 changes: 0 additions & 6 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ variables:
# pipelines-yaml-templates/promote-stage.yml line 56
- name: IS_RELEASE_BRANCH
value: ${{ or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), startsWith(variables['Build.SourceBranch'], 'refs/heads/branch-')) }}
- name: MSBUILD_15_PATH
value: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\MSBuild\\15.0\\Bin\\MSBuild.exe"
- name: MSBUILD_16_PATH
value: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\MSBuild\\Current\\Bin\\MSBuild.exe"
- name: MSBUILD_17_PATH
value: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\MSBuild\\Current\\Bin\\MSBuild.exe"
- name: BUILD_CONFIGURATION
value: "Release"
- name: BUILD_PLATFORM
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>net48</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion its/projects/ExcludedTest/Excluded/Excluded.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net48</TargetFramework>
<SonarQubeExclude>true</SonarQubeExclude>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion its/projects/ExcludedTest/Normal/Normal.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net48</TargetFramework>
</PropertyGroup>

</Project>
2 changes: 1 addition & 1 deletion its/projects/ExcludedTest/Test/Test.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net48</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net48</TargetFramework>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard1.6</TargetFramework>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
</PropertyGroup>

Expand Down

0 comments on commit 951bb9f

Please sign in to comment.