This repository has been archived by the owner on Jul 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathperform_tests.et
executable file
·89 lines (75 loc) · 2.32 KB
/
perform_tests.et
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
#!/usr/bin/env et
import std.( fs, os, str, vec, term, time, threads );
fn wait_procs( tpool, max_procs, with_valgrind, p, f ) {
for ; tpool.len() >= max_procs; {
for i = 0; i < tpool.len(); i += 1 {
if tpool[ i ].done() {
t = tpool[ i ];
if t.res() != 0 {
f += 1;
cprintln( '{r}failed {y}', files[ t.id() ], with_valgrind ? '{c} with valgrind' : '',
'{0}, {y}error code{0}: {r}', t.res(),'{0}' );
flush_out();
} else {
p += 1;
}
tpool.erase( i );
i -= 1;
}
}
}
}
files = fs.dir_entries( 'tests', fs.ent.RECURSE, '(.*)\\.et' );
tpool = [];
max_procs = threads.nproc;
threadid = 0;
p = 0;
f = 0;
start = time.now();
for file in files.iter() {
wait_procs( tpool, max_procs, false, p, f );
cprintln( '{c}test{0}: {y}', file, '{0} ...' );
flush_out();
tpool.push( threads.new_exec( __PROG__ + ' ' + file + ' test 1>/dev/null 2>&1', threadid ) );
threadid += 1;
}
wait_procs( tpool, 1, false, p, f );
diff = time.now() - start;
if f > 0 || args.find( '--with-valgrind' ) == -1 {
cprintln( '=> {y}Passed{0}: {g}', p,
'\n{0}=> {y}Failed{0}: {r}', f,
'\n{0}=> {y}Total Time{0}: {b}', diff.msecs(), ' ms{0}' );
exit( f );
}
############################################## Test with Valgrind ###############################################
valgrind = os.find_exec( 'valgrind' );
if valgrind.empty() {
cprintln( '=> {y}Passed{0}: {g}', p,
'\n{0}=> {y}Failed{0}: {r}', f,
'\n{0}=> {y}Total Time{0}: {b}', diff.msecs(), ' ms{0}' );
cprintln( '{y}valgrind binary is {r}not {y}available in the {m}PATH {y}variable{0}' );
exit( f );
}
threadid = 0;
vp = 0;
vf = 0;
start = time.now();
for file in files.iter() {
wait_procs( tpool, max_procs, true, vp, vf );
cprintln( '{c}test {0}({c}valgrind{0}): {y}', file, '{0} ...' );
flush_out();
tpool.push( threads.new_exec( valgrind + ' ' + __PROG__ + ' ' + file + ' test 1>/dev/null 2>&1', threadid ) );
threadid += 1;
}
wait_procs( tpool, 1, true, vp, vf );
vdiff = time.now() - start;
cprintln( '{y}OS{0}: {m}', os.name,
'\n{w}Basic{0}:',
'\n{0}=> {y}Passed{0}: {g}', p,
'\n{0}=> {y}Failed{0}: {r}', f,
'\n{0}=> {y}Total Time{0}: {b}', diff.msecs(), ' ms{0}',
'\n{w}Valgrind{0}:',
'\n{0}=> {y}Passed{0}: {g}', vp,
'\n{0}=> {y}Failed{0}: {r}', vf,
'\n{0}=> {y}Total Time{0}: {b}', vdiff.msecs(), ' ms{0}' );
exit( f );