2019-12-25 15:54:48 +03:00
|
|
|
module main
|
|
|
|
|
|
|
|
import (
|
|
|
|
os
|
|
|
|
testing
|
|
|
|
)
|
|
|
|
|
2019-12-27 19:59:04 +03:00
|
|
|
const (
|
|
|
|
known_failing_exceptions = ['./examples/vweb/vweb_example.v',
|
2019-12-25 15:54:48 +03:00
|
|
|
'./tools/gen_vc.v',
|
2020-02-08 19:01:10 +03:00
|
|
|
'./tools/modules/vgit/vgit.v', // generics
|
2020-01-08 23:45:47 +03:00
|
|
|
'./tools/preludes/live_main.v',
|
|
|
|
'./tools/preludes/live_shared.v',
|
|
|
|
'./tools/preludes/tests_assertions.v',
|
|
|
|
'./tools/preludes/tests_with_stats.v',
|
2020-02-08 19:01:10 +03:00
|
|
|
'./tools/performance_compare.v', // generics
|
|
|
|
'./tools/oldv.v', // generics
|
2019-12-25 15:54:48 +03:00
|
|
|
'./tutorials/code/blog/article.v',
|
|
|
|
'./tutorials/code/blog/blog.v',
|
|
|
|
'./vlib/arrays/arrays.v',
|
|
|
|
'./vlib/arrays/arrays_test.v',
|
|
|
|
'./vlib/builtin/js/hashmap.v',
|
|
|
|
'./vlib/compiler/tests/fn_variadic_test.v',
|
|
|
|
'./vlib/compiler/tests/generic_test.v',
|
|
|
|
'./vlib/crypto/aes/aes.v',
|
|
|
|
'./vlib/crypto/aes/aes_cbc.v',
|
|
|
|
'./vlib/crypto/aes/block_generic.v',
|
|
|
|
'./vlib/crypto/aes/const.v',
|
|
|
|
'./vlib/crypto/aes/cypher_generic.v',
|
|
|
|
'./vlib/crypto/rc4/rc4.v',
|
|
|
|
'./vlib/eventbus/eventbus_test.v',
|
|
|
|
'./vlib/os/bare/bare_example_linux.v',
|
|
|
|
'./vlib/szip/szip.v',
|
2020-01-08 23:45:47 +03:00
|
|
|
'./vlib/uiold/examples/users_gui/users.v',
|
2019-12-25 15:54:48 +03:00
|
|
|
'./vlib/vweb/assets/assets.v',
|
|
|
|
'./vlib/vweb/vweb.v',
|
|
|
|
]
|
2019-12-27 19:59:04 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
args := os.args
|
|
|
|
args_string := args[1..].join(' ')
|
|
|
|
v_test_formatting(args_string.all_before('test-fmt'))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn v_test_formatting(vargs string) {
|
|
|
|
all_v_files := v_files()
|
2020-02-08 19:01:10 +03:00
|
|
|
testing.eheader('Run "v fmt" over all .v files')
|
2019-12-27 19:59:04 +03:00
|
|
|
mut vfmt_test_session := testing.new_test_session('$vargs fmt -worker')
|
|
|
|
vfmt_test_session.files << all_v_files
|
2019-12-25 15:54:48 +03:00
|
|
|
vfmt_test_session.test()
|
2019-12-27 19:59:04 +03:00
|
|
|
eprintln(vfmt_test_session.benchmark.total_message('running vfmt over V files'))
|
2019-12-25 15:54:48 +03:00
|
|
|
if vfmt_test_session.benchmark.nfail > 0 {
|
|
|
|
panic('\nWARNING: v fmt failed ${vfmt_test_session.benchmark.nfail} times.\n')
|
|
|
|
}
|
|
|
|
}
|
2019-12-27 19:59:04 +03:00
|
|
|
|
|
|
|
fn v_files() []string {
|
|
|
|
mut files_that_can_be_formatted := []string
|
|
|
|
all_test_files := os.walk_ext('.', '.v')
|
|
|
|
for tfile in all_test_files {
|
|
|
|
if tfile in known_failing_exceptions {
|
|
|
|
continue
|
|
|
|
}
|
2019-12-28 15:55:53 +03:00
|
|
|
if tfile.starts_with('./vlib/v/cgen/tests') {
|
|
|
|
continue
|
|
|
|
}
|
2019-12-27 19:59:04 +03:00
|
|
|
files_that_can_be_formatted << tfile
|
|
|
|
}
|
|
|
|
return files_that_can_be_formatted
|
|
|
|
}
|