2019-12-25 15:54:48 +03:00
|
|
|
module main
|
|
|
|
|
2020-04-26 09:32:05 +03:00
|
|
|
import os
|
|
|
|
import testing
|
2020-10-21 12:54:03 +03:00
|
|
|
import v.util
|
2019-12-25 15:54:48 +03:00
|
|
|
|
2019-12-27 19:59:04 +03:00
|
|
|
const (
|
2020-10-14 23:49:12 +03:00
|
|
|
known_failing_exceptions = [
|
2021-05-08 13:32:29 +03:00
|
|
|
'vlib/crypto/aes/const.v' /* const array wrapped in too many lines */,
|
2019-12-25 15:54:48 +03:00
|
|
|
]
|
2019-12-27 19:59:04 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
fn main() {
|
2020-12-20 18:08:56 +03:00
|
|
|
args_string := os.args[1..].join(' ')
|
2019-12-27 19:59:04 +03:00
|
|
|
v_test_formatting(args_string.all_before('test-fmt'))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn v_test_formatting(vargs string) {
|
|
|
|
all_v_files := v_files()
|
2020-10-24 16:36:26 +03:00
|
|
|
util.prepare_tool_when_needed('vfmt.v')
|
2020-02-08 19:01:10 +03:00
|
|
|
testing.eheader('Run "v fmt" over all .v files')
|
2021-05-08 13:32:29 +03:00
|
|
|
mut vfmt_test_session := testing.new_test_session('$vargs fmt -worker', false)
|
2019-12-27 19:59:04 +03:00
|
|
|
vfmt_test_session.files << all_v_files
|
2020-10-14 23:58:31 +03:00
|
|
|
vfmt_test_session.skip_files << known_failing_exceptions
|
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 {
|
2020-10-14 23:49:12 +03:00
|
|
|
eprintln('\nWARNING: v fmt failed $vfmt_test_session.benchmark.nfail times.\n')
|
2020-10-14 23:42:30 +03:00
|
|
|
exit(1)
|
2019-12-25 15:54:48 +03:00
|
|
|
}
|
|
|
|
}
|
2019-12-27 19:59:04 +03:00
|
|
|
|
|
|
|
fn v_files() []string {
|
2020-04-26 14:49:31 +03:00
|
|
|
mut files_that_can_be_formatted := []string{}
|
2019-12-27 19:59:04 +03:00
|
|
|
all_test_files := os.walk_ext('.', '.v')
|
|
|
|
for tfile in all_test_files {
|
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
|
|
|
|
}
|