2020-10-24 16:36:26 +03:00
|
|
|
module main
|
|
|
|
|
|
|
|
import os
|
|
|
|
import testing
|
|
|
|
import v.util
|
|
|
|
|
|
|
|
const (
|
2021-01-09 20:25:50 +03:00
|
|
|
vet_known_failing_exceptions = []string{}
|
2020-11-11 23:53:21 +03:00
|
|
|
vet_folders = [
|
2020-10-24 16:36:26 +03:00
|
|
|
'vlib/sqlite',
|
|
|
|
'vlib/v',
|
|
|
|
'cmd/v',
|
|
|
|
'cmd/tools',
|
2021-02-04 18:34:49 +03:00
|
|
|
'examples/2048',
|
|
|
|
'examples/tetris',
|
|
|
|
'examples/term.ui',
|
2020-10-24 16:36:26 +03:00
|
|
|
]
|
2021-01-09 20:25:50 +03:00
|
|
|
verify_known_failing_exceptions = []string{}
|
2020-11-15 17:20:46 +03:00
|
|
|
vfmt_verify_list = [
|
2020-11-21 11:24:11 +03:00
|
|
|
'cmd/v/v.v',
|
2021-01-08 13:25:22 +03:00
|
|
|
'cmd/tools/vdoc/',
|
2021-01-09 17:11:49 +03:00
|
|
|
'cmd/tools/vvet/',
|
2020-12-27 16:51:55 +03:00
|
|
|
'vlib/arrays/',
|
|
|
|
'vlib/benchmark/',
|
|
|
|
'vlib/bitfield/',
|
2020-10-24 16:36:26 +03:00
|
|
|
'vlib/builtin/array.v',
|
2020-12-21 23:24:10 +03:00
|
|
|
'vlib/builtin/array_test.v',
|
2021-01-23 12:25:40 +03:00
|
|
|
'vlib/builtin/string.v',
|
2020-12-14 13:31:24 +03:00
|
|
|
'vlib/builtin/map.v',
|
2020-10-24 16:36:26 +03:00
|
|
|
'vlib/math/bits/bits.v',
|
2020-12-26 15:40:22 +03:00
|
|
|
'vlib/orm/',
|
2020-10-24 16:36:26 +03:00
|
|
|
'vlib/term/colors.v',
|
|
|
|
'vlib/term/term.v',
|
|
|
|
'vlib/v/ast/',
|
|
|
|
'vlib/v/builder/',
|
|
|
|
'vlib/v/cflag/',
|
|
|
|
'vlib/v/checker/',
|
|
|
|
'vlib/v/depgraph/',
|
|
|
|
'vlib/v/doc/',
|
2021-02-21 21:17:12 +03:00
|
|
|
'vlib/v/embed_file/',
|
2020-10-24 16:36:26 +03:00
|
|
|
'vlib/v/errors/',
|
|
|
|
'vlib/v/eval/',
|
|
|
|
'vlib/v/fmt/',
|
2021-02-21 21:17:12 +03:00
|
|
|
'vlib/v/gen/c/',
|
|
|
|
/* 'vlib/v/gen/js/', */
|
|
|
|
'vlib/v/gen/tests/',
|
|
|
|
'vlib/v/gen/x64/',
|
|
|
|
'vlib/v/live/',
|
|
|
|
'vlib/v/markused/',
|
2020-10-24 16:36:26 +03:00
|
|
|
'vlib/v/parser/',
|
2021-02-21 21:17:12 +03:00
|
|
|
/* 'vlib/v/pkgconfig/', */
|
2020-10-24 16:36:26 +03:00
|
|
|
'vlib/v/pref/',
|
2021-02-21 21:17:12 +03:00
|
|
|
'vlib/v/preludes',
|
2020-10-24 16:36:26 +03:00
|
|
|
'vlib/v/scanner/',
|
|
|
|
'vlib/v/table/',
|
2021-02-21 21:17:12 +03:00
|
|
|
/* 'vlib/v/tests/', */
|
|
|
|
'vlib/v/token/',
|
2020-10-24 16:36:26 +03:00
|
|
|
'vlib/v/util/',
|
2021-02-21 21:17:12 +03:00
|
|
|
'vlib/v/vcache/',
|
2020-10-24 16:36:26 +03:00
|
|
|
'vlib/v/vet/',
|
|
|
|
'vlib/v/vmod/',
|
2020-12-21 23:24:10 +03:00
|
|
|
'vlib/cli/',
|
|
|
|
'vlib/flag/',
|
2020-11-15 17:16:08 +03:00
|
|
|
'vlib/gg/gg.v',
|
2020-12-22 10:44:59 +03:00
|
|
|
'vlib/math/big/',
|
2020-12-16 15:15:11 +03:00
|
|
|
'vlib/os/',
|
2020-12-21 23:00:32 +03:00
|
|
|
'vlib/semver/',
|
|
|
|
'vlib/strings/',
|
2020-12-16 15:15:11 +03:00
|
|
|
'vlib/time/',
|
2020-12-27 12:38:12 +03:00
|
|
|
'vlib/vweb/',
|
2020-12-28 08:25:46 +03:00
|
|
|
'vlib/x/websocket/',
|
2020-10-24 16:36:26 +03:00
|
|
|
]
|
|
|
|
)
|
|
|
|
|
2021-01-09 20:25:50 +03:00
|
|
|
const vexe = os.getenv('VEXE')
|
|
|
|
|
|
|
|
const vroot = os.dir(vexe)
|
|
|
|
|
2020-10-24 16:36:26 +03:00
|
|
|
fn main() {
|
2020-12-20 17:40:49 +03:00
|
|
|
args_string := os.args[1..].join(' ')
|
2020-11-15 17:24:25 +03:00
|
|
|
pass_args := args_string.all_before('test-cleancode')
|
2020-10-24 16:36:26 +03:00
|
|
|
v_test_vetting(pass_args)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn tsession(vargs string, tool_source string, tool_cmd string, tool_args string, flist []string, slist []string) testing.TestSession {
|
2021-01-09 20:25:50 +03:00
|
|
|
os.chdir(vroot)
|
2020-10-24 16:36:26 +03:00
|
|
|
testing.eheader('Run `$tool_cmd` over most .v files')
|
|
|
|
mut test_session := testing.new_test_session('$vargs $tool_args')
|
|
|
|
test_session.files << flist
|
|
|
|
test_session.skip_files << slist
|
2021-01-09 21:41:15 +03:00
|
|
|
util.prepare_tool_when_needed(tool_source)
|
|
|
|
// note that util.prepare_tool_when_needed will put its temporary files
|
|
|
|
// in the VTMP from the test session too, so they will be cleaned up
|
|
|
|
// at the end
|
2020-10-24 16:36:26 +03:00
|
|
|
test_session.test()
|
|
|
|
eprintln(test_session.benchmark.total_message('running `$tool_cmd` over most .v files'))
|
|
|
|
return test_session
|
|
|
|
}
|
|
|
|
|
|
|
|
fn v_test_vetting(vargs string) {
|
2021-01-09 17:11:49 +03:00
|
|
|
vet_session := tsession(vargs, 'vvet', 'v vet', 'vet', vet_folders, vet_known_failing_exceptions)
|
2020-11-15 17:20:46 +03:00
|
|
|
verify_session := tsession(vargs, 'vfmt.v', 'v fmt -verify', 'fmt -verify', vfmt_verify_list,
|
2020-11-11 23:53:21 +03:00
|
|
|
verify_known_failing_exceptions)
|
2020-10-24 16:36:26 +03:00
|
|
|
//
|
|
|
|
if vet_session.benchmark.nfail > 0 || verify_session.benchmark.nfail > 0 {
|
|
|
|
eprintln('\n')
|
|
|
|
if vet_session.benchmark.nfail > 0 {
|
|
|
|
eprintln('WARNING: `v vet` failed $vet_session.benchmark.nfail times.')
|
|
|
|
}
|
|
|
|
if verify_session.benchmark.nfail > 0 {
|
|
|
|
eprintln('WARNING: `v fmt -verify` failed $verify_session.benchmark.nfail times.')
|
|
|
|
}
|
|
|
|
exit(1)
|
|
|
|
}
|
|
|
|
}
|