Simplified FlaxNativeTests.
This commit is contained in:
@@ -10,45 +10,6 @@ using Flax.Build.NativeCpp;
|
||||
/// </summary>
|
||||
public class TestsMain : EngineModule
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void Setup(BuildOptions options)
|
||||
{
|
||||
base.Setup(options);
|
||||
|
||||
// Use source folder per platform group
|
||||
switch (options.Platform.Target)
|
||||
{
|
||||
case TargetPlatform.Windows:
|
||||
options.SourcePaths.Add(Path.Combine(FolderPath, "Windows"));
|
||||
|
||||
// Visual Leak Detector (https://kinddragon.github.io/vld/)
|
||||
/*{
|
||||
var vldPath = @"C:\Program Files (x86)\Visual Leak Detector";
|
||||
var vldBinaries = options.Toolchain.Architecture == TargetArchitecture.x64 ? "Win64" : "Win32";
|
||||
var vldBinariesPostfix = options.Toolchain.Architecture == TargetArchitecture.x64 ? "x64" : "x86";
|
||||
options.PrivateDefinitions.Add("USE_VLD_MEM_LEAKS_CHECK");
|
||||
options.PrivateDefinitions.Add("VLD_FORCE_ENABLE");
|
||||
options.PrivateIncludePaths.Add(Path.Combine(vldPath, "include"));
|
||||
options.OutputFiles.Add(Path.Combine(vldPath, "lib", vldBinaries, "vld.lib"));
|
||||
options.DependencyFiles.Add(Path.Combine(vldPath, "bin", vldBinaries, "vld_" + vldBinariesPostfix + ".dll"));
|
||||
options.DependencyFiles.Add(Path.Combine(vldPath, "bin", vldBinaries, "vld_" + vldBinariesPostfix + ".pdb"));
|
||||
options.DependencyFiles.Add(Path.Combine(vldPath, "bin", vldBinaries, "dbghelp.dll"));
|
||||
options.DependencyFiles.Add(Path.Combine(vldPath, "bin", vldBinaries, "Microsoft.DTfW.DHL.manifest"));
|
||||
}*/
|
||||
|
||||
// Visual Studio memory leaks detection
|
||||
/*{
|
||||
options.PrivateDefinitions.Add("USE_VS_MEM_LEAKS_CHECK");
|
||||
}*/
|
||||
|
||||
break;
|
||||
case TargetPlatform.Linux:
|
||||
options.SourcePaths.Add(Path.Combine(FolderPath, "Linux"));
|
||||
break;
|
||||
default: throw new InvalidPlatformException(options.Platform.Target);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void GetFilesToDeploy(List<string> files)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
|
||||
|
||||
#if PLATFORM_LINUX
|
||||
#if PLATFORM_WINDOWS || PLATFORM_LINUX
|
||||
|
||||
#define CATCH_CONFIG_RUNNER
|
||||
#include <ThirdParty/catch2/catch.hpp>
|
||||
@@ -1,37 +0,0 @@
|
||||
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
|
||||
|
||||
#if PLATFORM_WINDOWS
|
||||
|
||||
#ifdef USE_VLD_MEM_LEAKS_CHECK
|
||||
#include <vld.h>
|
||||
#endif
|
||||
#ifdef USE_VS_MEM_LEAKS_CHECK
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include <stdlib.h>
|
||||
#include <crtdbg.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#define CATCH_CONFIG_RUNNER
|
||||
#include <ThirdParty/catch2/catch.hpp>
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#ifdef USE_VS_MEM_LEAKS_CHECK
|
||||
// Memory leaks detect inside VS
|
||||
int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
|
||||
flag |= _CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF;
|
||||
_CrtSetDbgFlag(flag);
|
||||
#endif
|
||||
|
||||
#ifdef USE_VLD_MEM_LEAKS_CHECK
|
||||
VLDGlobalEnable();
|
||||
#endif
|
||||
|
||||
int result = Catch::Session().run(argc, argv);
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -19,6 +19,8 @@ public class FlaxNativeTestsTarget : EngineTarget
|
||||
// Initialize
|
||||
OutputName = "FlaxNativeTests";
|
||||
ConfigurationName = "Tests";
|
||||
|
||||
// TODO: All platforms would benefit from the tests.
|
||||
Platforms = new[]
|
||||
{
|
||||
TargetPlatform.Windows,
|
||||
@@ -51,10 +53,11 @@ public class FlaxNativeTestsTarget : EngineTarget
|
||||
/// <inheritdoc />
|
||||
public override Target SelectReferencedTarget(ProjectInfo project, Target[] projectTargets)
|
||||
{
|
||||
var testTargetName = "FlaxNativeTests";
|
||||
var testTargetName = "FlaxNativeTests"; // Should this be added to .flaxproj, similarly as "GameTarget" and "EditorTarget"?
|
||||
var result = projectTargets.FirstOrDefault(x => x.Name == testTargetName);
|
||||
if (result == null)
|
||||
throw new Exception("Invalid or missing test target {testTargetName} specified in project {project.Name} (referenced by project {Project.Name}).");
|
||||
// Apparently .NET compiler that is used for building .Build.cs files is different that one used for building Flax.Build itself. String interpolation ($) does't work here.
|
||||
throw new Exception(string.Format("Invalid or missing test target {0} specified in project {1} (referenced by project {2}).", testTargetName, project.Name, Project.Name));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user