v: prepare for making -W impure-v the default (#19940)

This commit is contained in:
JalonSolov 2023-11-20 02:17:59 -05:00 committed by GitHub
parent 6cc51f254f
commit 0da00cc457
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
47 changed files with 33 additions and 24 deletions

View file

@ -203,8 +203,8 @@ jobs:
run: ./v -autofree -o tetris examples/tetris/tetris.v run: ./v -autofree -o tetris examples/tetris/tetris.v
- name: Build blog tutorial with -autofree - name: Build blog tutorial with -autofree
run: ./v -autofree -o blog tutorials/building_a_simple_web_blog_with_vweb/code/blog run: ./v -autofree -o blog tutorials/building_a_simple_web_blog_with_vweb/code/blog
- name: Build option_test.v with -autofree - name: Build option_test.c.v with -autofree
run: ./v -autofree vlib/v/tests/option_test.v run: ./v -autofree vlib/v/tests/option_test.c.v
- name: V self compilation with -parallel-cc - name: V self compilation with -parallel-cc
run: | run: |
./v -o v2 -parallel-cc cmd/v ./v -o v2 -parallel-cc cmd/v

View file

@ -41,8 +41,8 @@ jobs:
run: .\v.exe test-self run: .\v.exe test-self
# - name: Test # - name: Test
# run: .\v.exe test-all # run: .\v.exe test-all
- name: Build option_test.v with -autofree - name: Build option_test.c.v with -autofree
run: .\v.exe -autofree vlib/v/tests/option_test.v run: .\v.exe -autofree vlib/v/tests/option_test.c.v
- name: Test v->js - name: Test v->js
run: ./v -o hi.js examples/hello_v_js.v && node hi.js run: ./v -o hi.js examples/hello_v_js.v && node hi.js
- name: Test v binaries - name: Test v binaries

View file

@ -204,7 +204,7 @@ pub fn new_test_session(_vargs string, will_compile bool) TestSession {
skip_files << 'examples/coroutines/coroutines_bench.v' skip_files << 'examples/coroutines/coroutines_bench.v'
$if msvc { $if msvc {
skip_files << 'vlib/v/tests/const_comptime_eval_before_vinit_test.v' // _constructor used skip_files << 'vlib/v/tests/const_comptime_eval_before_vinit_test.v' // _constructor used
skip_files << 'vlib/v/tests/project_with_cpp_code/compiling_cpp_files_with_a_cplusplus_compiler_test.v' skip_files << 'vlib/v/tests/project_with_cpp_code/compiling_cpp_files_with_a_cplusplus_compiler_test.c.v'
} }
$if solaris { $if solaris {
skip_files << 'examples/gg/gg2.v' skip_files << 'examples/gg/gg2.v'

View file

@ -74,7 +74,7 @@ SUBCMD:
powershell: [QUERY] - returns PowerShell compatible completion code with completions computed from QUERY" powershell: [QUERY] - returns PowerShell compatible completion code with completions computed from QUERY"
) )
// Snooped from cmd/v/v.v, vlib/v/pref/pref.v // Snooped from cmd/v/v.v, vlib/v/pref/pref.c.v
const ( const (
auto_complete_commands = [ auto_complete_commands = [
// simple_cmd // simple_cmd

View file

@ -180,7 +180,7 @@ const (
'vlib/v/tests/orm_enum_test.v', 'vlib/v/tests/orm_enum_test.v',
'vlib/v/tests/orm_sub_array_struct_test.v', 'vlib/v/tests/orm_sub_array_struct_test.v',
'vlib/v/tests/orm_handle_error_for_select_from_not_created_table_test.v', 'vlib/v/tests/orm_handle_error_for_select_from_not_created_table_test.v',
'vlib/v/tests/project_with_cpp_code/compiling_cpp_files_with_a_cplusplus_compiler_test.v', // fails compilation with: undefined reference to vtable for __cxxabiv1::__function_type_info' 'vlib/v/tests/project_with_cpp_code/compiling_cpp_files_with_a_cplusplus_compiler_test.c.v', // fails compilation with: undefined reference to vtable for __cxxabiv1::__function_type_info'
] ]
skip_with_werror = [ skip_with_werror = [
'do_not_remove', 'do_not_remove',
@ -259,7 +259,7 @@ const (
'vlib/v/tests/const_and_global_with_same_name_test.v', // error C2099: initializer is not a constant 'vlib/v/tests/const_and_global_with_same_name_test.v', // error C2099: initializer is not a constant
'vlib/v/tests/sumtype_as_cast_1_test.v', // error: cannot support compound statement expression ({expr; expr; expr;}) 'vlib/v/tests/sumtype_as_cast_1_test.v', // error: cannot support compound statement expression ({expr; expr; expr;})
'vlib/v/tests/sumtype_as_cast_2_test.v', // error: cannot support compound statement expression ({expr; expr; expr;}) 'vlib/v/tests/sumtype_as_cast_2_test.v', // error: cannot support compound statement expression ({expr; expr; expr;})
'vlib/v/tests/project_with_cpp_code/compiling_cpp_files_with_a_cplusplus_compiler_test.v', // TODO 'vlib/v/tests/project_with_cpp_code/compiling_cpp_files_with_a_cplusplus_compiler_test.c.v', // TODO
] ]
skip_on_windows = [ skip_on_windows = [
'do_not_remove', 'do_not_remove',
@ -350,7 +350,7 @@ fn main() {
$if windows { $if windows {
if github_job == 'tcc' { if github_job == 'tcc' {
tsession.skip_files << 'vlib/v/tests/project_with_cpp_code/compiling_cpp_files_with_a_cplusplus_compiler_test.v' tsession.skip_files << 'vlib/v/tests/project_with_cpp_code/compiling_cpp_files_with_a_cplusplus_compiler_test.c.v'
} }
} }

View file

@ -308,7 +308,11 @@ pub fn (v &Builder) get_user_files() []string {
user_files << os.join_path(preludes_path, 'live_shared.v') user_files << os.join_path(preludes_path, 'live_shared.v')
} }
if v.pref.is_test { if v.pref.is_test {
user_files << os.join_path(preludes_path, 'test_runner.v') if v.pref.backend == .js_node {
user_files << os.join_path(preludes_path, 'test_runner.v')
} else {
user_files << os.join_path(preludes_path, 'test_runner.c.v')
}
// //
mut v_test_runner_prelude := os.getenv('VTEST_RUNNER') mut v_test_runner_prelude := os.getenv('VTEST_RUNNER')
if v.pref.test_runner != '' { if v.pref.test_runner != '' {

View file

@ -1,4 +1,4 @@
vlib/v/checker/tests/modules/module_with_redeclaration/redeclare_time_structs.v:1:1: error: project must include a `main` module or be a shared library (compile with `v -shared`) vlib/v/checker/tests/modules/module_with_redeclaration/redeclare_time_structs.c.v:1:1: error: project must include a `main` module or be a shared library (compile with `v -shared`)
1 | module module_with_redeclaration 1 | module module_with_redeclaration
| ^ | ^
2 | 2 |

View file

@ -7,7 +7,7 @@ import term
// This file gets compiled as part of the main program, for // This file gets compiled as part of the main program, for
// each _test.v file. It implements the default/normal test // each _test.v file. It implements the default/normal test
// output for `v run file_test.v` // output for `v run file_test.v`
// See also test_runner.v . // See also test_runner.c.v .
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
fn vtest_init() { fn vtest_init() {

View file

@ -4,7 +4,7 @@
* To verify the effect of "[keep_args_alive]", this attribute may be commented out. * To verify the effect of "[keep_args_alive]", this attribute may be commented out.
* However it is not guaranteed that then this test will fail. * However it is not guaranteed that then this test will fail.
* To provoke a failure it seems to be best to use `gcc` with optimization: * To provoke a failure it seems to be best to use `gcc` with optimization:
* `gcc -gc boehm -cc gcc-9 -prod test keep_args_alive_test.v`. * `gcc -gc boehm -cc gcc-9 -prod test keep_args_alive_test.c.v`.
* Without optimization, pointer variables may remain on the stack even if * Without optimization, pointer variables may remain on the stack even if
* not used any more. * not used any more.
*/ */

View file

@ -21,7 +21,7 @@ fn main() {
// //
encoded_size := base64.encode_in_buffer(s_original, ebuffer) encoded_size := base64.encode_in_buffer(s_original, ebuffer)
mut encoded_in_buf := []u8{len: encoded_size} mut encoded_in_buf := []u8{len: encoded_size}
unsafe { C.memcpy(encoded_in_buf.data, ebuffer, encoded_size) } unsafe { vmemcpy(encoded_in_buf.data, ebuffer, encoded_size) }
assert input_size * 4 / 3 == encoded_size assert input_size * 4 / 3 == encoded_size
assert encoded_in_buf[0] == `Y` assert encoded_in_buf[0] == `Y`
assert encoded_in_buf[1] == `W` assert encoded_in_buf[1] == `W`
@ -38,7 +38,7 @@ fn main() {
decoded_size := base64.decode_in_buffer(s_encoded, dbuffer) decoded_size := base64.decode_in_buffer(s_encoded, dbuffer)
assert decoded_size == input_size assert decoded_size == input_size
mut decoded_in_buf := []u8{len: decoded_size} mut decoded_in_buf := []u8{len: decoded_size}
unsafe { C.memcpy(decoded_in_buf.data, dbuffer, decoded_size) } unsafe { vmemcpy(decoded_in_buf.data, dbuffer, decoded_size) }
assert decoded_in_buf == s_original assert decoded_in_buf == s_original
mut s := 0 mut s := 0

View file

@ -84,7 +84,12 @@ fn test_all() {
} }
} }
// //
base_filename := os.file_name(test).replace('.v', '') mut base_filename := os.file_name(test)
if base_filename.ends_with('.c.v') {
base_filename = base_filename#[..-4]
} else if base_filename.ends_with('.v') {
base_filename = base_filename#[..-2]
}
exe_filename := '${wrkdir}/${base_filename}' exe_filename := '${wrkdir}/${base_filename}'
full_path_to_source_file := os.join_path(vroot, test) full_path_to_source_file := os.join_path(vroot, test)
compile_cmd := '${os.quoted_path(vexe)} -o ${os.quoted_path(exe_filename)} -cg -cflags ' + compile_cmd := '${os.quoted_path(vexe)} -o ${os.quoted_path(exe_filename)} -cg -cflags ' +

View file

@ -16,7 +16,7 @@ fn test_closure_data_is_kept_alive() {
for _ in 0 .. 1000 { for _ in 0 .. 1000 {
unsafe { unsafe {
p := malloc(8) p := malloc(8)
C.memset(p, 0x33, 8) vmemset(p, 0x33, 8)
} }
} }
$if gcboehm ? { $if gcboehm ? {

View file

@ -16,7 +16,7 @@ fn run_test(cc_used string) {
else { '' } else { '' }
} }
assert os.system('${os.quoted_path(@VEXE)} ${cc_flag} -o create_win_${cc_used}.dll -shared create_win_dll.v') == 0 assert os.system('${os.quoted_path(@VEXE)} ${cc_flag} -o create_win_${cc_used}.dll -shared create_win_dll.c.v') == 0
assert os.exists('create_win_${cc_used}.dll') assert os.exists('create_win_${cc_used}.dll')
handle := dl.open('create_win_${cc_used}.dll', 0) handle := dl.open('create_win_${cc_used}.dll', 0)
assert handle != 0 assert handle != 0

View file

@ -12,8 +12,8 @@ mut:
} }
pub fn with_cap[T](cap int) Vec[T] { pub fn with_cap[T](cap int) Vec[T] {
new_data := unsafe { C.malloc(cap * int(sizeof(T))) } new_data := unsafe { malloc(cap * int(sizeof(T))) }
unsafe { C.memset(new_data, 0, cap * int(sizeof(T))) } unsafe { vmemset(new_data, 0, cap * int(sizeof(T))) }
return Vec[T]{ return Vec[T]{
data: new_data data: new_data

View file

@ -1,6 +1,6 @@
module mod1 module mod1
// Note: the function here, overrides the one from wrapper.v // Note: the function here, overrides the one from wrapper.c.v
pub fn vadd(a int, b int) int { pub fn vadd(a int, b int) int {
return 2003 return 2003
} }

View file

@ -18,7 +18,7 @@ pub fn get_cache() &ModFileCacher {
// examples/hanoi.v // examples/hanoi.v
// vlib/v.mod // vlib/v.mod
// vlib/v/tests/project_with_c_code/mod1/v.mod // vlib/v/tests/project_with_c_code/mod1/v.mod
// vlib/v/tests/project_with_c_code/mod1/wrapper.v // vlib/v/tests/project_with_c_code/mod1/wrapper.c.v
// ----------------- // -----------------
// ModFileCacher.get('examples') // ModFileCacher.get('examples')
// => ModFileAndFolder{'', 'examples'} // => ModFileAndFolder{'', 'examples'}