v / ci / macos_ci.vsh
163 lines · 139 sloc · 5.33 KB · 6fef27f37132d22f27f45962e61479d8195e7f13
Raw
1import common { Task, exec }
2import os
3
4fn test_symlink() {
5 exec('v symlink')
6}
7
8fn test_cross_compilation() {
9 exec('v -o hw -os linux examples/hello_world.v && ls -la hw && file hw')
10 exec('v -d use_openssl -o ve -os linux examples/veb/veb_example.v && ls -la ve && file ve')
11}
12
13fn build_with_cstrict() {
14 exec('v -cg -cstrict -o vstrict1 cmd/v')
15}
16
17fn all_code_is_formatted() {
18 if common.is_github_job {
19 exec('VJOBS=1 v -silent test-cleancode')
20 } else {
21 vjobs := os.getenv_opt('VJOBS') or { '1' }
22 exec('VJOBS=${vjobs} v -progress test-cleancode')
23 }
24}
25
26fn run_sanitizers() {
27 exec('v -o v2 cmd/v -cflags -fsanitize=undefined')
28 exec('UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./v2 -o v.c cmd/v')
29}
30
31fn build_using_v() {
32 exec('v -o v2 cmd/v')
33 exec('./v2 -o v3 cmd/v')
34}
35
36fn verify_v_test_works() {
37 exec('echo \$VFLAGS')
38 exec('v cmd/tools/test_if_v_test_system_works.v')
39 exec('./cmd/tools/test_if_v_test_system_works')
40}
41
42fn install_iconv() {
43 // Skip Homebrew when iconv is already linkable for V on this machine.
44 if os.system('v -silent test vlib/encoding/iconv/') == 0 {
45 return
46 }
47 exec('brew list --versions libiconv >/dev/null 2>&1 || brew install libiconv')
48}
49
50fn test_pure_v_math_module() {
51 exec('v -silent -exclude @vlib/math/*.c.v test vlib/math/')
52}
53
54fn self_tests() {
55 if common.is_github_job {
56 exec('VJOBS=1 v -silent test-self vlib')
57 } else {
58 vjobs := os.getenv_opt('VJOBS') or { '1' }
59 exec('VJOBS=${vjobs} v -progress test-self vlib')
60 }
61}
62
63fn build_examples() {
64 if common.is_github_job {
65 exec('v build-examples')
66 } else {
67 exec('v -progress build-examples')
68 }
69}
70
71fn build_examples_v_compiled_with_tcc() {
72 exec('v -o vtcc -cc tcc cmd/v')
73 if common.is_github_job {
74 exec('./vtcc build-examples')
75 } else {
76 exec('./vtcc -progress build-examples')
77 }
78}
79
80fn build_tetris_autofree() {
81 exec('v -autofree -o tetris examples/tetris/tetris.v')
82}
83
84fn build_blog_autofree() {
85 exec('v -autofree -o blog tutorials/building_a_simple_web_blog_with_veb/code/blog')
86}
87
88fn build_examples_prod() {
89 exec('v -prod examples/news_fetcher.v')
90}
91
92fn v_doctor() {
93 exec('v doctor')
94}
95
96fn build_v_with_prealloc() {
97 exec('v -cg -cstrict -o vstrict1 cmd/v')
98 exec('./vstrict1 -d debug_malloc -d debug_realloc -o vdebug1 cmd/v')
99 exec('./vstrict1 -o vprealloc -prealloc cmd/v')
100 // TODO: fix prealloc on macos (the rwmutex implementation for shared maps there seems to require that mutexes are allocated by C.malloc directly, and segfaults for arbitrary memory addresses)
101 // exec('./vprealloc run examples/hello_world.v')
102 // exec('./vprealloc -o v3 cmd/v')
103 // exec('./v3 -o v4 cmd/v')
104}
105
106fn v_self_compilation_usecache() {
107 $if !enable_usecache_test ? {
108 eprintln('> ${@LOCATION} use `-d enable_usecache_test` in VFLAGS to enable this task')
109 return
110 }
111 exec('v -usecache examples/hello_world.v')
112 exec('./examples/hello_world')
113 exec('v -o v2 -usecache cmd/v')
114 exec('./v2 -o v3 -usecache cmd/v')
115 exec('./v3 version')
116 exec('./v3 -o tetris -usecache examples/tetris/tetris.v')
117}
118
119fn v_self_compilation_parallel_cc() {
120 exec('v -o vp -parallel-cc cmd/v')
121 // exec('./v2 -o v3 -usecache cmd/v')
122 exec('./vp version')
123 exec('./vp -o tetris examples/tetris/tetris.v')
124}
125
126fn test_password_input() {
127 exec('v -silent test examples/password/')
128}
129
130fn test_readline() {
131 exec('v -silent test examples/readline/')
132}
133
134fn test_inline_assembly() {
135 exec('v test vlib/v/slow_tests/assembly')
136}
137
138const all_tasks = {
139 'test_symlink': Task{test_symlink, 'Test symlink'}
140 'test_cross_compilation': Task{test_cross_compilation, 'Test cross compilation to Linux'}
141 'build_with_cstrict': Task{build_with_cstrict, 'Build V with -cstrict'}
142 'all_code_is_formatted': Task{all_code_is_formatted, 'All code is formatted'}
143 'run_sanitizers': Task{run_sanitizers, 'Run sanitizers'}
144 'build_using_v': Task{build_using_v, 'Build V using V'}
145 'verify_v_test_works': Task{verify_v_test_works, 'Verify `v test` works'}
146 'install_iconv': Task{install_iconv, 'Install iconv for encoding.iconv'}
147 'test_pure_v_math_module': Task{test_pure_v_math_module, 'Test pure V math module'}
148 'self_tests': Task{self_tests, 'Self tests'}
149 'build_examples': Task{build_examples, 'Build examples'}
150 'build_tetris_autofree': Task{build_tetris_autofree, 'Build tetris with -autofree'}
151 'build_blog_autofree': Task{build_blog_autofree, 'Build blog tutorial with -autofree'}
152 'build_examples_prod': Task{build_examples_prod, 'Build examples with -prod'}
153 'build_examples_v_compiled_with_tcc': Task{build_examples_v_compiled_with_tcc, 'Build examples with V build with tcc'}
154 'v_doctor': Task{v_doctor, 'v doctor'}
155 'build_v_with_prealloc': Task{build_v_with_prealloc, 'Build V with prealloc'}
156 'v_self_compilation_usecache': Task{v_self_compilation_usecache, 'V self compilation with -usecache'}
157 'v_self_compilation_parallel_cc': Task{v_self_compilation_parallel_cc, 'V self compilation with -parallel-cc'}
158 'test_password_input': Task{test_password_input, 'Test password input'}
159 'test_readline': Task{test_readline, 'Test readline'}
160 'test_inline_assembly': Task{test_inline_assembly, 'Test inline assembly'}
161}
162
163common.run(all_tasks)
164