Add tests to CI

This commit is contained in:
Wojciech Figat
2022-01-14 14:20:41 +01:00
parent d032f18b71
commit 992333fd64
17 changed files with 169 additions and 8 deletions

32
.github/workflows/tests.yml vendored Normal file
View File

@@ -0,0 +1,32 @@
name: Tests
on: [push, pull_request]
jobs:
# Tests
tests-linux:
name: Tests (Linux)
runs-on: "ubuntu-20.04"
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Checkout LFS
run: |
git lfs version
git lfs pull
- name: Install dependencies
run: |
sudo rm -f /etc/apt/sources.list.d/*
sudo cp -f .github/workflows/build_linux_sources.list /etc/apt/sources.list
sudo apt-get update
sudo apt-get install libx11-dev libxcursor-dev libxinerama-dev build-essential gettext libtool libtool-bin libpulse-dev libasound2-dev libjack-dev portaudio19-dev
- name: Build
run: |
./Development/Scripts/Linux/CallBuildTool.sh -build -log -arch=x64 -platform=Linux -configuration=Development -buildtargets=FlaxTestsTarget
./Development/Scripts/Linux/CallBuildTool.sh -build -log -arch=x64 -platform=Linux -configuration=Debug -buildtargets="FlaxEngine.Tests"
./Development/Scripts/Linux/CallBuildTool.sh -build -log -arch=x64 -platform=Linux -configuration=Debug -buildtargets="Flax.Build.Tests"
- name: Test
run: |
Binaries/Tests/Linux/x64/Development/FlaxTests
mono Source/Platforms/DotNet/NUnit/nunit3-console.exe Binaries/Tools/FlaxEngine.Tests.dll
mono Source/Platforms/DotNet/NUnit/nunit3-console.exe Binaries/Tools/Flax.Build.Tests.dll

BIN
Source/Platforms/DotNet/NUnit/agents/net40/nunit-agent.exe (Stored with Git LFS) Normal file

Binary file not shown.

View File

@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--
Nunit-agent only runs under .NET 2.0 or higher.
The setting useLegacyV2RuntimeActivationPolicy only applies
under .NET 4.0 and permits use of mixed mode assemblies,
which would otherwise not load correctly.
-->
<startup useLegacyV2RuntimeActivationPolicy="true">
<!--
Nunit-agent is normally run by the console or gui
runners and not independently. In normal usage,
the runner specifies which runtime should be used.
Do NOT add any supportedRuntime elements here,
since they may prevent the runner from controlling
the runtime that is used!
-->
</startup>
<runtime>
<!-- Ensure that test exceptions don't crash NUnit -->
<legacyUnhandledExceptionPolicy enabled="1" />
<!--
Since legacyUnhandledExceptionPolicy keeps the console from being killed even though an NUnit framework
test worker thread is killed, this is needed to prevent a hang. NUnit framework can only handle these
exceptions when this config element is present. (Or if future versions of NUnit framework drop support
for partial trust which would enable it to use [HandleProcessCorruptedStateExceptions].)
-->
<legacyCorruptedStateExceptionsPolicy enabled="true" />
<!-- Run partial trust V2 assemblies in full trust under .NET 4.0 -->
<loadFromRemoteSources enabled="true" />
<!-- Enable reading source information from Portable and Embedded PDBs when running applications -->
<!-- built against previous .NET Framework versions on .NET Framework 4.7.2 -->
<AppContextSwitchOverrides value="Switch.System.Diagnostics.IgnorePortablePDBsInStackTraces=false" />
</runtime>
</configuration>

View File

@@ -0,0 +1 @@
../../ # refer to the directory containing the engine and runner

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,6 @@
../../NUnit.Extension.*/**/tools/ # nuget v2 layout
../../../NUnit.Extension.*/**/tools/ # nuget v3 layout
../../../../NUnit.Extension.*/**/tools/
../../nunit.extension.*/**/tools/ # nuget v2 layout
../../../nunit.extension.*/**/tools/ # nuget v3 layout
../../../../nunit.extension.*/**/tools/

BIN
Source/Platforms/DotNet/NUnit/nunit.engine.api.dll (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Source/Platforms/DotNet/NUnit/nunit.engine.core.dll (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Source/Platforms/DotNet/NUnit/nunit.engine.dll (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Source/Platforms/DotNet/NUnit/nunit3-console.exe (Stored with Git LFS) Normal file

Binary file not shown.

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0.30319" />
</startup>
<runtime>
<legacyUnhandledExceptionPolicy enabled="1" />
<legacyCorruptedStateExceptionsPolicy enabled="true" />
<loadFromRemoteSources enabled="true" />
<AppContextSwitchOverrides value="Switch.System.Diagnostics.IgnorePortablePDBsInStackTraces=false" />
</runtime>
</configuration>

Binary file not shown.

View File

@@ -38,6 +38,10 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Flax.Build">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Binaries\Tools\Flax.Build.exe</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.12.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL"> <Reference Include="nunit.framework, Version=3.12.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll</HintPath> <HintPath>..\..\..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll</HintPath>
</Reference> </Reference>
@@ -47,12 +51,6 @@
<Compile Include="TestCommandLine.cs" /> <Compile Include="TestCommandLine.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Flax.Build\Flax.Build.csproj">
<Project>{c99aaf92-d4ad-4847-9ee0-b11e68e93e1e}</Project>
<Name>Flax.Build</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>

View File

@@ -228,6 +228,11 @@ namespace Flax.Build
var rules = GenerateRulesAssembly(); var rules = GenerateRulesAssembly();
var project = Globals.Project; var project = Globals.Project;
if (project == null)
{
Log.Warning("Missing project");
return true;
}
using (new ProfileEventScope("BuildTargets")) using (new ProfileEventScope("BuildTargets"))
{ {

View File

@@ -34,8 +34,8 @@ namespace Flax.Build.Projects.VisualStudio
var projectFileToolVersion = ProjectFileToolVersion; var projectFileToolVersion = ProjectFileToolVersion;
var projectDirectory = Path.GetDirectoryName(project.Path); var projectDirectory = Path.GetDirectoryName(project.Path);
var defaultTarget = project.Targets[0]; var defaultTarget = project.Targets[0];
var defaultConfiguration = defaultTarget.Configurations.First(); var defaultConfiguration = TargetConfiguration.Debug;
var defaultArchitecture = defaultTarget.Architectures.First(); var defaultArchitecture = TargetArchitecture.AnyCPU;
var projectTypes = ProjectTypeGuids.ToOption(ProjectTypeGuids.WindowsCSharp); var projectTypes = ProjectTypeGuids.ToOption(ProjectTypeGuids.WindowsCSharp);
if (vsProject.CSharp.UseFlaxVS && VisualStudioInstance.HasFlaxVS) if (vsProject.CSharp.UseFlaxVS && VisualStudioInstance.HasFlaxVS)
projectTypes = ProjectTypeGuids.ToOption(ProjectTypeGuids.FlaxVS) + ';' + projectTypes; projectTypes = ProjectTypeGuids.ToOption(ProjectTypeGuids.FlaxVS) + ';' + projectTypes;
@@ -75,6 +75,45 @@ namespace Flax.Build.Projects.VisualStudio
csProjectFileContent.AppendLine(" </PropertyGroup>"); csProjectFileContent.AppendLine(" </PropertyGroup>");
// Default configuration
{
var configuration = project.Configurations.First();
foreach (var e in project.Configurations)
{
if (e.Configuration == defaultConfiguration && e.Target == defaultTarget && e.Platform == Platform.BuildTargetPlatform)
{
configuration = e;
break;
}
}
var defines = string.Join(";", project.Defines);
if (configuration.TargetBuildOptions.ScriptingAPI.Defines.Count != 0)
{
if (defines.Length != 0)
defines += ";";
defines += string.Join(";", configuration.TargetBuildOptions.ScriptingAPI.Defines);
}
var outputPath = Utilities.MakePathRelativeTo(project.CSharp.OutputPath ?? configuration.TargetBuildOptions.OutputFolder, projectDirectory);
var intermediateOutputPath = Utilities.MakePathRelativeTo(project.CSharp.IntermediateOutputPath ?? Path.Combine(configuration.TargetBuildOptions.IntermediateFolder, "CSharp"), projectDirectory);
csProjectFileContent.AppendLine(string.Format(" <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == '{0}|{1}' \">", defaultConfiguration, defaultArchitecture));
csProjectFileContent.AppendLine(" <DebugSymbols>true</DebugSymbols>");
csProjectFileContent.AppendLine(" <DebugType>portable</DebugType>");
csProjectFileContent.AppendLine(string.Format(" <Optimize>{0}</Optimize>", defaultConfiguration == TargetConfiguration.Debug ? "false" : "true"));
csProjectFileContent.AppendLine(string.Format(" <OutputPath>{0}\\</OutputPath>", outputPath));
csProjectFileContent.AppendLine(string.Format(" <BaseIntermediateOutputPath>{0}\\</BaseIntermediateOutputPath>", intermediateOutputPath));
csProjectFileContent.AppendLine(string.Format(" <IntermediateOutputPath>{0}\\</IntermediateOutputPath>", intermediateOutputPath));
csProjectFileContent.AppendLine(string.Format(" <DefineConstants>{0}</DefineConstants>", defines));
csProjectFileContent.AppendLine(" <ErrorReport>prompt</ErrorReport>");
csProjectFileContent.AppendLine(" <WarningLevel>4</WarningLevel>");
csProjectFileContent.AppendLine(" <AllowUnsafeBlocks>true</AllowUnsafeBlocks>");
if (configuration.TargetBuildOptions.ScriptingAPI.IgnoreMissingDocumentationWarnings)
csProjectFileContent.AppendLine(" <NoWarn>1591</NoWarn>");
csProjectFileContent.AppendLine(string.Format(" <DocumentationFile>{0}\\{1}.CSharp.xml</DocumentationFile>", outputPath, project.Name));
csProjectFileContent.AppendLine(" <UseVSHostingProcess>true</UseVSHostingProcess>");
csProjectFileContent.AppendLine(" </PropertyGroup>");
}
// Configurations // Configurations
foreach (var configuration in project.Configurations) foreach (var configuration in project.Configurations)
{ {