Web assembly #6

Merged
Mergul merged 38 commits from WebAssembly into master 2020-04-14 17:44:27 +02:00
Showing only changes of commit 09633d1056 - Show all commits

View file

@ -8,16 +8,10 @@ import core.sys.posix.setjmp;
import ecs.vector;
import ecs.std;
unittest
{
assert(0, "AAAAAAAA");
}
enum int ASSERTED = 123;
enum string OUT_FILE = "test_report.xml";
static jmp_buf gEnvBuffer;
//__gshared TestSuite[4] gSuites;
static AssertInfo gAssertInfo;
struct AssertInfo
@ -147,54 +141,6 @@ string copyString(const char* str)
return cast(string) Mallocator.makeArray(arr);
}
void runTestSuite(alias testModule)(ref TestSuite suite)
{
suite.name = testModule.stringof;
foreach (index, testDelegate; __traits(getUnitTests, testModule))
{
suite.tests[index].executed = true;
writeTests(gSuites); // Save executed info
// Save calling environment for longjmp
int jmpRet = setjmp(gEnvBuffer);
if (jmpRet == ASSERTED)
{
suite.tests[index].passed = false;
suite.tests[index].file = copyString(gAssertInfo.file);
suite.tests[index].fileLine = gAssertInfo.line;
suite.tests[index].msg = copyString(gAssertInfo.msg);
}
else
{
testDelegate();
suite.tests[index].passed = true;
}
}
}
void addTestSuite(alias testModule)(ref TestSuite suite)
{
suite.name = testModule.stringof;
foreach (index, testDelegate; __traits(getUnitTests, testModule))
{
enum attributes = __traits(getAttributes, testDelegate);
static if (attributes.length == 0)
{
enum string testName = "No name";
}
else
{
enum string testName = attributes[0];
}
Test test;
test.name = testName;
suite.tests ~= test;
}
}
struct TestRunner(Args...)
{
TestSuite[Args.length] suites;