1 module during.tests;
2 
3 version (D_BetterC)
4 {
5     import during.tests.base : errmsg;
6     import core.stdc.stdio;
7     extern(C) void main()
8     {
9         runTests!("API tests", during.tests.api);
10         runTests!("Thread tests", during.tests.thread);
11         runTests!("RW tests", during.tests.rw);
12         runTests!("Fsync tests", during.tests.fsync);
13         runTests!("Msg tests", during.tests.msg);
14         runTests!("Poll tests", during.tests.poll);
15         runTests!("Timeout tests", during.tests.timeout);
16         runTests!("Cancel tests", during.tests.cancel);
17         runTests!("Socket tests", during.tests.socket);
18         printf("All unit tests have been run successfully.\n");
19     }
20 
21     void runTests(string desc, alias symbol)()
22     {
23         printf(">> " ~ desc ~ ":\n");
24         static foreach(u; __traits(getUnitTests, symbol))
25         {
26             printf("testing '" ~ __traits(getAttributes, u)[0] ~ "'");
27             errmsg = null;
28             u();
29             if (errmsg is null) printf(": ok\n");
30             else printf(": %s\n", &errmsg[0]);
31         }
32         printf("\n");
33     }
34 }