Skip to content

Commit 0957e26

Browse files
committed
tests: allow for VAUTOFIX=1 ./vlib/v/slow_tests/repl/repl_test.v, describe repl_test.v in TESTS.md
1 parent a818744 commit 0957e26

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

‎TESTS.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,21 @@ Each `.c.must_have` file, consists of multiple lines. Each of these
8080
lines, *should* be present *at least once* in the output, when the .vv
8181
file is compiled with `-o -` .
8282

83+
## REPL tests
84+
85+
The test runner for these is `vlib/v/slow_tests/repl/repl_test.v`.
86+
87+
The test cases for the V REPL, are stored in .repl files, in the folder
88+
`vlib/v/slow_tests/repl/`. Each .repl file in this folder, contains several
89+
lines of input to the V repl, followed by a single line of `===output===`,
90+
and then the output lines, that the repl would normally show for the input
91+
lines.
92+
93+
If you change the compiler or the REPL source, and you have breaks in those
94+
.repl files, you can replace the current output in them, by running several
95+
times `VAUTOFIX=1 ./vlib/v/slow_tests/repl/repl_test.v`, until all the
96+
files are fixed and the test pass.
97+
8398
## `v vlib/v/slow_tests/run_project_folders_test.v`
8499

85100
This *test runner*, checks whether whole project folders, can be compiled, and run.

‎vlib/v/slow_tests/repl/runner/runner.v‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ module runner
33
import os
44
import v.util.diff
55

6+
const is_vautofix = os.getenv('VAUTOFIX') != ''
7+
68
pub struct RunnerOptions {
79
pub:
810
wd string
@@ -62,6 +64,11 @@ pub fn run_repl_file(wd string, vexec string, file string) !string {
6264
}
6365
os.rm(input_temporary_filename)!
6466
if result != output {
67+
if is_vautofix {
68+
new_content := input + '===output===\n' + r.output.trim_right('\n\r') + '\n'
69+
os.write_file(file, new_content)!
70+
eprintln('>>> fixed file: `${file}`, new_content.len: ${new_content.len}')
71+
}
6572
return diff_error(file, output, result)
6673
}
6774
return file.replace('./', '')

0 commit comments

Comments
 (0)