tools/vbuild-examples: test hot code reloading examples with -live

pull/2984/head
Delyan Angelov 2019-12-05 13:22:54 +02:00 committed by Alexander Medvednikov
parent 2e30e1453d
commit 0ff2754677
3 changed files with 23 additions and 13 deletions

View File

@ -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'))

View File

@ -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')
}

View File

@ -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)
}