mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
implement 'v build-vbinaries' tooling
This commit is contained in:

committed by
Alexander Medvednikov

parent
5ff387bbe4
commit
ee1edab2a9
@ -62,7 +62,7 @@ pub fn (ts mut TestSession) test() {
|
||||
|
||||
ts.benchmark.step()
|
||||
if show_stats {
|
||||
println('-------------------------------------------------')
|
||||
eprintln('-------------------------------------------------')
|
||||
status := os.system(cmd)
|
||||
if status == 0 {
|
||||
ts.benchmark.ok()
|
||||
@ -75,16 +75,16 @@ pub fn (ts mut TestSession) test() {
|
||||
r := os.exec(cmd) or {
|
||||
ts.benchmark.fail()
|
||||
ts.failed = true
|
||||
println(ts.benchmark.step_message('$relative_file ${ts.fail}'))
|
||||
eprintln(ts.benchmark.step_message('$relative_file ${ts.fail}'))
|
||||
continue
|
||||
}
|
||||
if r.exit_code != 0 {
|
||||
ts.benchmark.fail()
|
||||
ts.failed = true
|
||||
println(ts.benchmark.step_message('$relative_file ${ts.fail}\n`$file`\n (\n$r.output\n)'))
|
||||
eprintln(ts.benchmark.step_message('$relative_file ${ts.fail}\n`$file`\n (\n$r.output\n)'))
|
||||
} else {
|
||||
ts.benchmark.ok()
|
||||
println(ts.benchmark.step_message('$relative_file ${ts.ok}'))
|
||||
eprintln(ts.benchmark.step_message('$relative_file ${ts.ok}'))
|
||||
}
|
||||
}
|
||||
os.rm( tmpc_filepath )
|
||||
@ -95,7 +95,7 @@ pub fn (ts mut TestSession) test() {
|
||||
pub fn vlib_should_be_present( parent_dir string ) {
|
||||
vlib_dir := filepath.join( parent_dir, 'vlib' )
|
||||
if !os.dir_exists( vlib_dir ){
|
||||
println('$vlib_dir is missing, it must be next to the V executable')
|
||||
eprintln('$vlib_dir is missing, it must be next to the V executable')
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
@ -107,7 +107,7 @@ pub fn v_build_failing(vargs string, folder string) bool {
|
||||
parent_dir := os.dir(vexe)
|
||||
vlib_should_be_present( parent_dir )
|
||||
|
||||
println(main_label)
|
||||
eprintln(main_label)
|
||||
mut session := new_test_sesion( vargs )
|
||||
files := os.walk_ext(filepath.join(parent_dir, folder),'.v')
|
||||
mains := files.filter(!it.contains('modules'))
|
||||
@ -120,7 +120,60 @@ pub fn v_build_failing(vargs string, folder string) bool {
|
||||
}
|
||||
session.files << rebuildable_mains
|
||||
session.test()
|
||||
println( session.benchmark.total_message( finish_label ) )
|
||||
eprintln( session.benchmark.total_message( finish_label ) )
|
||||
|
||||
return session.failed
|
||||
}
|
||||
|
||||
pub fn build_v_cmd_failed (cmd string) bool {
|
||||
res := os.exec(cmd) or {
|
||||
return true
|
||||
}
|
||||
if res.exit_code != 0 {
|
||||
eprintln('')
|
||||
eprintln( res.output )
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
pub fn building_any_v_binaries_failed() bool {
|
||||
eprintln('Building V binaries...')
|
||||
eprintln('VFLAGS is: "' + os.getenv('VFLAGS') + '"')
|
||||
vexe := testing.vexe_path()
|
||||
parent_dir := os.dir(vexe)
|
||||
testing.vlib_should_be_present( parent_dir )
|
||||
os.chdir( parent_dir )
|
||||
|
||||
mut failed := false
|
||||
v_build_commands := [
|
||||
|
||||
// '$vexe -o v_g -g v.v',
|
||||
// '$vexe -o v_prod_g -prod -g v.v',
|
||||
|
||||
'$vexe -o v_cg -cg v.v',
|
||||
'$vexe -o v_prod_cg -prod -cg v.v',
|
||||
|
||||
'$vexe -o v_prod -prod v.v',
|
||||
]
|
||||
|
||||
mut bmark := benchmark.new_benchmark()
|
||||
bok := term.ok_message('OK')
|
||||
bfail := term.fail_message('FAIL')
|
||||
for cmd in v_build_commands {
|
||||
bmark.step()
|
||||
if build_v_cmd_failed(cmd) {
|
||||
bmark.fail()
|
||||
failed = true
|
||||
eprintln(bmark.step_message('$cmd => ${bfail} . See details above ^^^^^^^'))
|
||||
eprintln('')
|
||||
continue
|
||||
}
|
||||
bmark.ok()
|
||||
eprintln(bmark.step_message('$cmd => ${bok}'))
|
||||
}
|
||||
bmark.stop()
|
||||
eprintln( bmark.total_message( 'building v binaries' ) )
|
||||
|
||||
return failed
|
||||
}
|
||||
|
9
tools/vbuild-vbinaries.v
Normal file
9
tools/vbuild-vbinaries.v
Normal file
@ -0,0 +1,9 @@
|
||||
module main
|
||||
|
||||
import testing
|
||||
|
||||
fn main() {
|
||||
if testing.building_any_v_binaries_failed() {
|
||||
exit(1)
|
||||
}
|
||||
}
|
@ -27,7 +27,7 @@ fn v_test_compiler(vargs string){
|
||||
|
||||
/*
|
||||
if !os.file_exists(parent_dir + '/v.v') {
|
||||
println('v.v is missing, it must be next to the V executable')
|
||||
eprintln('v.v is missing, it must be next to the V executable')
|
||||
exit(1)
|
||||
}
|
||||
*/
|
||||
@ -37,38 +37,37 @@ fn v_test_compiler(vargs string){
|
||||
if os.file_exists('/v.v') {
|
||||
os.system('$vexe -o v.c v.v')
|
||||
if os.system('cc -Werror v.c') != 0 {
|
||||
println('cc failed to build v.c without warnings')
|
||||
eprintln('cc failed to build v.c without warnings')
|
||||
exit(1)
|
||||
}
|
||||
println('v.c can be compiled without warnings. This is good :)')
|
||||
eprintln('v.c can be compiled without warnings. This is good :)')
|
||||
}
|
||||
}
|
||||
|
||||
building_tools_failed := testing.v_build_failing(vargs, 'tools')
|
||||
|
||||
println('\nTesting all _test.v files...')
|
||||
eprintln('\nTesting all _test.v files...')
|
||||
mut compiler_test_session := testing.new_test_sesion( vargs )
|
||||
compiler_test_session.files << os.walk_ext(parent_dir, '_test.v')
|
||||
compiler_test_session.test()
|
||||
println( compiler_test_session.benchmark.total_message('running V tests') )
|
||||
eprintln( compiler_test_session.benchmark.total_message('running V tests') )
|
||||
|
||||
println('')
|
||||
eprintln('')
|
||||
building_examples_failed := testing.v_build_failing(vargs, 'examples')
|
||||
|
||||
|
||||
eprintln('')
|
||||
v_module_install_cmd := '$vexe install nedpals.args'
|
||||
println('\nInstalling a v module with: $v_module_install_cmd ')
|
||||
eprintln('\nInstalling a v module with: $v_module_install_cmd ')
|
||||
mut vmark := benchmark.new_benchmark()
|
||||
ret := os.system(v_module_install_cmd)
|
||||
if ret != 0 {
|
||||
println('failed to run v install')
|
||||
exit(1)
|
||||
eprintln('failed to run v install')
|
||||
}
|
||||
if !os.file_exists(v_modules_path + '/nedpals/args') {
|
||||
println('v failed to install a test module')
|
||||
exit(1)
|
||||
eprintln('v failed to install a test module')
|
||||
}
|
||||
vmark.stop()
|
||||
println( '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 {
|
||||
exit(1)
|
||||
|
Reference in New Issue
Block a user