diff --git a/cmd/tools/modules/testing/common.v b/cmd/tools/modules/testing/common.v index 6eddb5b140..0cd10213a0 100644 --- a/cmd/tools/modules/testing/common.v +++ b/cmd/tools/modules/testing/common.v @@ -69,6 +69,7 @@ pub fn (mut ts TestSession) test() { // ts.init() mut remaining_files := []string{} + vtest_only := os.getenv('VTEST_ONLY') for dot_relative_file in ts.files { relative_file := dot_relative_file.replace('./', '') file := os.real_path(relative_file) @@ -92,6 +93,11 @@ pub fn (mut ts TestSession) test() { continue } } + if vtest_only.len > 0 { + if !file.contains(vtest_only) { + continue + } + } remaining_files << dot_relative_file } ts.files = remaining_files diff --git a/vlib/v/compiler_errors_test.v b/vlib/v/compiler_errors_test.v index 1255ccfd34..28fddf2e1f 100644 --- a/vlib/v/compiler_errors_test.v +++ b/vlib/v/compiler_errors_test.v @@ -11,14 +11,14 @@ fn test_all() { global_dir := '$classic_dir/globals' global_tests := get_tests_in_dir(global_dir) run_dir := '$classic_dir/run' - run_tests := get_tests_in_dir(run_dir) + run_tests := get_tests_in_dir(run_dir) parser_dir := 'vlib/v/parser/tests' parser_tests := get_tests_in_dir(parser_dir) // -prod so that warns are errors total_errors += check_path(vexe, classic_dir, '-prod', '.out', classic_tests) total_errors += check_path(vexe, global_dir, '--enable-globals', '.out', global_tests) total_errors += check_path(vexe, classic_dir, '--enable-globals run', '.run.out', ['globals_error.vv']) - total_errors += check_path(vexe, run_dir, 'run', '.run.out', run_tests) + total_errors += check_path(vexe, run_dir, 'run', '.run.out', run_tests) total_errors += check_path(vexe, parser_dir, '-prod', '.out', parser_tests) assert total_errors == 0 } @@ -33,9 +33,19 @@ fn get_tests_in_dir(dir string) []string { } fn check_path(vexe, dir, voptions, result_extension string, tests []string) int { + vtest_only := os.getenv('VTEST_ONLY') mut nb_fail := 0 + mut paths := []string{} for test in tests { path := os.join_path(dir, test).replace('\\', '/') + if vtest_only.len > 0 { + if !path.contains(vtest_only) { + continue + } + } + paths << path + } + for path in paths { program := path.replace('.vv', '.v') print(path + ' ') os.cp(path, program) or { @@ -68,5 +78,10 @@ fn check_path(vexe, dir, voptions, result_extension string, tests []string) int } fn clean_line_endings(s string) string { - return s.trim_space().replace(' \n', '\n').replace(' \r\n', '\n').replace('\r\n', '\n').trim('\n') + mut res := s.trim_space() + res = res.replace(' \n', '\n') + res = res.replace(' \r\n', '\n') + res = res.replace('\r\n', '\n') + res = res.trim('\n') + return res }