From 0ff27546776bdb46260101db270448edacbc2ecb Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Thu, 5 Dec 2019 13:22:54 +0200 Subject: [PATCH] tools/vbuild-examples: test hot code reloading examples with -live --- tools/modules/testing/common.v | 8 ++++++-- tools/vbuild-examples.v | 16 +++++++--------- tools/vtest-compiler.v | 12 ++++++++++-- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/tools/modules/testing/common.v b/tools/modules/testing/common.v index 0e09ed42bd..2fe008c66d 100644 --- a/tools/modules/testing/common.v +++ b/tools/modules/testing/common.v @@ -59,6 +59,7 @@ pub fn (ts mut TestSession) test() { tmpc_filepath := file.replace('.v', '.tmp.c') cmd := '"$ts.vexe" $ts.vargs "$file"' + //eprintln('>>> v cmd: $cmd') ts.benchmark.step() if show_stats { @@ -100,14 +101,17 @@ pub fn vlib_should_be_present( parent_dir string ) { } } -pub fn v_build_failing(vargs string, folder string) bool { +pub fn v_build_failing(zargs string, folder string) bool { main_label := 'Building $folder ...' finish_label := 'building $folder' vexe := vexe_path() parent_dir := os.dir(vexe) vlib_should_be_present( parent_dir ) - + vargs := zargs.replace(vexe, '') + eprintln(main_label) + eprintln(' v compiler args: "$vargs"') + mut session := new_test_sesion( vargs ) files := os.walk_ext(filepath.join(parent_dir, folder),'.v') mains := files.filter(!it.contains('modules')) diff --git a/tools/vbuild-examples.v b/tools/vbuild-examples.v index 29f93748e6..b2a5ac8507 100644 --- a/tools/vbuild-examples.v +++ b/tools/vbuild-examples.v @@ -3,22 +3,20 @@ module main import ( os testing + filepath ) fn main() { args := os.args args_string := args[1..].join(' ') - if testing.v_build_failing( - args_string.all_before('build-examples'), 'examples') - { + params := args_string.all_before('build-examples') + + if testing.v_build_failing(params, 'examples'){ exit(1) } - // Test -live - vexe := args[1] - ret := os.system('$vexe -live examples/hot_reload/message.v') - if ret != 0 { - println('v -live message.v failed') + + if testing.v_build_failing(params + '-live', filepath.join( 'examples', 'hot_reload')){ exit(1) } - println('v -live message.v is ok') + } diff --git a/tools/vtest-compiler.v b/tools/vtest-compiler.v index 33da2720c0..a7c21fff78 100644 --- a/tools/vtest-compiler.v +++ b/tools/vtest-compiler.v @@ -4,6 +4,7 @@ import ( os testing benchmark + filepath ) pub const ( @@ -33,7 +34,7 @@ fn v_test_compiler(vargs string){ */ // Make sure v.c can be compiled without warnings - $if mac { + $if macos { if os.exists('/v.v') { os.system('$vexe -o v.c v.v') if os.system('cc -Werror v.c') != 0 { @@ -55,6 +56,10 @@ fn v_test_compiler(vargs string){ eprintln('') building_examples_failed := testing.v_build_failing(vargs, 'examples') + eprintln('') + building_live_failed := testing.v_build_failing(vargs + '-live', + filepath.join( 'examples', 'hot_reload')) + eprintln('') v_module_install_cmd := '$vexe install nedpals.args' eprintln('\nInstalling a v module with: $v_module_install_cmd ') @@ -69,7 +74,10 @@ fn v_test_compiler(vargs string){ vmark.stop() eprintln( 'Installing a v module took: ' + vmark.total_duration().str() + 'ms') - if building_tools_failed || compiler_test_session.failed || building_examples_failed { + if building_tools_failed || + compiler_test_session.failed || + building_examples_failed || + building_live_failed { exit(1) }