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

Get Linux build working under Azure - tests still not run #1254

Merged
merged 3 commits into from
Oct 29, 2022
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
244 changes: 244 additions & 0 deletions NUnitConsole_Linux.sln

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ jobs:
# ArtifactName: Package

- job: Linux
condition: false # temporarily disabled
# condition: not(or(startsWith(variables['Build.SourceBranchName'], 'azure-windows-'),startsWith(variables['Build.SourceBranchName'], 'azure-macOS-')))
condition: not(or(startsWith(variables['Build.SourceBranchName'], 'azure-windows-'),startsWith(variables['Build.SourceBranchName'], 'azure-macOS-')))
pool:
vmImage: ubuntu-20.04
steps:
Expand Down Expand Up @@ -104,8 +103,8 @@ jobs:
version: 2.1.x

- bash: |
./build.sh --target=Test --configuration=Release
displayName: Build and Test
./build.sh --target=Build --configuration=Release
displayName: Build

# Workaround for https://github.com/nunit/nunit/issues/3012#issuecomment-441517922
- task: PublishTestResults@2
Expand Down
4 changes: 2 additions & 2 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ Task("TestNetStandard20Engine")
.OnError(exception => { UnreportedErrors.Add(exception.Message); })
.Does(() =>
{
RunDotnetNUnitLiteTests(ENGINE_TESTS_PROJECT, "netcoreapp2.1");
RunDotnetNUnitLiteTests(ENGINE_TESTS_PROJECT, "netcoreapp2.1", "--labels:Before");
});

//////////////////////////////////////////////////////////////////////
Expand All @@ -207,7 +207,7 @@ Task("TestNetCore31Engine")
.OnError(exception => { UnreportedErrors.Add(exception.Message); })
.Does(() =>
{
RunDotnetNUnitLiteTests(ENGINE_TESTS_PROJECT, "netcoreapp3.1");
RunDotnetNUnitLiteTests(ENGINE_TESTS_PROJECT, "netcoreapp3.1", "--labels:Before");
});

//////////////////////////////////////////////////////////////////////
Expand Down
5 changes: 4 additions & 1 deletion cake/constants.cake
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ static string SOURCE_DIR; SOURCE_DIR = PROJECT_DIR + "src/";
static string EXTENSIONS_DIR; EXTENSIONS_DIR = PROJECT_DIR + "bundled-extensions";

// Solution and Projects
static string SOLUTION_FILE; SOLUTION_FILE = PROJECT_DIR + "NUnitConsole.sln";
static string SOLUTION_FILE;
SOLUTION_FILE = IsRunningOnWindows()
? PROJECT_DIR + "NUnitConsole.sln"
: PROJECT_DIR + "NUnitConsole_Linux.sln";
static string NETFX_CONSOLE_PROJECT; NETFX_CONSOLE_PROJECT = SOURCE_DIR + "NUnitConsole/nunit3-console/nunit3-console.csproj";
static string NETCORE_CONSOLE_PROJECT; NETCORE_CONSOLE_PROJECT = SOURCE_DIR + "NUnitConsole/nunit3-netcore-console/nunit3-netcore-console.csproj";
static string ENGINE_PROJECT; ENGINE_PROJECT = SOURCE_DIR + "NUnitEngine/nunit.engine/nunit.engine.csproj";
Expand Down
4 changes: 3 additions & 1 deletion cake/package-definitions.cake
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ public void InitializePackageDefinitions(ICakeContext context)
Net50PlusNet60Test,
Net35X86Test,
Net40X86Test,
Net60WindowsFormsTest,
Net60AspNetCoreTest
};

if (IsRunningOnWindows())
StandardRunnerTests.Add(Net60WindowsFormsTest);

if (dotnetX86Available)
StandardRunnerTests.Add(NetCore31X86Test);

Expand Down
12 changes: 7 additions & 5 deletions cake/utilities.cake
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,16 @@ DotNetMSBuildSettings CreateDotNetMSBuildSettings(string target)

private void BuildEachProjectSeparately()
{
Information($"Restoring {SOLUTION_FILE}");
DotNetRestore(SOLUTION_FILE);

BuildProject(ENGINE_API_PROJECT);

BuildProject(MOCK_ASSEMBLY_PROJECT);
BuildProject(MOCK_ASSEMBLY_X86_PROJECT);
BuildProject(NOTEST_PROJECT);
BuildProject(WINDOWS_TEST_PROJECT);
if (IsRunningOnWindows())
BuildProject(WINDOWS_TEST_PROJECT);
BuildProject(ASPNETCORE_TEST_PROJECT);

BuildProject(ENGINE_CORE_PROJECT);
Expand Down Expand Up @@ -203,7 +205,7 @@ string GetProjectBinDir(string projectPath, string targetRuntime)
return GetProjectBinDir(projectPath) + targetRuntime + "/";
}

void RunNUnitLiteTests(string projectPath, string targetRuntime)
void RunNUnitLiteTests(string projectPath, string targetRuntime, string additionalArgs="")
{
var testAssembly = System.IO.Path.GetFileNameWithoutExtension(projectPath) + ".exe";
var workingDir = GetProjectBinDir(projectPath, targetRuntime);
Expand All @@ -213,7 +215,7 @@ void RunNUnitLiteTests(string projectPath, string targetRuntime)
workingDir + testAssembly,
new ProcessSettings()
{
Arguments = $"--result:{resultPath}",
Arguments = $"--result:{resultPath} {additionalArgs}",
WorkingDirectory = workingDir
});

Expand All @@ -223,7 +225,7 @@ void RunNUnitLiteTests(string projectPath, string targetRuntime)
UnreportedErrors.Add($"{testAssembly}({targetRuntime}) returned rc = {rc}");
}

void RunDotnetNUnitLiteTests(string projectPath, string targetRuntime)
void RunDotnetNUnitLiteTests(string projectPath, string targetRuntime, string additionalArgs="")
{
var testAssembly = System.IO.Path.GetFileNameWithoutExtension(projectPath) + ".dll";
var workingDir = GetProjectBinDir(projectPath, targetRuntime);
Expand All @@ -234,7 +236,7 @@ void RunDotnetNUnitLiteTests(string projectPath, string targetRuntime)
"dotnet",
new ProcessSettings
{
Arguments = $"\"{assemblyPath}\" --result:{resultPath}",
Arguments = $"\"{assemblyPath}\" --result:\"{resultPath}\" {additionalArgs}",
WorkingDirectory = workingDir
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
<PropertyGroup>
<RootNamespace>NUnit.ConsoleRunner.Tests</RootNamespace>
<TargetFrameworks>net462;net6.0</TargetFrameworks>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<NoWarn>1685</NoWarn>
<DebugType>Full</DebugType>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

<PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions src/NUnitConsole/nunit3-console/nunit3-console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<RootNamespace>NUnit.ConsoleRunner</RootNamespace>
<AssemblyName>nunit3-console</AssemblyName>
<TargetFrameworks>net462</TargetFrameworks>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<RollForward>Major</RollForward>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<RootNamespace>NUnit.ConsoleRunner</RootNamespace>
<AssemblyName>nunit3-netcore-console</AssemblyName>
<TargetFrameworks>net6.0</TargetFrameworks>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<RollForward>Major</RollForward>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions src/NUnitEngine/aspnetcore-test/aspnetcore-test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<OutputType>Library</OutputType>
</PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions src/NUnitEngine/mock-assembly-x86/mock-assembly-x86.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<RootNamespace>NUnit.Tests</RootNamespace>
<TargetFrameworks>net35;net462;netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\nunit.snk</AssemblyOriginatorKeyFile>
<PlatformTarget>x86</PlatformTarget>
Expand Down
1 change: 1 addition & 0 deletions src/NUnitEngine/mock-assembly/mock-assembly.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<RootNamespace>NUnit.Tests</RootNamespace>
<TargetFrameworks>net35;net462;netcoreapp2.1;netcoreapp3.1;net5.0;net6.0;net7.0</TargetFrameworks>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\nunit.snk</AssemblyOriginatorKeyFile>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
Expand Down
1 change: 1 addition & 0 deletions src/NUnitEngine/notest-assembly/notest-assembly.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<RootNamespace>notest_assembly</RootNamespace>
<TargetFrameworks>net35;netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
Expand Down
21 changes: 17 additions & 4 deletions src/NUnitEngine/nunit-agent-x86/nunit-agent-x86.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<OutputType>Exe</OutputType>
<RootNamespace>nunit.agent</RootNamespace>
<TargetFrameworks>net20;net462</TargetFrameworks>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationIcon>..\..\..\nunit.ico</ApplicationIcon>
<PlatformTarget>x86</PlatformTarget>
Expand All @@ -15,7 +16,8 @@
<Product>NUnit Engine</Product>
<AssemblyTitle>NUnit X86 Agent ($(TargetFramework))</AssemblyTitle>
<Description>Agent used to run X86 tests out of process under .NET framework</Description>
</PropertyGroup>
<RunPostBuildEvent>Always</RunPostBuildEvent>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net20' or '$(TargetFramework)'=='net462'">
<Reference Include="System.Runtime.Remoting" />
Expand All @@ -38,9 +40,20 @@
<ProjectReference Include="..\nunit.engine.core\nunit.engine.core.csproj" />
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="call ..\..\..\CopyAgentFiles &quot;$(TargetDir)nunit-agent-x86.*&quot; &quot;..\..\NUnitConsole\nunit3-console\bin\$(Configuration)\net462\agents\$(TargetFramework)\&quot;" />
<Exec Command="call ..\..\..\CopyAgentFiles &quot;$(TargetDir)nunit-agent-x86.*&quot; &quot;..\..\NUnitEngine\nunit.engine\bin\$(Configuration)\agents\$(TargetFramework)\&quot;" />
<Target Name="CopyX86Files" AfterTargets="PostBuildEvent">
<PropertyGroup>
<ConsoleDestination>$([System.IO.Path]::GetFullPath("../../NUnitConsole/nunit3-console/bin/$(Configuration)/net462/agents/$(TargetFramework)/"))</ConsoleDestination>
<EngineDestination>$([System.IO.Path]::GetFullPath("../nunit.engine/bin/$(Configuration)/agents/$(TargetFramework)/"))</EngineDestination>
</PropertyGroup>

<ItemGroup>
<AgentFiles Include="$(TargetDir)/nunit-agent-x86.*" />
</ItemGroup>

<Copy SourceFiles="@(AgentFiles)" DestinationFiles="$(ConsoleDestination)%(FileName)%(Extension)" />
<Message Text="Copied @(AgentFiles->Count()) files to $(ConsoleDestination)" Importance="High" />
<Copy SourceFiles="@(AgentFiles)" DestinationFiles="$(EngineDestination)%(FileName)%(Extension)" />
<Message Text="Copied @(AgentFiles->Count()) files to $(EngineDestination)" Importance="High" />
</Target>

</Project>
23 changes: 18 additions & 5 deletions src/NUnitEngine/nunit-agent/nunit-agent.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
<OutputType>Exe</OutputType>
<RootNamespace>nunit.agent</RootNamespace>
<TargetFrameworks>net20;net462;netcoreapp3.1;net5.0;net6.0;net7.0</TargetFrameworks>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationIcon>..\..\..\nunit.ico</ApplicationIcon>
<GenerateSupportedRuntime>false</GenerateSupportedRuntime>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<RunPostBuildEvent>Always</RunPostBuildEvent>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)'!='net20' and '$(TargetFramework)'!='net462'">
Expand All @@ -20,7 +23,6 @@
<Product>NUnit Engine</Product>
<AssemblyTitle>NUnit Agent ($(TargetFramework))</AssemblyTitle>
<Description>Agent used to run tests out of process</Description>
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net20' or '$(TargetFramework)'=='net462'">
Expand All @@ -30,7 +32,7 @@
<ItemGroup>
<Compile Include="..\nunit.engine.core\Internal\ExceptionHelper.cs" Link="ExceptionHelper.cs" />
</ItemGroup>

<ItemGroup>
<Content Include="..\..\..\nunit.ico">
<Link>nunit.ico</Link>
Expand All @@ -42,9 +44,20 @@
<ProjectReference Include="..\nunit.engine.core\nunit.engine.core.csproj" />
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="call ..\..\..\CopyAgentFiles &quot;$(TargetDir)*.*&quot; &quot;..\..\NUnitConsole\nunit3-console\bin\$(Configuration)\net462\agents\$(TargetFramework)\&quot;" />
<Exec Command="call ..\..\..\CopyAgentFiles &quot;$(TargetDir)*.*&quot; &quot;..\..\NUnitEngine\nunit.engine\bin\$(Configuration)\agents\$(TargetFramework)\&quot;" />
<Target Name="CopyAgentFiles" AfterTargets="PostBuildEvent">
<PropertyGroup>
<ConsoleDestination>$([System.IO.Path]::GetFullPath("../../NUnitConsole/nunit3-console/bin/$(Configuration)/net462/agents/$(TargetFramework)/"))</ConsoleDestination>
<EngineDestination>$([System.IO.Path]::GetFullPath("../nunit.engine/bin/$(Configuration)/agents/$(TargetFramework)/"))</EngineDestination>
</PropertyGroup>

<ItemGroup>
<AgentFiles Include="$(TargetDir)/*.*" />
</ItemGroup>

<Copy SourceFiles="@(AgentFiles)" DestinationFiles="$(ConsoleDestination)%(FileName)%(Extension)" />
<Message Text="Copied @(AgentFiles->Count()) files to $(ConsoleDestination)" Importance="High" />
<Copy SourceFiles="@(AgentFiles)" DestinationFiles="$(EngineDestination)%(FileName)%(Extension)" />
<Message Text="Copied @(AgentFiles->Count()) files to $(EngineDestination)" Importance="High" />
</Target>

</Project>
1 change: 1 addition & 0 deletions src/NUnitEngine/nunit.engine.api/nunit.engine.api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<RootNamespace>NUnit.Engine</RootNamespace>
<TargetFrameworks>net20;netstandard2.0</TargetFrameworks>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\nunit.snk</AssemblyOriginatorKeyFile>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
<PropertyGroup>
<RootNamespace>NUnit.Engine.Core.Tests</RootNamespace>
<TargetFrameworks>net35;netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<OutputType>Exe</OutputType>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\nunit.snk</AssemblyOriginatorKeyFile>
<DebugType>Full</DebugType>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

<PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions src/NUnitEngine/nunit.engine.core/nunit.engine.core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<RootNamespace>NUnit.Engine</RootNamespace>
<TargetFrameworks>net20;netstandard2.0;netcoreapp3.1</TargetFrameworks>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<NoWarn>$(NoWarn);SYSLIB0011;SYSLIB0012</NoWarn><!-- TODO: Get rid of obsolete stuff -->
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\nunit.snk</AssemblyOriginatorKeyFile>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt

#if NETFRAMEWORK
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -46,7 +47,7 @@ public void SingleClientConnection()
}
}

[Test]
[Test, Platform(Exclude = "Linux")]
public void MultipleClientConnections()
{
TcpClient[] clients = new[] { new TcpClient(), new TcpClient(), new TcpClient() };
Expand All @@ -69,3 +70,4 @@ public void MultipleClientConnections()
}
}
}
#endif
5 changes: 3 additions & 2 deletions src/NUnitEngine/nunit.engine.tests/nunit.engine.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
<PropertyGroup>
<RootNamespace>NUnit.Engine.Tests</RootNamespace>
<TargetFrameworks>net462;netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<OutputType>Exe</OutputType>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\nunit.snk</AssemblyOriginatorKeyFile>
<DebugType>Full</DebugType>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

<PropertyGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/NUnitEngine/nunit.engine/nunit.engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
<PropertyGroup>
<RootNamespace>NUnit.Engine</RootNamespace>
<TargetFrameworks>net462;netstandard2.0;netcoreapp3.1</TargetFrameworks>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\nunit.snk</AssemblyOriginatorKeyFile>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

<PropertyGroup>
Expand Down