Skip to content

Commit 8958217

Browse files
committed
Sped the test run up by moving the test for ignored system types.
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent b5c17d9 commit 8958217

File tree

5 files changed

+32
-32
lines changed

5 files changed

+32
-32
lines changed

src/Generator.Tests/AST/TestAST.cs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,13 @@ public void TestFindClassInNamespace()
303303
[Test]
304304
public void TestLineNumber()
305305
{
306-
Assert.AreEqual(70, AstContext.FindClass("HiddenInNamespace").First().LineNumberStart);
306+
Assert.AreEqual(72, AstContext.FindClass("HiddenInNamespace").First().LineNumberStart);
307307
}
308308

309309
[Test]
310310
public void TestLineNumberOfFriend()
311311
{
312-
Assert.AreEqual(93, AstContext.FindFunction("operator+").First().LineNumberStart);
312+
Assert.AreEqual(95, AstContext.FindFunction("operator+").First().LineNumberStart);
313313
}
314314

315315
static string StripWindowsNewLines(string text)
@@ -350,7 +350,7 @@ public void TestAtomics()
350350
[Test]
351351
public void TestMacroLineNumber()
352352
{
353-
Assert.AreEqual(103, AstContext.FindClass("HasAmbiguousFunctions").First().Specifiers.Last().LineNumberStart);
353+
Assert.AreEqual(105, AstContext.FindClass("HasAmbiguousFunctions").First().Specifiers.Last().LineNumberStart);
354354
}
355355

356356
[Test]
@@ -576,5 +576,30 @@ public void TestClassContext()
576576
var @classC = AstContext.FindClass("ClassC").First();
577577
Assert.That(@classC.Redeclarations.Count, Is.EqualTo(2));
578578
}
579+
580+
[Test]
581+
public void TestRemovalOfUnusedStdTypes()
582+
{
583+
new IgnoreSystemDeclarationsPass { Context = Driver.Context }.VisitASTContext(AstContext);
584+
if (Platform.IsWindows)
585+
{
586+
Assert.That(AstContext.GetEnumWithMatchingItem("_ALLOC_MASK").Ignore, Is.True);
587+
Assert.That(AstContext.FindClass("_Ctypevec").First().Ignore, Is.True);
588+
return;
589+
}
590+
if (Platform.IsLinux)
591+
{
592+
Assert.That(AstContext.GetEnumWithMatchingItem("PTHREAD_RWLOCK_PREFER_READER_NP").Ignore, Is.True);
593+
Assert.That(AstContext.FindClass("pthread_mutex_t").First().Ignore, Is.True);
594+
return;
595+
596+
}
597+
if (Platform.IsMacOS)
598+
{
599+
Assert.That(AstContext.GetEnumWithMatchingItem("__n_words").Ignore, Is.True);
600+
Assert.That(AstContext.FindClass("__darwin_fp_control").First().Ignore, Is.True);
601+
return;
602+
}
603+
}
579604
}
580605
}

src/Generator.Tests/ASTTestFixture.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using CppSharp.Utils;
44
using CppSharp.Parser;
55
using CppSharp.Passes;
6+
using CppSharp.Generators;
67

78
namespace CppSharp.Generator.Tests
89
{
@@ -15,7 +16,7 @@ public class ASTTestFixture
1516

1617
protected void ParseLibrary(params string[] files)
1718
{
18-
Options = new DriverOptions();
19+
Options = new DriverOptions { GeneratorKind = GeneratorKind.CSharp };
1920
ParserOptions = new ParserOptions();
2021

2122
var testsPath = GeneratorTest.GetTestsDirectory("Native");

src/Generator.Tests/Passes/TestPasses.cs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -231,31 +231,5 @@ public void TestAbstractOperator()
231231
var @class = AstContext.FindDecl<Class>("ClassWithAbstractOperator").First();
232232
Assert.AreEqual(@class.Operators.First().GenerationKind, GenerationKind.None);
233233
}
234-
235-
[Test]
236-
public void TestRemovalOfUnusedStdTypes()
237-
{
238-
passBuilder.AddPass(new IgnoreSystemDeclarationsPass());
239-
passBuilder.RunPasses(pass => pass.VisitASTContext(AstContext));
240-
if (Platform.IsWindows)
241-
{
242-
Assert.That(AstContext.GetEnumWithMatchingItem("_ALLOC_MASK").Ignore, Is.True);
243-
Assert.That(AstContext.FindClass("_Ctypevec").First().Ignore, Is.True);
244-
return;
245-
}
246-
if (Platform.IsLinux)
247-
{
248-
Assert.That(AstContext.GetEnumWithMatchingItem("PTHREAD_RWLOCK_PREFER_READER_NP").Ignore, Is.True);
249-
Assert.That(AstContext.FindClass("pthread_mutex_t").First().Ignore, Is.True);
250-
return;
251-
252-
}
253-
if (Platform.IsMacOS)
254-
{
255-
Assert.That(AstContext.GetEnumWithMatchingItem("__n_words").Ignore, Is.True);
256-
Assert.That(AstContext.FindClass("__darwin_fp_control").First().Ignore, Is.True);
257-
return;
258-
}
259-
}
260234
}
261235
}

tests/Native/AST.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include <string>
2+
13
#define Q_SIGNALS protected
24

35
// Tests assignment of AST.Parameter properties

tests/Native/Passes.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#include <string>
2-
31
enum FlagEnum
42
{
53
A = 1 << 0,

0 commit comments

Comments
 (0)