mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
tools: add report_v_module_folders_without_tests.v . Use it to discover other modules without _test.v files. Add simple ones, to ensure CI can find more breakage on future wide changes to vlib/
This commit is contained in:
parent
17800b4bca
commit
409a4f33a1
68
cmd/tools/report_v_module_folders_without_tests.v
Normal file
68
cmd/tools/report_v_module_folders_without_tests.v
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
module main
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
const vexe = @VEXE
|
||||||
|
|
||||||
|
const known_skip_patterns_env = os.getenv('VKNOWN_SKIP_PATTERNS')
|
||||||
|
|
||||||
|
const known_folder_patterns_that_are_not_module_ones = [
|
||||||
|
'vlib/sync/bench',
|
||||||
|
'/tests',
|
||||||
|
'/testdata',
|
||||||
|
'/preludes_js',
|
||||||
|
'vlib/builtin/js', // TODO: fix compiler panic
|
||||||
|
'vlib/fontstash', // used by `gg`
|
||||||
|
'vlib/sokol/sfons', // used by `gg`, and by examples/sokol/fonts.v
|
||||||
|
'vlib/sokol/sapp', // used by `gg`, and many examples/
|
||||||
|
'vlib/sokol/gfx', // used by `gg`, `x.ttf`
|
||||||
|
'vlib/sokol/sgl', // used by `gg`
|
||||||
|
'vlib/toml', // toml is well tested, even if the top level folder does not have _test.v files, the ones below do
|
||||||
|
'vlib/v/', // the compiler itself is well tested
|
||||||
|
]
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
mut places := if os.args.len > 1 {
|
||||||
|
os.args#[1..]
|
||||||
|
} else {
|
||||||
|
eprintln('> check the current folder only by default ...')
|
||||||
|
['.']
|
||||||
|
}
|
||||||
|
mut known_skip_patterns := known_folder_patterns_that_are_not_module_ones.clone()
|
||||||
|
if known_skip_patterns_env != '' {
|
||||||
|
known_skip_patterns = known_skip_patterns_env.split(',').filter(it != '')
|
||||||
|
}
|
||||||
|
for path in places {
|
||||||
|
eprintln('> Checking folder: `$path` ...')
|
||||||
|
mut found := 0
|
||||||
|
files := os.walk_ext(path, '.v')
|
||||||
|
mut v_files := map[string]int{}
|
||||||
|
mut v_test_files := map[string]int{}
|
||||||
|
for f in files {
|
||||||
|
folder := os.to_slash(os.dir(f))
|
||||||
|
if known_skip_patterns.any(f.contains(it)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if f.ends_with('.v') {
|
||||||
|
v_files[folder]++
|
||||||
|
}
|
||||||
|
if f.ends_with('_test.v') {
|
||||||
|
v_test_files[folder]++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
eprintln('> Found ${v_files.len:5} potential V module folders (containing .v files).')
|
||||||
|
for folder, n_v_files in v_files {
|
||||||
|
n_test_v_files := v_test_files[folder]
|
||||||
|
if n_v_files > 1 && n_test_v_files == 0 {
|
||||||
|
println('> ${n_test_v_files:5} _test.v files, with ${n_v_files:5} .v files, in folder: $folder')
|
||||||
|
compilation := os.execute('${os.quoted_path(vexe)} -shared -W -Wfatal-errors -check ${os.quoted_path(folder)}')
|
||||||
|
if compilation.exit_code != 0 {
|
||||||
|
eprintln('> $folder has parser/checker errors!')
|
||||||
|
eprintln(compilation.output)
|
||||||
|
}
|
||||||
|
found++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
eprintln('> Found $found module folders without _test.v files in `$path` .')
|
||||||
|
}
|
||||||
|
}
|
5
vlib/hash/hash_compiles_test.v
Normal file
5
vlib/hash/hash_compiles_test.v
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import hash
|
||||||
|
|
||||||
|
fn test_hash_compiles() {
|
||||||
|
assert hash.sum64_string('abc', 5).hex_full() == 'ce2703347d216491'
|
||||||
|
}
|
@ -68,8 +68,8 @@ fn (mut h HStmt) prepare_read() ? {
|
|||||||
column_count := h.retrieve_column_count()?
|
column_count := h.retrieve_column_count()?
|
||||||
h.column_count = column_count // remember the count because read will need it
|
h.column_count = column_count // remember the count because read will need it
|
||||||
|
|
||||||
h.buffers = [][]char{len: h.column_count, cap: h.column_count}
|
h.buffers = [][]char{len: h.column_count}
|
||||||
h.indicators = []C.SQLLEN{len: h.column_count, cap: h.column_count}
|
h.indicators = []C.SQLLEN{len: h.column_count}
|
||||||
|
|
||||||
for i := 0; i < h.column_count; i++ {
|
for i := 0; i < h.column_count; i++ {
|
||||||
i_col := C.SQLUSMALLINT(i + 1) // col number starts with 1
|
i_col := C.SQLUSMALLINT(i + 1) // col number starts with 1
|
||||||
@ -82,7 +82,7 @@ fn (mut h HStmt) prepare_read() ? {
|
|||||||
// buffer allocation is the size + 1 to include termination char, since SQL_DESC_LENGTH does not include it.
|
// buffer allocation is the size + 1 to include termination char, since SQL_DESC_LENGTH does not include it.
|
||||||
allocate_size := size_ret + C.SQLLEN(1)
|
allocate_size := size_ret + C.SQLLEN(1)
|
||||||
allocate_size_int := int(allocate_size)
|
allocate_size_int := int(allocate_size)
|
||||||
buff := []char{len: allocate_size_int, cap: allocate_size_int}
|
buff := []char{len: allocate_size_int}
|
||||||
|
|
||||||
// bind the buffer
|
// bind the buffer
|
||||||
retcode = C.SQLBindCol(h.hstmt, C.SQLUSMALLINT(i_col), C.SQLSMALLINT(C.SQL_C_CHAR),
|
retcode = C.SQLBindCol(h.hstmt, C.SQLUSMALLINT(i_col), C.SQLSMALLINT(C.SQL_C_CHAR),
|
||||||
@ -112,7 +112,7 @@ fn (h HStmt) read_rows() ?[][]string {
|
|||||||
if retcode == C.SQLRETURN(C.SQL_SUCCESS) || retcode == C.SQLRETURN(C.SQL_SUCCESS_WITH_INFO) {
|
if retcode == C.SQLRETURN(C.SQL_SUCCESS) || retcode == C.SQLRETURN(C.SQL_SUCCESS_WITH_INFO) {
|
||||||
// copy buffered result to res
|
// copy buffered result to res
|
||||||
for content in h.buffers {
|
for content in h.buffers {
|
||||||
row << string(content)
|
row << unsafe { cstring_to_vstring(content.data) }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if retcode != C.SQLRETURN(C.SQL_NO_DATA) {
|
if retcode != C.SQLRETURN(C.SQL_NO_DATA) {
|
||||||
|
6
vlib/net/mbedtls/mbedtls_compiles_test.v
Normal file
6
vlib/net/mbedtls/mbedtls_compiles_test.v
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import net.mbedtls
|
||||||
|
|
||||||
|
fn test_mbedtls_compiles() {
|
||||||
|
assert mbedtls.is_used == 1
|
||||||
|
assert true
|
||||||
|
}
|
5
vlib/net/ssl/ssl_compiles_test.v
Normal file
5
vlib/net/ssl/ssl_compiles_test.v
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import net.ssl
|
||||||
|
|
||||||
|
fn test_ssl_compiles() {
|
||||||
|
assert sizeof(ssl.SSLConn) > 0
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user