v / cmd / tools / vbuild-examples.v
40 lines · 35 sloc · 1.05 KB · 5d91447d09493d073ae7b8cb1c45a4a00de9222d
Raw
1module main
2
3import os
4import testing
5
6const vroot = os.dir(os.real_path(os.getenv_opt('VEXE') or { @VEXE }))
7
8// build as a project folder
9const efolders = [
10 'examples/viewer',
11 'examples/fasthttp',
12 'examples/veb_orm_jwt',
13 'examples/veb_fullstack',
14]
15
16pub fn normalised_vroot_path(path string) string {
17 return os.real_path(os.join_path_single(vroot, path)).replace('\\', '/')
18}
19
20fn main() {
21 args_string := os.args[1..].join(' ')
22 params := args_string.all_before('build-examples')
23 mut skip_prefixes := efolders.map(normalised_vroot_path(it))
24 res := testing.v_build_failing_skipped(params, 'examples', skip_prefixes, fn (mut session testing.TestSession) {
25 for x in efolders {
26 pathsegments := x.split_any('/')
27 fpath := os.real_path(os.join_path(vroot, ...pathsegments))
28 session.skip_files = session.skip_files.filter(it != fpath)
29 session.add(fpath)
30 }
31 })
32 if res {
33 exit(1)
34 }
35 if testing.v_build_failing_skipped(params + '-live', os.join_path_single('examples',
36 'hot_reload'), skip_prefixes, fn (mut session testing.TestSession) {})
37 {
38 exit(1)
39 }
40}
41