From 23be53e2de7d48023fa00100687e5cc18280cee8 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sat, 11 Dec 2021 23:20:08 +0200 Subject: [PATCH] tools: build `examples/viewer` as a project folder --- cmd/tools/modules/testing/common.v | 9 ++++----- cmd/tools/vbuild-examples.v | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/cmd/tools/modules/testing/common.v b/cmd/tools/modules/testing/common.v index b3a1085e78..0b7d169836 100644 --- a/cmd/tools/modules/testing/common.v +++ b/cmd/tools/modules/testing/common.v @@ -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 diff --git a/cmd/tools/vbuild-examples.v b/cmd/tools/vbuild-examples.v index 82ddc1e968..184aba6bb6 100644 --- a/cmd/tools/vbuild-examples.v +++ b/cmd/tools/vbuild-examples.v @@ -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) } }