diff --git a/vlib/v/builder/cc.v b/vlib/v/builder/cc.v index 9c6d666b54..e685cc93d0 100644 --- a/vlib/v/builder/cc.v +++ b/vlib/v/builder/cc.v @@ -545,8 +545,7 @@ fn (mut v Builder) cc() { builtin_obj_path := v.rebuild_cached_module(vexe, 'vlib/builtin') libs << builtin_obj_path for ast_file in v.parsed_files { - is_test := ast_file.path.ends_with('_test.v') || ast_file.path.ends_with('_test.vv') - if is_test && ast_file.mod.name != 'main' { + if v.pref.is_test && ast_file.mod.name != 'main' { imp_path := v.find_module_path(ast_file.mod.name, ast_file.path) or { verror('cannot import module "$ast_file.mod.name" (not found)') break diff --git a/vlib/v/builder/compile.v b/vlib/v/builder/compile.v index 21fead410e..c1776fe45c 100644 --- a/vlib/v/builder/compile.v +++ b/vlib/v/builder/compile.v @@ -245,7 +245,7 @@ pub fn (v &Builder) get_user_files() []string { if v.pref.is_prof { user_files << os.join_path(preludes_path, 'profiled_program.v') } - is_test := dir.ends_with('_test.v') || dir.ends_with('_test.vv') + is_test := v.pref.is_test mut is_internal_module_test := false if is_test { tcontent := os.read_file(dir) or { diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index fcea13dc78..35f6d5654d 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -215,8 +215,7 @@ pub fn cgen(files []ast.File, table &table.Table, pref &pref.Preferences) string } // println('\ncgen "$g.file.path" nr_stmts=$file.stmts.len') // building_v := true && (g.file.path.contains('/vlib/') || g.file.path.contains('cmd/v')) - is_test := g.file.path.ends_with('_test.vv') || g.file.path.ends_with('_test.v') - g.is_test = is_test + g.is_test = g.pref.is_test if g.file.path == '' || !g.pref.autofree { // cgen test or building V // println('autofree=false') @@ -1046,7 +1045,7 @@ fn (mut g Gen) stmt(node ast.Stmt) { // We are using prebuilt modules, we do not need to generate // their functions in main.c. if node.mod != 'main' && node.mod != 'help' && !should_bundle_module - && !g.file.path.ends_with('_test.v')&& node.generic_params.len == 0 { + && !g.pref.is_test&& node.generic_params.len == 0 { skip = true } } diff --git a/vlib/v/gen/js/js.v b/vlib/v/gen/js/js.v index 63f261c23e..391f75d9bd 100644 --- a/vlib/v/gen/js/js.v +++ b/vlib/v/gen/js/js.v @@ -82,14 +82,14 @@ pub fn gen(files []ast.File, table &table.Table, pref &pref.Preferences) string for file in files { g.file = file g.enter_namespace(g.file.mod.name) - g.is_test = g.file.path.ends_with('_test.v') || g.file.path.ends_with('_test.vv') + g.is_test = g.pref.is_test g.find_class_methods(file.stmts) g.escape_namespace() } for file in files { g.file = file g.enter_namespace(g.file.mod.name) - g.is_test = g.file.path.ends_with('_test.v') || g.file.path.ends_with('_test.vv') + g.is_test = g.pref.is_test // store imports mut imports := []string{} for imp in g.file.imports {