From 0957e26c88958618933e37ec587cc495231875ad Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Tue, 19 Aug 2025 16:59:04 +0300 Subject: [PATCH] tests: allow for `VAUTOFIX=1 ./vlib/v/slow_tests/repl/repl_test.v`, describe repl_test.v in TESTS.md --- TESTS.md | 15 +++++++++++++++ vlib/v/slow_tests/repl/runner/runner.v | 7 +++++++ 2 files changed, 22 insertions(+) diff --git a/TESTS.md b/TESTS.md index 18ed3d58e9..6476adc18b 100644 --- a/TESTS.md +++ b/TESTS.md @@ -80,6 +80,21 @@ Each `.c.must_have` file, consists of multiple lines. Each of these lines, *should* be present *at least once* in the output, when the .vv file is compiled with `-o -` . +## REPL tests + +The test runner for these is `vlib/v/slow_tests/repl/repl_test.v`. + +The test cases for the V REPL, are stored in .repl files, in the folder +`vlib/v/slow_tests/repl/`. Each .repl file in this folder, contains several +lines of input to the V repl, followed by a single line of `===output===`, +and then the output lines, that the repl would normally show for the input +lines. + +If you change the compiler or the REPL source, and you have breaks in those +.repl files, you can replace the current output in them, by running several +times `VAUTOFIX=1 ./vlib/v/slow_tests/repl/repl_test.v`, until all the +files are fixed and the test pass. + ## `v vlib/v/slow_tests/run_project_folders_test.v` This *test runner*, checks whether whole project folders, can be compiled, and run. diff --git a/vlib/v/slow_tests/repl/runner/runner.v b/vlib/v/slow_tests/repl/runner/runner.v index c85e63d7c0..c14bca1b62 100644 --- a/vlib/v/slow_tests/repl/runner/runner.v +++ b/vlib/v/slow_tests/repl/runner/runner.v @@ -3,6 +3,8 @@ module runner import os import v.util.diff +const is_vautofix = os.getenv('VAUTOFIX') != '' + pub struct RunnerOptions { pub: wd string @@ -62,6 +64,11 @@ pub fn run_repl_file(wd string, vexec string, file string) !string { } os.rm(input_temporary_filename)! if result != output { + if is_vautofix { + new_content := input + '===output===\n' + r.output.trim_right('\n\r') + '\n' + os.write_file(file, new_content)! + eprintln('>>> fixed file: `${file}`, new_content.len: ${new_content.len}') + } return diff_error(file, output, result) } return file.replace('./', '')