You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
- Each module can now have a Tests folder at its root containing low level tests written with Catch2 - Used like this: UnrealBuildTool.exe -Mode=Test TargetName Platform Configuration - It creates a test executable that's associated with the specified build Target and it includes all the tests for the Target AND all its dependencies as well - When building without -Mode=Test it will omit the Tests folder contents from compilation: in theory we never allowed folders named Tests at the root of modules, but there might be isolated exceptions where we didn't validate folder names - in this case we will need to move that Tests folder one level up for example - Code paths for test and non-test builds are entirely separated #jira UE-135280 #rb Jerome.Delattre #preflight 61e839d5276892ce10759205 [CL 18663474 by chris constantinescu in ue5-main branch]
66 lines
2.5 KiB
C#
66 lines
2.5 KiB
C#
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
using System.Collections.Generic;
|
|
using EpicGames.Core;
|
|
using UnrealBuildBase;
|
|
|
|
namespace UnrealBuildTool
|
|
{
|
|
/// <summary>
|
|
/// Builds low level tests on one or more targets.
|
|
/// </summary>
|
|
[ToolMode("Test", ToolModeOptions.XmlConfig | ToolModeOptions.BuildPlatforms | ToolModeOptions.SingleInstance | ToolModeOptions.ShowExecutionTime)]
|
|
class TestMode : ToolMode
|
|
{
|
|
/// <summary>
|
|
/// Main entry point
|
|
/// </summary>
|
|
/// <param name="Arguments">Command-line arguments</param>
|
|
public override int Execute(CommandLineArguments Arguments)
|
|
{
|
|
Arguments.ApplyTo(this);
|
|
|
|
// Create the build configuration object, and read the settings
|
|
BuildConfiguration BuildConfiguration = new BuildConfiguration();
|
|
Arguments.ApplyTo(BuildConfiguration);
|
|
XmlConfig.ApplyTo(BuildConfiguration);
|
|
|
|
// Parse all the targets being built
|
|
List<TargetDescriptor> TargetDescriptors = TargetDescriptor.ParseCommandLine(Arguments, false, false, false);
|
|
|
|
BuildTests(TargetDescriptors, BuildConfiguration);
|
|
|
|
return 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Build tests for a list of targets.
|
|
/// It generates artificial test target descriptors to build a target AND its dependencies's tests in one monolithic executable.
|
|
/// Each module containing a "Tests" folder is included.
|
|
/// The target that we generate the tests executable for must include a main.cpp file and Setup and Teardown methods.
|
|
/// The generated executable is the target name + "Tests", e.g. UnrealEditorTests.exe
|
|
/// Passing UnrealEditor here would build all the tests in all the modules.
|
|
/// </summary>
|
|
/// <param name="TargetDescriptors">Target descriptors</param>
|
|
/// <param name="BuildConfiguration">Current build configuration</param>
|
|
public static void BuildTests(List<TargetDescriptor> TargetDescriptors, BuildConfiguration BuildConfiguration)
|
|
{
|
|
List<TargetDescriptor> TestTargetDescriptors = new List<TargetDescriptor>();
|
|
|
|
for (int Idx = 0; Idx < TargetDescriptors.Count; ++Idx)
|
|
{
|
|
TargetDescriptor TestsTargetDescriptor = TargetDescriptors[Idx].Copy();
|
|
TestsTargetDescriptor.Name = TargetDescriptors[Idx].Name + "Tests";
|
|
TestsTargetDescriptor.IsTestsTarget = true;
|
|
TestTargetDescriptors.Add(TestsTargetDescriptor);
|
|
}
|
|
|
|
using (ISourceFileWorkingSet WorkingSet = SourceFileWorkingSet.Create(Unreal.RootDirectory, new HashSet<DirectoryReference>()))
|
|
{
|
|
BuildMode.Build(TestTargetDescriptors, BuildConfiguration, WorkingSet, BuildOptions.None, null);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|