From 969f8f1a758e62cc751e92b4cfd73d6e61038a1e Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sun, 20 Dec 2020 18:27:42 +0200 Subject: [PATCH] ci: fix compilation of the test infrastructure --- cmd/tools/vtest.v | 4 ++-- vlib/v/compiler_errors_test.v | 33 ++++++++++++++------------------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/cmd/tools/vtest.v b/cmd/tools/vtest.v index 9eac67b532..0ec59c7582 100644 --- a/cmd/tools/vtest.v +++ b/cmd/tools/vtest.v @@ -5,8 +5,8 @@ import os.cmdline import testing fn main() { - args := os.args - if args.last() == 'test' { + args := os.args.clone() + if os.args.last() == 'test' { println('Usage:') println(' A)') println(' v test folder/ : run all v tests in the given folder.') diff --git a/vlib/v/compiler_errors_test.v b/vlib/v/compiler_errors_test.v index 46aca3ade8..2d49d2d122 100644 --- a/vlib/v/compiler_errors_test.v +++ b/vlib/v/compiler_errors_test.v @@ -47,10 +47,14 @@ fn test_all() { mut tasks := []TaskDescription{} tasks.add(vexe, parser_dir, '-prod', '.out', parser_tests, false) tasks.add(vexe, checker_dir, '-prod', '.out', checker_tests, false) - tasks.add(vexe, checker_dir, '-d mysymbol run', '.mysymbol.run.out', ['custom_comptime_define_error.vv'], false) - tasks.add(vexe, checker_dir, '-d mydebug run', '.mydebug.run.out', ['custom_comptime_define_if_flag.vv'], false) - tasks.add(vexe, checker_dir, '-d nodebug run', '.nodebug.run.out', ['custom_comptime_define_if_flag.vv'], false) - tasks.add(vexe, checker_dir, '--enable-globals run', '.run.out', ['globals_error.vv'], false) + tasks.add(vexe, checker_dir, '-d mysymbol run', '.mysymbol.run.out', ['custom_comptime_define_error.vv'], + false) + tasks.add(vexe, checker_dir, '-d mydebug run', '.mydebug.run.out', ['custom_comptime_define_if_flag.vv'], + false) + tasks.add(vexe, checker_dir, '-d nodebug run', '.nodebug.run.out', ['custom_comptime_define_if_flag.vv'], + false) + tasks.add(vexe, checker_dir, '--enable-globals run', '.run.out', ['globals_error.vv'], + false) tasks.add(vexe, global_dir, '--enable-globals', '.out', global_tests, false) tasks.add(vexe, module_dir, '-prod run', '.out', module_tests, true) tasks.add(vexe, run_dir, 'run', '.run.out', run_tests, false) @@ -58,9 +62,7 @@ fn test_all() { } fn (mut tasks []TaskDescription) add(vexe string, dir string, voptions string, result_extension string, tests []string, is_module bool) { - paths := vtest.filter_vtest_only(tests, { - basepath: dir - }) + paths := vtest.filter_vtest_only(tests, basepath: dir) for path in paths { tasks << TaskDescription{ vexe: vexe @@ -73,7 +75,6 @@ fn (mut tasks []TaskDescription) add(vexe string, dir string, voptions string, r } } - fn bstep_message(mut bench benchmark.Benchmark, label string, msg string, sduration time.Duration) string { return bench.step_message_with_label_and_duration(label, msg, sduration) } @@ -85,7 +86,7 @@ fn (mut tasks []TaskDescription) run() { bench.set_total_expected_steps(tasks.len) mut work := sync.new_channel(tasks.len) mut results := sync.new_channel(tasks.len) - mut m_skip_files := skip_files + mut m_skip_files := skip_files.clone() $if noskip ? { m_skip_files = [] } @@ -161,9 +162,7 @@ fn (mut task TaskDescription) execute() { } program := task.path cli_cmd := '$task.vexe $task.voptions $program' - res := os.exec(cli_cmd) or { - panic(err) - } + res := os.exec(cli_cmd) or { panic(err) } mut expected := os.read_file(program.replace('.vv', '') + task.result_extension) or { panic(err) } @@ -189,19 +188,15 @@ fn clean_line_endings(s string) string { } fn diff_content(s1 string, s2 string) { - diff_cmd := util.find_working_diff_command() or { - return - } + diff_cmd := util.find_working_diff_command() or { return } println('diff: ') println(util.color_compare_strings(diff_cmd, s1, s2)) println('============\n') } fn get_tests_in_dir(dir string, is_module bool) []string { - files := os.ls(dir) or { - panic(err) - } - mut tests := files + files := os.ls(dir) or { panic(err) } + mut tests := files.clone() if !is_module { tests = files.filter(it.ends_with('.vv')) } else {