Browse Source

Changed the tests for dependencies to use one combined AST.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/658/head
Dimitar Dobrev 9 years ago
parent
commit
22ba637aec
  1. 0
      tests/NamespacesBase/NamespacesBase.Tests.cs
  2. 41
      tests/NamespacesBase/NamespacesBase.cs
  3. 27
      tests/NamespacesBase/premake4.lua
  4. 23
      tests/NamespacesDerived/NamespacesDerived.cs
  5. 6
      tests/NamespacesDerived/premake4.lua

0
tests/NamespacesBase/NamespacesBase.Tests.cs

41
tests/NamespacesBase/NamespacesBase.cs

@ -1,41 +0,0 @@ @@ -1,41 +0,0 @@
using System;
using CppSharp.AST;
using CppSharp.Generators;
using CppSharp.Passes;
using CppSharp.Utils;
namespace CppSharp.Tests
{
public class NamespacesBaseTests : GeneratorTest
{
public NamespacesBaseTests(GeneratorKind kind)
: base("NamespacesBase", kind)
{
}
public override void SetupPasses(Driver driver)
{
driver.Options.GeneratePropertiesAdvanced = true;
}
public override void Preprocess(Driver driver, ASTContext ctx)
{
}
public override void Postprocess(Driver driver, ASTContext ctx)
{
new CaseRenamePass(
RenameTargets.Function | RenameTargets.Method | RenameTargets.Property | RenameTargets.Delegate | RenameTargets.Variable,
RenameCasePattern.UpperCamelCase).VisitLibrary(driver.ASTContext);
}
}
public class NamespacesBase {
public static void Main(string[] args)
{
ConsoleDriver.Run(new NamespacesBaseTests(GeneratorKind.CSharp));
}
}
}

27
tests/NamespacesBase/premake4.lua

@ -1,2 +1,27 @@ @@ -1,2 +1,27 @@
function SetupWrapper(name)
project(name .. ".CSharp")
SetupManagedTestProject()
dependson { name .. ".Native", "NamespacesDerived.Gen" }
local runtimeExe = os.is("windows") and "" or "mono --debug "
if string.starts(action, "vs") then
local exePath = SafePath("$(TargetDir)NamespacesDerived.Gen.exe")
prebuildcommands { runtimeExe .. exePath }
else
local exePath = SafePath("%{cfg.buildtarget.directory}/NamespacesDerived.Gen.exe")
prebuildcommands { runtimeExe .. exePath }
end
files
{
path.join(gendir, "NamespacesDerived", name .. ".cs"),
}
linktable = { "CppSharp.Runtime" }
links(linktable)
end
group "Tests/Namespaces"
SetupTestCSharp("NamespacesBase")
SetupTestNativeProject("NamespacesBase")
SetupWrapper("NamespacesBase")

23
tests/NamespacesDerived/NamespacesDerived.cs

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
using System.IO;
using CppSharp.AST;
using CppSharp.Generators;
using CppSharp.Passes;
@ -5,7 +6,6 @@ using CppSharp.Utils; @@ -5,7 +6,6 @@ using CppSharp.Utils;
namespace CppSharp.Tests
{
public class NamespacesDerivedTests : GeneratorTest
{
public NamespacesDerivedTests(GeneratorKind kind)
@ -13,10 +13,24 @@ namespace CppSharp.Tests @@ -13,10 +13,24 @@ namespace CppSharp.Tests
{
}
public override void SetupPasses(Driver driver)
public override void Setup(Driver driver)
{
base.Setup(driver);
driver.Options.GenerateDefaultValuesForArguments = true;
driver.Options.GeneratePropertiesAdvanced = true;
driver.Options.Modules[0].IncludeDirs.Add(GetTestsDirectory("NamespacesDerived"));
var @base = "NamespacesBase";
var module = new Module();
module.IncludeDirs.Add(Path.GetFullPath(GetTestsDirectory(@base)));
module.Headers.Add(string.Format("{0}.h", @base));
module.OutputNamespace = @base;
module.SharedLibraryName = string.Format("{0}.Native", @base);
// Workaround for CLR which does not check for .dll if the name already has a dot
if (System.Type.GetType("Mono.Runtime") == null)
module.SharedLibraryName += ".dll";
module.LibraryName = string.Format("{0}.CSharp", @base);
driver.Options.Modules.Insert(0, module);
}
public override void Postprocess(Driver driver, ASTContext ctx)
@ -27,14 +41,13 @@ namespace CppSharp.Tests @@ -27,14 +41,13 @@ namespace CppSharp.Tests
}
}
public class NamespacesDerived {
public class NamespacesDerived
{
public static void Main(string[] args)
{
ConsoleDriver.Run(new NamespacesBaseTests(GeneratorKind.CSharp));
ConsoleDriver.Run(new NamespacesDerivedTests(GeneratorKind.CSharp));
}
}
}

6
tests/NamespacesDerived/premake4.lua

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
group "Tests/Namespaces"
SetupTestGeneratorProject("NamespacesDerived", "NamespacesBase")
SetupTestNativeProject("NamespacesDerived", "NamespacesBase")
SetupTestProjectsCSharp("NamespacesDerived", "NamespacesBase")
SetupTestGeneratorProject("NamespacesDerived")
SetupTestNativeProject("NamespacesDerived", "NamespacesBase")
SetupTestProjectsCSharp("NamespacesDerived", "NamespacesBase")
project("NamespacesDerived.Tests.CSharp")
links { "NamespacesBase.CSharp" }
Loading…
Cancel
Save