Skip to content

Commit

Permalink
v: prepare for making -W impure-v the default (#19940)
Browse files Browse the repository at this point in the history
  • Loading branch information
JalonSolov committed Nov 20, 2023
1 parent 6cc51f2 commit 0da00cc
Show file tree
Hide file tree
Showing 47 changed files with 33 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/linux_ci.yml
Expand Up @@ -203,8 +203,8 @@ jobs:
run: ./v -autofree -o tetris examples/tetris/tetris.v
- name: Build blog tutorial with -autofree
run: ./v -autofree -o blog tutorials/building_a_simple_web_blog_with_vweb/code/blog
- name: Build option_test.v with -autofree
run: ./v -autofree vlib/v/tests/option_test.v
- name: Build option_test.c.v with -autofree
run: ./v -autofree vlib/v/tests/option_test.c.v
- name: V self compilation with -parallel-cc
run: |
./v -o v2 -parallel-cc cmd/v
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/windows_ci.yml
Expand Up @@ -41,8 +41,8 @@ jobs:
run: .\v.exe test-self
# - name: Test
# run: .\v.exe test-all
- name: Build option_test.v with -autofree
run: .\v.exe -autofree vlib/v/tests/option_test.v
- name: Build option_test.c.v with -autofree
run: .\v.exe -autofree vlib/v/tests/option_test.c.v
- name: Test v->js
run: ./v -o hi.js examples/hello_v_js.v && node hi.js
- name: Test v binaries
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/modules/testing/common.v
Expand Up @@ -204,7 +204,7 @@ pub fn new_test_session(_vargs string, will_compile bool) TestSession {
skip_files << 'examples/coroutines/coroutines_bench.v'
$if msvc {
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 {
skip_files << 'examples/gg/gg2.v'
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vcomplete.v
Expand Up @@ -74,7 +74,7 @@ SUBCMD:
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 (
auto_complete_commands = [
// simple_cmd
Expand Down
6 changes: 3 additions & 3 deletions cmd/tools/vtest-self.v
Expand Up @@ -180,7 +180,7 @@ const (
'vlib/v/tests/orm_enum_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/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 = [
'do_not_remove',
Expand Down Expand Up @@ -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/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/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 = [
'do_not_remove',
Expand Down Expand Up @@ -350,7 +350,7 @@ fn main() {

$if windows {
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'
}
}

Expand Down
6 changes: 5 additions & 1 deletion vlib/v/builder/compile.v
Expand Up @@ -308,7 +308,11 @@ pub fn (v &Builder) get_user_files() []string {
user_files << os.join_path(preludes_path, 'live_shared.v')
}
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')
if v.pref.test_runner != '' {
Expand Down
6 changes: 3 additions & 3 deletions vlib/v/checker/tests/modules/module_with_redeclaration.out
@@ -1,5 +1,5 @@
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
| ^
2 |
3 | import sokol.memory
2 |
3 | import sokol.memory
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion vlib/v/preludes/test_runner_normal.v
Expand Up @@ -7,7 +7,7 @@ import term
// This file gets compiled as part of the main program, for
// each _test.v file. It implements the default/normal test
// output for `v run file_test.v`
// See also test_runner.v .
// See also test_runner.c.v .
///////////////////////////////////////////////////////////

fn vtest_init() {
Expand Down
Expand Up @@ -4,7 +4,7 @@
* 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.
* 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
* not used any more.
*/
Expand Down
4 changes: 2 additions & 2 deletions vlib/v/slow_tests/valgrind/base64.v
Expand Up @@ -21,7 +21,7 @@ fn main() {
//
encoded_size := base64.encode_in_buffer(s_original, ebuffer)
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 encoded_in_buf[0] == `Y`
assert encoded_in_buf[1] == `W`
Expand All @@ -38,7 +38,7 @@ fn main() {
decoded_size := base64.decode_in_buffer(s_encoded, dbuffer)
assert decoded_size == input_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

mut s := 0
Expand Down
File renamed without changes.
7 changes: 6 additions & 1 deletion vlib/v/slow_tests/valgrind/valgrind_test.v
Expand Up @@ -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}'
full_path_to_source_file := os.join_path(vroot, test)
compile_cmd := '${os.quoted_path(vexe)} -o ${os.quoted_path(exe_filename)} -cg -cflags ' +
Expand Down
File renamed without changes.
Expand Up @@ -16,7 +16,7 @@ fn test_closure_data_is_kept_alive() {
for _ in 0 .. 1000 {
unsafe {
p := malloc(8)
C.memset(p, 0x33, 8)
vmemset(p, 0x33, 8)
}
}
$if gcboehm ? {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion vlib/v/tests/create_dll/create_win_dll_test.v
Expand Up @@ -16,7 +16,7 @@ fn run_test(cc_used string) {
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')
handle := dl.open('create_win_${cc_used}.dll', 0)
assert handle != 0
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions vlib/v/tests/generics_with_pointer_index_test.v
Expand Up @@ -12,8 +12,8 @@ mut:
}

pub fn with_cap[T](cap int) Vec[T] {
new_data := unsafe { C.malloc(cap * int(sizeof(T))) }
unsafe { C.memset(new_data, 0, cap * int(sizeof(T))) }
new_data := unsafe { malloc(cap * int(sizeof(T))) }
unsafe { vmemset(new_data, 0, cap * int(sizeof(T))) }

return Vec[T]{
data: new_data
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion vlib/v/tests/project_with_c_code_3/mod1/wrapper.js.v
@@ -1,6 +1,6 @@
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 {
return 2003
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion vlib/v/vmod/vmod.v
Expand Up @@ -18,7 +18,7 @@ pub fn get_cache() &ModFileCacher {
// examples/hanoi.v
// vlib/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')
// => ModFileAndFolder{'', 'examples'}
Expand Down

0 comments on commit 0da00cc

Please sign in to comment.