Skip to content
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

Don't try to run tests from SIL.LCModel.Utils.Tests #420

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/windows@v2
with:
files: '**/TestResults.xml'
files: '**/*TestResults.trx'

- name: Create NuGet packages
shell: cmd
Expand Down
30 changes: 8 additions & 22 deletions build/FLExBridge.proj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build;Pack">
<PropertyGroup>
<RootDir Condition="'$(teamcity_build_checkoutDir)' == '' And '$(RootDir)'==''">$(MSBuildProjectDirectory)/..</RootDir>
<RootDir Condition="'$(teamcity_build_checkoutDir)' != ''">$(teamcity_build_checkoutDir)</RootDir>
<RootDir>$(MSBuildProjectDirectory)/..</RootDir>
<Configuration Condition="'$(Configuration)'==''">Debug</Configuration>
<Platform>Any CPU</Platform>
<Solution>FLExBridge.sln</Solution>
Expand All @@ -10,24 +9,19 @@
<BUILD_VCS_NUMBER Condition="'$(BUILD_VCS_NUMBER)' == ''">0</BUILD_VCS_NUMBER>
<BUILD_NUMBER Condition="'$(BUILD_NUMBER)' == ''">0</BUILD_NUMBER>
<ExtraExcludeCategories Condition="'$(OS)'!='Windows_NT'">KnownMonoIssue,UnknownMonoIssue</ExtraExcludeCategories>
<ExtraExcludeCategories Condition="'$(teamcity_version)' != ''">SkipOnTeamCity,$(ExtraExcludeCategories)</ExtraExcludeCategories>
<ExtraExcludeCategories Condition="'$(GITHUB_ACTIONS)' != ''">SkipOnCI,$(ExtraExcludeCategories)</ExtraExcludeCategories>
<Release Condition="'$(Release)' == ''">true</Release>
<PalasoVer4LinuxGecko Condition="'$(OS)'!='Windows_NT'">10.0.0-beta0081</PalasoVer4LinuxGecko>
<GitVersionMsBuildProps>$(RootDir)/packages/GitVersion.MsBuild/build/GitVersion.MsBuild.props</GitVersionMsBuildProps>
<GitVersionMsBuildTargets>$(RootDir)/packages/GitVersion.MsBuild/build/GitVersion.MsBuild.targets</GitVersionMsBuildTargets>
<SILBuildTasksDLL>$(RootDir)/packages/SIL.BuildTasks/tools/SIL.BuildTasks.dll</SILBuildTasksDLL>
<SILReleaseTasksProps>$(RootDir)/packages/SIL.ReleaseTasks/build/SIL.ReleaseTasks.props</SILReleaseTasksProps>
<NUnitToolsDir>$(RootDir)/packages/NUnit.ConsoleRunner/tools</NUnitToolsDir>
<NUnitConsoleRunner>$(NUnitToolsDir)/nunit3-console.exe</NUnitConsoleRunner>
<BuildDependencyTasksDLL>$(RootDir)/packages/BuildDependencyTasks/BuildDependencyTasks.dll</BuildDependencyTasksDLL>
<RestartBuild Condition="!Exists('$(GitVersionMsBuildProps)') Or !Exists('$(GitVersionMsBuildTargets)') Or !Exists('$(SILBuildTasksDLL)') Or !Exists('$(SILReleaseTasksProps)') Or !Exists('$(NUnitConsoleRunner)') Or !Exists('$(BuildDependencyTasksDLL)')">true</RestartBuild>
<RestartBuild Condition="Exists('$(GitVersionMsBuildProps)') And Exists('$(GitVersionMsBuildTargets)') And Exists('$(SILBuildTasksDLL)') And Exists('$(SILReleaseTasksProps)') And Exists('$(NUnitConsoleRunner)') And Exists('$(BuildDependencyTasksDLL)')">false</RestartBuild>
<IgnoreGitVersionTask Condition="'$(IgnoreGitVersionTask)' == ''">false</IgnoreGitVersionTask>
<MSBuildTasksTargets>$(RootDir)/packages/MSBuildTasks.1.5.0.235/tools/MSBuild.Community.Tasks.Targets</MSBuildTasksTargets>
<GetVersion Condition="'$(GetVersion)' == ''">true</GetVersion>
<WriteVersionInfoToBuildLog Condition="'$(WriteVersionInfoToBuildLog)' == ''">true</WriteVersionInfoToBuildLog>
<TeamCity Condition="'$(teamcity_version)' != ''">true</TeamCity>
<TeamCity Condition="'$(teamcity_version)' == ''">false</TeamCity>
<!-- note this does not set the TargetFramework for the csproj files, it's just used as a variable to configure build paths-->
<TargetFramework Condition="'$(TargetFramework)' == ''">net462</TargetFramework>
</PropertyGroup>
Expand All @@ -44,9 +38,6 @@
<UsingTask TaskName="Split" AssemblyFile="$(SILBuildTasksDLL)" Condition="Exists('$(SILBuildTasksDLL)')"/>
<UsingTask TaskName="SIL.BuildTasks.FileUpdate" AssemblyFile="$(SILBuildTasksDLL)" Condition="Exists('$(SILBuildTasksDLL)')"/>
<UsingTask TaskName="MakeWixForDirTree" AssemblyFile="$(SILBuildTasksDLL)" Condition="Exists('$(SILBuildTasksDLL)') And '$(OS)'=='Windows_NT'"/>
<UsingTask TaskName="NUnit3"
AssemblyFile="$(SILBuildTasksDLL)"
Condition="Exists('$(SILBuildTasksDLL)')" />

<!-- a few do-nothing targets to get rid of some warnings from GitVersion.MsBuild.targets -->
<Target Name="GetAssemblyVersion"/>
Expand Down Expand Up @@ -203,19 +194,14 @@

<Target Name="TestOnly">
<ItemGroup>
<TestAssemblies Include="$(RootDir)/output/$(Configuration)/$(TargetFramework)/*Tests.dll" />
<!-- Include test assemblies and exclude unwanted ones -->
<TestAssemblies Include="$(RootDir)/output/$(Configuration)/$(TargetFramework)/*Tests.dll"
Exclude="**/SIL.LCModel.Utils.Tests.dll" />
</ItemGroup>

<NUnit3 Assemblies="@(TestAssemblies)"
ToolPath="$(NUnitToolsDir)"
TestInNewThread="false"
ExcludeCategory="$(ExtraExcludeCategories)"
WorkingDirectory="$(RootDir)/output/$(Configuration)/$(TargetFramework)"
Process="single"
Verbose="true"
UseNUnit3Xml="false"
OutputXmlFile="$(RootDir)/output/$(Configuration)/$(TargetFramework)/TestResults.xml"
TeamCity="$(TeamCity)"/>
<!-- Loop over each TestAssembly and execute dotnet test -->
<Exec Command="dotnet test --no-build --verbosity detailed --logger &quot;trx;LogFileName=%(TestAssemblies.Filename)TestResults.trx&quot; --filter &quot;TestCategory!=$(ExtraExcludeCategories)&quot; &quot;%(TestAssemblies.FullPath)&quot;"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

escaping stuff sucks, could you do this instead?

Suggested change
<Exec Command="dotnet test --no-build --verbosity detailed --logger &quot;trx;LogFileName=%(TestAssemblies.Filename)TestResults.trx&quot; --filter &quot;TestCategory!=$(ExtraExcludeCategories)&quot; &quot;%(TestAssemblies.FullPath)&quot;"
<PropertyGroup>
<_RunTestsCommand>dotnet test --no-build --verbosity detailed --logger "trx;LogFileName=%(TestAssemblies.Filename)TestResults.trx" --filter "TestCategory!=$(ExtraExcludeCategories)" "%(TestAssemblies.FullPath)"</_RunTestsCommand>
</PropertyGroup>
<!-- Loop over each TestAssembly and execute dotnet test -->
<Exec Command="$(_RunTestsCommand)"

I'm not too familiar with msbuild so I'm not sure if that would work but it would be much more maintinable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, escaping stuff isn't my favorite, but in this case I think it is necessary.
Your suggestion wouldn't work because it would defeat the batching. Actually, the error you got is probably because the metadata expansion isn't valid in a PropertyGroup.
https://learn.microsoft.com/en-us/visualstudio/msbuild/item-metadata-in-task-batching?view=vs-2022

Condition="Exists('%(TestAssemblies.FullPath)')" />
</Target>

<Target Name="Pack" DependsOnTargets="RestorePackages">
Expand Down