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
const CC = 'clang'
const CFLAGS = ['-Wall', '-Wextra', '-Werror', '-DNREADLINE']
const SUBPYTHON = 'subpython'
const OBJS = [
'arena.o', 'ast.o', 'eval.o', 'eval_dict.o', 'eval_list.o',
'eval_refs.o', 'eval_types.o', 'exception.o', 'grammar.l.o',
'grammar.y.o', 'mm.o', 'parser.o', 'refs.o', 'repl.o'
]
const TESTS1 = [
'simple_math', 'simple_print', 'algo_fizzbuzz', 'algo_csum',
'algo_join', 'algo_bubble', 'algo_bubble_str', 'stress_int',
'stress_str', 'multiple_refs', 'long_chain', 'transpose', 'ordered_fractions'
]
const TESTS2 = TESTS1.concat([
'dict_ops', 'long_chain_dict', 'tree', 'dict_resize', 'stress_struct'
])
const TESTS3 = TESTS2.concat([
'self_cycle', 'simple_recursive', 'simple_rep', 'long_loops',
'linked_list', 'gc_ref_counts', 'dense_graph', 'compacting', 'gc_tombstones'
])
const expectedName = test => `tests/${test}-expected.txt`
const actualName = test => `tests/${test}-actual.txt`
const resultName = test => `${test}-result`
const objectCommand = (target, dependencies) => ({
target,
dependencies,
command: [CC, '-c', ...CFLAGS, dependencies[0], '-o', target]
})
module.exports = [
objectCommand('arena.o', ['arena.c', 'arena.h']),
objectCommand('ast.o', ['ast.c', 'ast.h', 'arena.h', 'types.h']),
objectCommand('eval.o', [
'eval.c', 'eval.h', 'ast.h', 'arena.h', 'types.h', 'config.h',
'eval_refs.h', 'eval_types.h', 'exception.h', 'mm.h', 'refs.h'
]),
objectCommand('eval_dict.o', [
'eval_dict.c', 'eval_dict.h', 'types.h', 'eval_refs.h',
'eval_types.h', 'ast.h', 'arena.h', 'exception.h', 'refs.h'
]),
objectCommand('eval_list.o', [
'eval_list.c', 'eval_list.h', 'types.h', 'eval_types.h',
'ast.h', 'arena.h', 'exception.h', 'refs.h'
]),
objectCommand('eval_refs.o', [
'eval_refs.c', 'eval_refs.h', 'types.h', 'eval_types.h',
'ast.h', 'arena.h', 'exception.h', 'refs.h'
]),
objectCommand('eval_types.o', [
'eval_types.c', 'eval_types.h', 'ast.h', 'arena.h', 'types.h', 'config.h',
'eval_dict.h', 'eval_list.h', 'eval_refs.h', 'exception.h', 'refs.h'
]),
objectCommand('exception.o', ['exception.c', 'exception.h']),
objectCommand('grammar.l.o', [
'grammar.l.c', 'grammar.y.h', 'ast.h', 'arena.h', 'types.h', 'config.h', 'parser.h'
]),
objectCommand('grammar.y.o', [
'grammar.y.c', 'ast.h', 'arena.h', 'types.h', 'config.h', 'parser.h', 'grammar.l.h'
]),
objectCommand('mm.o', [
'mm.c', 'mm.h', 'types.h', 'refs.h', 'eval_types.h', 'ast.h', 'arena.h', 'exception.h'
]),
objectCommand('parser.o', [
'parser.c', 'parser.h', 'arena.h', 'ast.h', 'types.h',
'grammar.h', 'grammar.y.h', 'config.h', 'grammar.l.h'
]),
objectCommand('refs.o', [
'refs.c', 'refs.h', 'types.h', 'config.h', 'eval.h', 'ast.h', 'arena.h', 'mm.h'
]),
objectCommand('repl.o', [
'repl.c', 'config.h', 'eval.h', 'ast.h', 'arena.h', 'types.h',
'eval_types.h', 'exception.h', 'mm.h', 'parser.h', 'refs.h'
]),
{
target: SUBPYTHON,
dependencies: OBJS,
command: [CC, ...CFLAGS, ...OBJS, '-o', SUBPYTHON]
},
...TESTS3.map(test => {
const dependency = `tests/${test}.py`
const target = expectedName(test)
return {
target,
dependencies: [dependency],
command: ['sh', '-c', `grep '# output' ${dependency} | sed 's/# output //' > ${target}`]
}
}),
...TESTS3.map(test => {
const dependency = `tests/${test}.py`
const target = actualName(test)
return {
target,
dependencies: [SUBPYTHON, dependency],
command: ['sh', '-c', `./subpython \`grep '# -' ${dependency} | sed 's/#//'\` ${dependency} > ${target}`]
}
}),
...TESTS3.map(test => {
const dependencies = [expectedName(test), actualName(test)]
const target = resultName(test)
return {
target,
dependencies,
command: ['diff', '-u', ...dependencies]
}
}),
{
target: 'test1',
dependencies: TESTS1.map(resultName)
},
{
target: 'test2',
dependencies: TESTS2.map(resultName)
},
{
target: 'test3',
dependencies: TESTS3.map(resultName)
},
{
target: 'test',
dependencies: ['test3']
},
{
target: 'clean',
dependencies: [],
command: ['sh', '-c', 'rm -f *.d *.o subpython tests/*.txt']
}
]