-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.c
More file actions
executable file
·160 lines (135 loc) · 4.05 KB
/
Copy pathmain.c
File metadata and controls
executable file
·160 lines (135 loc) · 4.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#include <external.h>
#include <caneka.h>
#include <test_module.h>
#ifdef MEMTEST
#define MEM_MAX_TESTS
#endif
i32 main(int argc, char **argv){
status r = READY;
MemBook *cp = MemBook_Make(NULL);
void *args[5];
if(cp == NULL){
Fatal(NULL, FUNCNAME, FILENAME, LINENUMBER, "MemBook created successfully", NULL);
}
MemCh *m = MemCh_Make();
if(m == NULL){
Fatal(NULL, FUNCNAME, FILENAME, LINENUMBER, "MemCh created successfully", NULL);
}
#ifdef CNKOPT_EXT
Caneka_Init(m);
#else
Caneka_InitBase(m);
#endif
Core_Direct(m, 1, 2);
#ifdef CNKOPT_INTER
Inter_Init(m);
#endif
CliArgs *cli = CliArgs_Make(argc, argv);
Debug_Push(m, cli);
Str *help = K(m, "help");
Str *noColor = K(m, "no-color");
Str *dist = K(m, "dist");
Args_Add(cli, help, NULL, ARG_OPTIONAL,
Sv(m, "Show this help message."));
Args_Add(cli, noColor, NULL, ARG_OPTIONAL,
Sv(m, "Skip ansi color sequences in output."));
Args_Add(cli, dist, NULL, ARG_OPTIONAL,
Sv(m, "Out to the dist directory instead of displaying results on the console."));
Args_Add(cli, Str_FromCstr(m, "licence", STRING_COPY), NULL, ARG_OPTIONAL,
Sv(m, "Show software licences."));
Args_Add(cli, Str_FromCstr(m, "version", STRING_COPY), NULL, ARG_OPTIONAL,
Sv(m, "Show the licences used in this application."));
StrVec *name = StrVec_From(m, Str_FromCstr(m, argv[0], STRING_COPY));
IoUtil_Annotate(m, name);
Str *fname = IoUtil_FnameStr(m, name);
CliArgs_Parse(cli);
if(CliArgs_Get(cli, noColor)){
Ansi_SetColor(OutStream, FALSE);
}
Buff *bf = Buff_Make(m, ZERO);
Str *path = Str_Make(m, STR_DEFAULT);
if(CliArgs_Get(cli, dist) != NULL){
Ansi_SetColor(OutStream, FALSE);
Str *dir = IoUtil_GetAbsPath(m, S(m, "dist/output"));
Dir_CheckCreate(m, dir);
args[0] = dir;
args[1] = S(m, "/test-output.fmt");
args[2] = NULL;
Str_AddChain(m, path, args);
args[0] = path;
args[1] = NULL;
Out("^p.Outputting test results to @^0\n",args);
bf->type.state |= BUFF_CLOBBER;
File_Open(bf, path, O_WRONLY|O_CREAT|O_TRUNC);
i32 outFd = 1;
if(bf->pfd->fd > 0){
outFd = bf->pfd->fd;
}
Core_Direct(m, outFd, 2);
}
i32 pass = 0;
i32 fail = 0;
i32 skip = 0;
TestSuite *suite = NULL;
#ifdef CNKOPT_BASE
suite = TestSuite_Make(m, S(m, "Caneka base"), BaseTests);
r |= Test_Runner(m, suite);
pass += suite->pass;
fail += suite->fail;
skip += suite->skip;
#endif
#ifdef CNKOPT_EXT
if((r & ERROR) == 0){
suite = TestSuite_Make(m, S(m, "Caneka ext"), ExtTests);
r |= Test_Runner(m, suite);
pass += suite->pass;
fail += suite->fail;
skip += suite->skip;
}
#endif
#ifdef CNKOPT_CRYPTO
if((r & ERROR) == 0){
suite = TestSuite_Make(m, S(m, "Caneka crypto"), CryptoTests);
r |= Test_Runner(m, suite);
pass += suite->pass;
fail += suite->fail;
skip += suite->skip;
}
#endif
#ifdef CNKOPT_INTER
if((r & ERROR) == 0){
suite = TestSuite_Make(m, S(m, "Caneka inter"), InterTests);
r |= Test_Runner(m, suite);
pass += suite->pass;
fail += suite->fail;
skip += suite->skip;
}
#endif
#ifdef CNKOPT_ALGO
if((r & ERROR) == 0){
suite = TestSuite_Make(m, S(m, "Caneka algo"), AlgoTests);
r |= Test_Runner(m, suite);
pass += suite->pass;
fail += suite->fail;
skip += suite->skip;
}
#endif
args[0] = I32_Wrapped(m, pass),
args[1] = I32_Wrapped(m, fail),
args[2] = I32_Wrapped(m, skip),
args[3] = NULL;
if(!fail){
Out("^g", NULL);
}else{
Out("^r", NULL);
}
Out("\nAll Suites - pass($) fail($) skip($)^0\n", args);
if(CliArgs_Get(cli, dist) != NULL){
File_Close(bf);
Core_Direct(m, 1, 2);
args[0] = path;
args[1] = NULL;
Out("Tests run and output to $\n", args);
}
Return(m, 0);
}