tools/vbuild-examples: test hot code reloading examples with -live
parent
2e30e1453d
commit
0ff2754677
|
@ -59,6 +59,7 @@ pub fn (ts mut TestSession) test() {
|
||||||
tmpc_filepath := file.replace('.v', '.tmp.c')
|
tmpc_filepath := file.replace('.v', '.tmp.c')
|
||||||
|
|
||||||
cmd := '"$ts.vexe" $ts.vargs "$file"'
|
cmd := '"$ts.vexe" $ts.vargs "$file"'
|
||||||
|
//eprintln('>>> v cmd: $cmd')
|
||||||
|
|
||||||
ts.benchmark.step()
|
ts.benchmark.step()
|
||||||
if show_stats {
|
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 ...'
|
main_label := 'Building $folder ...'
|
||||||
finish_label := 'building $folder'
|
finish_label := 'building $folder'
|
||||||
vexe := vexe_path()
|
vexe := vexe_path()
|
||||||
parent_dir := os.dir(vexe)
|
parent_dir := os.dir(vexe)
|
||||||
vlib_should_be_present( parent_dir )
|
vlib_should_be_present( parent_dir )
|
||||||
|
vargs := zargs.replace(vexe, '')
|
||||||
|
|
||||||
eprintln(main_label)
|
eprintln(main_label)
|
||||||
|
eprintln(' v compiler args: "$vargs"')
|
||||||
|
|
||||||
mut session := new_test_sesion( vargs )
|
mut session := new_test_sesion( vargs )
|
||||||
files := os.walk_ext(filepath.join(parent_dir, folder),'.v')
|
files := os.walk_ext(filepath.join(parent_dir, folder),'.v')
|
||||||
mains := files.filter(!it.contains('modules'))
|
mains := files.filter(!it.contains('modules'))
|
||||||
|
|
|
@ -3,22 +3,20 @@ module main
|
||||||
import (
|
import (
|
||||||
os
|
os
|
||||||
testing
|
testing
|
||||||
|
filepath
|
||||||
)
|
)
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
args := os.args
|
args := os.args
|
||||||
args_string := args[1..].join(' ')
|
args_string := args[1..].join(' ')
|
||||||
if testing.v_build_failing(
|
params := args_string.all_before('build-examples')
|
||||||
args_string.all_before('build-examples'), 'examples')
|
|
||||||
{
|
if testing.v_build_failing(params, 'examples'){
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
// Test -live
|
|
||||||
vexe := args[1]
|
if testing.v_build_failing(params + '-live', filepath.join( 'examples', 'hot_reload')){
|
||||||
ret := os.system('$vexe -live examples/hot_reload/message.v')
|
|
||||||
if ret != 0 {
|
|
||||||
println('v -live message.v failed')
|
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
println('v -live message.v is ok')
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
os
|
os
|
||||||
testing
|
testing
|
||||||
benchmark
|
benchmark
|
||||||
|
filepath
|
||||||
)
|
)
|
||||||
|
|
||||||
pub const (
|
pub const (
|
||||||
|
@ -33,7 +34,7 @@ fn v_test_compiler(vargs string){
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Make sure v.c can be compiled without warnings
|
// Make sure v.c can be compiled without warnings
|
||||||
$if mac {
|
$if macos {
|
||||||
if os.exists('/v.v') {
|
if os.exists('/v.v') {
|
||||||
os.system('$vexe -o v.c v.v')
|
os.system('$vexe -o v.c v.v')
|
||||||
if os.system('cc -Werror v.c') != 0 {
|
if os.system('cc -Werror v.c') != 0 {
|
||||||
|
@ -55,6 +56,10 @@ fn v_test_compiler(vargs string){
|
||||||
eprintln('')
|
eprintln('')
|
||||||
building_examples_failed := testing.v_build_failing(vargs, 'examples')
|
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('')
|
eprintln('')
|
||||||
v_module_install_cmd := '$vexe install nedpals.args'
|
v_module_install_cmd := '$vexe install nedpals.args'
|
||||||
eprintln('\nInstalling a v module with: $v_module_install_cmd ')
|
eprintln('\nInstalling a v module with: $v_module_install_cmd ')
|
||||||
|
@ -69,7 +74,10 @@ fn v_test_compiler(vargs string){
|
||||||
vmark.stop()
|
vmark.stop()
|
||||||
eprintln( 'Installing a v module took: ' + vmark.total_duration().str() + 'ms')
|
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)
|
exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue