1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

tools: build examples/viewer as a project folder

This commit is contained in:
Delyan Angelov 2021-12-11 23:20:08 +02:00
parent d3b769d1bc
commit 23be53e2de
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 21 additions and 7 deletions

View File

@ -417,10 +417,6 @@ pub fn vlib_should_be_present(parent_dir string) {
}
}
pub fn v_build_failing(zargs string, folder string) bool {
return v_build_failing_skipped(zargs, folder, [])
}
pub fn prepare_test_session(zargs string, folder string, oskipped []string, main_label string) TestSession {
vexe := pref.vexe_path()
parent_dir := os.dir(vexe)
@ -470,10 +466,13 @@ pub fn prepare_test_session(zargs string, folder string, oskipped []string, main
return session
}
pub fn v_build_failing_skipped(zargs string, folder string, oskipped []string) bool {
pub type FnTestSetupCb = fn (mut session TestSession)
pub fn v_build_failing_skipped(zargs string, folder string, oskipped []string, cb FnTestSetupCb) bool {
main_label := 'Building $folder ...'
finish_label := 'building $folder'
mut session := prepare_test_session(zargs, folder, oskipped, main_label)
cb(mut session)
session.test()
eprintln(session.benchmark.total_message(finish_label))
return session.failed

View File

@ -3,13 +3,28 @@ module main
import os
import testing
const vroot = @VMODROOT
const efolders = [
'examples/viewer',
]
fn main() {
args_string := os.args[1..].join(' ')
params := args_string.all_before('build-examples')
if testing.v_build_failing(params, 'examples') {
skip_prefixes := efolders.map(os.join_path(vroot, it))
res := testing.v_build_failing_skipped(params, 'examples', skip_prefixes, fn (mut session testing.TestSession) {
for x in efolders {
pathsegments := x.split_any('/')
session.add(os.join_path(vroot, ...pathsegments))
}
})
if res {
exit(1)
}
if testing.v_build_failing(params + '-live', os.join_path('examples', 'hot_reload')) {
if testing.v_build_failing_skipped(params + '-live', os.join_path('examples', 'hot_reload'),
skip_prefixes, fn (mut session testing.TestSession) {})
{
exit(1)
}
}