mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
tools: make v test-cleancode test everything by default (#10050)
This commit is contained in:
@@ -12,6 +12,10 @@ const github_job = os.getenv('GITHUB_JOB')
|
||||
|
||||
const show_start = os.getenv('VTEST_SHOW_START') == '1'
|
||||
|
||||
const hide_skips = os.getenv('VTEST_HIDE_SKIP') == '1'
|
||||
|
||||
const hide_oks = os.getenv('VTEST_HIDE_OK') == '1'
|
||||
|
||||
pub struct TestSession {
|
||||
pub mut:
|
||||
files []string
|
||||
@@ -108,43 +112,50 @@ pub fn (mut ts TestSession) print_messages() {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_test_session(_vargs string) TestSession {
|
||||
pub fn new_test_session(_vargs string, will_compile bool) TestSession {
|
||||
mut skip_files := []string{}
|
||||
$if solaris {
|
||||
skip_files << 'examples/gg/gg2.v'
|
||||
skip_files << 'examples/pico/pico.v'
|
||||
skip_files << 'examples/sokol/fonts.v'
|
||||
skip_files << 'examples/sokol/drawing.v'
|
||||
}
|
||||
$if macos {
|
||||
skip_files << 'examples/database/mysql.v'
|
||||
skip_files << 'examples/database/orm.v'
|
||||
skip_files << 'examples/database/pg/customer.v'
|
||||
}
|
||||
$if windows {
|
||||
skip_files << 'examples/database/mysql.v'
|
||||
skip_files << 'examples/database/orm.v'
|
||||
skip_files << 'examples/websocket/ping.v' // requires OpenSSL
|
||||
skip_files << 'examples/websocket/client-server/client.v' // requires OpenSSL
|
||||
skip_files << 'examples/websocket/client-server/server.v' // requires OpenSSL
|
||||
$if tinyc {
|
||||
skip_files << 'examples/database/orm.v' // try fix it
|
||||
if will_compile {
|
||||
$if solaris {
|
||||
skip_files << 'examples/gg/gg2.v'
|
||||
skip_files << 'examples/pico/pico.v'
|
||||
skip_files << 'examples/sokol/fonts.v'
|
||||
skip_files << 'examples/sokol/drawing.v'
|
||||
}
|
||||
$if macos {
|
||||
skip_files << 'examples/database/mysql.v'
|
||||
skip_files << 'examples/database/orm.v'
|
||||
skip_files << 'examples/database/pg/customer.v'
|
||||
}
|
||||
$if windows {
|
||||
skip_files << 'examples/database/mysql.v'
|
||||
skip_files << 'examples/database/orm.v'
|
||||
skip_files << 'examples/websocket/ping.v' // requires OpenSSL
|
||||
skip_files << 'examples/websocket/client-server/client.v' // requires OpenSSL
|
||||
skip_files << 'examples/websocket/client-server/server.v' // requires OpenSSL
|
||||
$if tinyc {
|
||||
skip_files << 'examples/database/orm.v' // try fix it
|
||||
}
|
||||
}
|
||||
if testing.github_job != 'sokol-shaders-can-be-compiled' {
|
||||
// These examples need .h files that are produced from the supplied .glsl files,
|
||||
// using by the shader compiler tools in https://github.com/floooh/sokol-tools-bin/archive/pre-feb2021-api-changes.tar.gz
|
||||
skip_files << 'examples/sokol/02_cubes_glsl/cube_glsl.v'
|
||||
skip_files << 'examples/sokol/03_march_tracing_glsl/rt_glsl.v'
|
||||
skip_files << 'examples/sokol/04_multi_shader_glsl/rt_glsl.v'
|
||||
skip_files << 'examples/sokol/05_instancing_glsl/rt_glsl.v'
|
||||
// Skip obj_viewer code in the CI
|
||||
skip_files << 'examples/sokol/06_obj_viewer/show_obj.v'
|
||||
}
|
||||
if testing.github_job != 'ubuntu-tcc' {
|
||||
skip_files << 'examples/c_interop_wkhtmltopdf.v' // needs installation of wkhtmltopdf from https://github.com/wkhtmltopdf/packaging/releases
|
||||
// the ttf_test.v is not interactive, but needs X11 headers to be installed, which is done only on ubuntu-tcc for now
|
||||
skip_files << 'vlib/x/ttf/ttf_test.v'
|
||||
}
|
||||
if testing.github_job != 'audio-examples' {
|
||||
skip_files << 'examples/sokol/sounds/melody.v'
|
||||
skip_files << 'examples/sokol/sounds/wav_player.v'
|
||||
skip_files << 'examples/sokol/sounds/simple_sin_tones.v'
|
||||
}
|
||||
}
|
||||
if testing.github_job != 'sokol-shaders-can-be-compiled' {
|
||||
// These examples need .h files that are produced from the supplied .glsl files,
|
||||
// using by the shader compiler tools in https://github.com/floooh/sokol-tools-bin/archive/pre-feb2021-api-changes.tar.gz
|
||||
skip_files << 'examples/sokol/02_cubes_glsl/cube_glsl.v'
|
||||
skip_files << 'examples/sokol/03_march_tracing_glsl/rt_glsl.v'
|
||||
skip_files << 'examples/sokol/04_multi_shader_glsl/rt_glsl.v'
|
||||
skip_files << 'examples/sokol/05_instancing_glsl/rt_glsl.v'
|
||||
// Skip obj_viewer code in the CI
|
||||
skip_files << 'examples/sokol/06_obj_viewer/show_obj.v'
|
||||
}
|
||||
if testing.github_job != 'ubuntu-tcc' {
|
||||
skip_files << 'examples/c_interop_wkhtmltopdf.v' // needs installation of wkhtmltopdf from https://github.com/wkhtmltopdf/packaging/releases
|
||||
// the ttf_test.v is not interactive, but needs X11 headers to be installed, which is done only on ubuntu-tcc for now
|
||||
skip_files << 'vlib/x/ttf/ttf_test.v'
|
||||
}
|
||||
vargs := _vargs.replace('-progress', '').replace('-progress', '')
|
||||
vexe := pref.vexe_path()
|
||||
@@ -268,7 +279,9 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
|
||||
if relative_file.replace('\\', '/') in ts.skip_files {
|
||||
ts.benchmark.skip()
|
||||
tls_bench.skip()
|
||||
ts.append_message(.skip, tls_bench.step_message_skip(relative_file))
|
||||
if !testing.hide_skips {
|
||||
ts.append_message(.skip, tls_bench.step_message_skip(relative_file))
|
||||
}
|
||||
return pool.no_result
|
||||
}
|
||||
if show_stats {
|
||||
@@ -304,7 +317,9 @@ fn worker_trunner(mut p pool.PoolProcessor, idx int, thread_id int) voidptr {
|
||||
} else {
|
||||
ts.benchmark.ok()
|
||||
tls_bench.ok()
|
||||
ts.append_message(.ok, tls_bench.step_message_ok(relative_file))
|
||||
if !testing.hide_oks {
|
||||
ts.append_message(.ok, tls_bench.step_message_ok(relative_file))
|
||||
}
|
||||
}
|
||||
}
|
||||
if os.exists(generated_binary_fpath) {
|
||||
@@ -336,7 +351,7 @@ pub fn prepare_test_session(zargs string, folder string, oskipped []string, main
|
||||
if vargs.len > 0 {
|
||||
eprintln('v compiler args: "$vargs"')
|
||||
}
|
||||
mut session := new_test_session(vargs)
|
||||
mut session := new_test_session(vargs, true)
|
||||
files := os.walk_ext(os.join_path(parent_dir, folder), '.v')
|
||||
mut mains := []string{}
|
||||
mut skipped := oskipped.clone()
|
||||
@@ -414,7 +429,9 @@ pub fn building_any_v_binaries_failed() bool {
|
||||
continue
|
||||
}
|
||||
bmark.ok()
|
||||
eprintln(bmark.step_message_ok('command: $cmd'))
|
||||
if !testing.hide_oks {
|
||||
eprintln(bmark.step_message_ok('command: $cmd'))
|
||||
}
|
||||
}
|
||||
bmark.stop()
|
||||
eprintln(term.h_divider('-'))
|
||||
|
||||
@@ -3,6 +3,7 @@ module main
|
||||
import os
|
||||
import testing
|
||||
import v.util
|
||||
import arrays
|
||||
|
||||
const (
|
||||
vet_known_failing_exceptions = []string{}
|
||||
@@ -31,70 +32,31 @@ const (
|
||||
'vlib/builtin/int.v' /* TODO byteptr: vfmt converts `pub fn (nn byteptr) str() string {` to `nn &byte` and that conflicts with `nn byte` */,
|
||||
'vlib/builtin/string_charptr_byteptr_helpers.v' /* TODO byteptr: a temporary shim to ease the byteptr=>&byte transition */,
|
||||
'vlib/v/tests/fn_high_test.v', /* param name removed */
|
||||
'vlib/v/tests/fn_test.v', /* bad comment formatting */
|
||||
'vlib/v/tests/generics_return_generics_struct_test.v', /* generic fn param removed */
|
||||
'vlib/v/tests/interop_test.v', /* bad comment formatting */
|
||||
'vlib/v/tests/generics_test.v', /* multi_generic_args<Foo<int>, Foo<int> >(...) becomes .... Foo<int>>(...) which does not parse */
|
||||
'vlib/v/tests/string_interpolation_test.v' /* TODO byteptr: &byte.str() behaves differently than byteptr.str() */,
|
||||
'vlib/v/gen/js/tests/js.v', /* local `hello` fn, gets replaced with module `hello` aliased as `hl` */
|
||||
'examples/c_interop_wkhtmltopdf.v', /* &charptr --> &&char */
|
||||
'vlib/v/gen/c/cheaders.v' /* infix wrapping error */,
|
||||
'examples/c_interop_wkhtmltopdf.v' /* &charptr --> &&char */,
|
||||
]
|
||||
vfmt_verify_list = [
|
||||
'cmd/',
|
||||
'examples/',
|
||||
'tutorials/',
|
||||
'vlib/arrays/',
|
||||
'vlib/benchmark/',
|
||||
'vlib/bitfield/',
|
||||
'vlib/builtin/',
|
||||
'vlib/cli/',
|
||||
'vlib/dl/',
|
||||
'vlib/encoding/utf8/',
|
||||
'vlib/flag/',
|
||||
'vlib/gg/',
|
||||
'vlib/math/bits/bits.v',
|
||||
'vlib/orm/',
|
||||
'vlib/runtime/',
|
||||
'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/',
|
||||
'vlib/v/embed_file/',
|
||||
'vlib/v/errors/',
|
||||
'vlib/v/eval/',
|
||||
'vlib/v/fmt/',
|
||||
'vlib/v/gen/c/',
|
||||
'vlib/v/gen/js/',
|
||||
'vlib/v/gen/native/',
|
||||
'vlib/v/live/',
|
||||
'vlib/v/markused/',
|
||||
'vlib/v/parser/',
|
||||
'vlib/v/pkgconfig/',
|
||||
'vlib/v/pref/',
|
||||
'vlib/v/preludes',
|
||||
'vlib/v/scanner/',
|
||||
'vlib/v/tests/',
|
||||
'vlib/v/token/',
|
||||
'vlib/v/util/',
|
||||
'vlib/v/vcache/',
|
||||
'vlib/v/vet/',
|
||||
'vlib/v/vmod/',
|
||||
'vlib/cli/',
|
||||
'vlib/flag/',
|
||||
'vlib/math/big/',
|
||||
'vlib/os/',
|
||||
'vlib/semver/',
|
||||
'vlib/strings/',
|
||||
'vlib/time/',
|
||||
'vlib/vweb/',
|
||||
'vlib/x/json2',
|
||||
'vlib/x/websocket/',
|
||||
'vlib/',
|
||||
]
|
||||
vfmt_known_failing_exceptions = arrays.merge(verify_known_failing_exceptions, [
|
||||
'vlib/strconv/' /* prevent conflicts, till the new pure V string interpolation is merged */,
|
||||
'vlib/net/' /* prevent conflicts, till ipv6 support is merged */,
|
||||
'vlib/math/math_test.v', /* prevent conflict, till the sign PR is merged */
|
||||
'vlib/term/ui/input.v' /* comment after a struct embed is removed */,
|
||||
'vlib/regex/regex_test.v' /* contains meaningfull formatting of the test case data */,
|
||||
'vlib/readline/readline_test.v' /* vfmt eats `{ Readline }` from `import readline { Readline }` */,
|
||||
'vlib/glm/glm.v' /* `mut res &f32` => `mut res f32`, which then fails to compile */,
|
||||
'vlib/fontstash/fontstash_structs.v' /* eats fn arg names for inline callback types in struct field declarations */,
|
||||
'vlib/crypto/sha512/sha512block_generic.v' /* formatting of large constant arrays wraps to too many lines */,
|
||||
'vlib/crypto/aes/const.v' /* formatting of large constant arrays wraps to too many lines */,
|
||||
])
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -113,7 +75,7 @@ fn tsession(vargs string, tool_source string, tool_cmd string, tool_args string,
|
||||
os.chdir(vroot)
|
||||
title_message := 'running $tool_cmd over most .v files'
|
||||
testing.eheader(title_message)
|
||||
mut test_session := testing.new_test_session('$vargs $tool_args')
|
||||
mut test_session := testing.new_test_session('$vargs $tool_args', false)
|
||||
test_session.files << flist
|
||||
test_session.skip_files << slist
|
||||
util.prepare_tool_when_needed(tool_source)
|
||||
@@ -128,10 +90,11 @@ fn tsession(vargs string, tool_source string, tool_cmd string, tool_args string,
|
||||
fn v_test_vetting(vargs string) {
|
||||
expanded_vet_list := util.find_all_v_files(vet_folders) or { return }
|
||||
vet_session := tsession(vargs, 'vvet', 'v vet', 'vet', expanded_vet_list, vet_known_failing_exceptions)
|
||||
//
|
||||
fmt_cmd, fmt_args := if is_fix { 'v fmt -w', 'fmt -w' } else { 'v fmt -verify', 'fmt -verify' }
|
||||
expanded_vfmt_list := util.find_all_v_files(vfmt_verify_list) or { return }
|
||||
verify_session := tsession(vargs, 'vfmt.v', fmt_cmd, fmt_args, expanded_vfmt_list,
|
||||
verify_known_failing_exceptions)
|
||||
vfmt_list := util.find_all_v_files(vfmt_verify_list) or { return }
|
||||
exceptions := util.find_all_v_files(vfmt_known_failing_exceptions) or { return }
|
||||
verify_session := tsession(vargs, 'vfmt.v', fmt_cmd, fmt_args, vfmt_list, exceptions)
|
||||
//
|
||||
if vet_session.benchmark.nfail > 0 || verify_session.benchmark.nfail > 0 {
|
||||
eprintln('\n')
|
||||
|
||||
@@ -6,21 +6,7 @@ import v.util
|
||||
|
||||
const (
|
||||
known_failing_exceptions = [
|
||||
'vlib/crypto/aes/const.v',
|
||||
// multiple narrow columns of []string turned to 1 long single column, otherwise works
|
||||
'vlib/v/gen/js/tests/life.v',
|
||||
// error: unexpected `,`, expecting ), on JS.setInterval(fn () { show(game) game = step(game) }, 500)
|
||||
'vlib/builtin/js/builtin.v',
|
||||
// JS.console.error(s) => JS.error(s), JS.process.exit(c) => JS.exit(c)
|
||||
'vlib/builtin/js/jsfns_node.js.v',
|
||||
'vlib/builtin/js/jsfns.js.v',
|
||||
'vlib/builtin/js/jsfns_browser.js.v',
|
||||
// total chaos (duplicated code several times) in array_eq_test.v
|
||||
'vlib/builtin/array_eq_test.v',
|
||||
// the fn args are removed, then `cb fn (picohttpparser.Request, mut picohttpparser.Response)` can not be reparsed
|
||||
'vlib/picoev/picoev.v',
|
||||
// the preprocessor directives are formated to the V standard, even though they are in a string literal
|
||||
'vlib/v/gen/c/cheaders.v',
|
||||
'vlib/crypto/aes/const.v' /* const array wrapped in too many lines */,
|
||||
]
|
||||
)
|
||||
|
||||
@@ -33,7 +19,7 @@ fn v_test_formatting(vargs string) {
|
||||
all_v_files := v_files()
|
||||
util.prepare_tool_when_needed('vfmt.v')
|
||||
testing.eheader('Run "v fmt" over all .v files')
|
||||
mut vfmt_test_session := testing.new_test_session('$vargs fmt -worker')
|
||||
mut vfmt_test_session := testing.new_test_session('$vargs fmt -worker', false)
|
||||
vfmt_test_session.files << all_v_files
|
||||
vfmt_test_session.skip_files << known_failing_exceptions
|
||||
vfmt_test_session.test()
|
||||
|
||||
@@ -105,7 +105,7 @@ fn main() {
|
||||
title := 'testing vlib'
|
||||
all_test_files := os.walk_ext(os.join_path(vroot, 'vlib'), '_test.v')
|
||||
testing.eheader(title)
|
||||
mut tsession := testing.new_test_session(cmd_prefix)
|
||||
mut tsession := testing.new_test_session(cmd_prefix, true)
|
||||
tsession.files << all_test_files
|
||||
tsession.skip_files << skip_test_files
|
||||
mut werror := false
|
||||
|
||||
@@ -22,7 +22,7 @@ fn main() {
|
||||
backend_pos := args_before.index('-b')
|
||||
backend := if backend_pos == -1 { '.c' } else { args_before[backend_pos + 1] } // this giant mess because closures are not implemented
|
||||
|
||||
mut ts := testing.new_test_session(args_before.join(' '))
|
||||
mut ts := testing.new_test_session(args_before.join(' '), true)
|
||||
for targ in args_after {
|
||||
if os.is_dir(targ) {
|
||||
// Fetch all tests from the directory
|
||||
|
||||
Reference in New Issue
Block a user