1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

vfmt: implement support for // vfmt off and // vfmt on, with it, v fmt -w . now works. (#16335)

This commit is contained in:
Delyan Angelov
2022-11-05 08:08:01 +02:00
committed by GitHub
parent 131d07aede
commit b52b8429d4
21 changed files with 760 additions and 503 deletions

View File

@ -151,13 +151,11 @@ pub fn (mut ts TestSession) print_messages() {
pub fn new_test_session(_vargs string, will_compile bool) TestSession {
mut skip_files := []string{}
// Skip the call_v_from_c files. They need special instructions for compilation.
// Check the README.md for detailed information.
skip_files << 'examples/call_v_from_c/v_test_print.v'
skip_files << 'examples/call_v_from_c/v_test_math.v'
if will_compile {
// Skip the call_v_from_c files. They need special instructions for compilation.
// Check the README.md for detailed information.
skip_files << 'examples/call_v_from_c/v_test_print.v'
skip_files << 'examples/call_v_from_c/v_test_math.v'
$if msvc {
skip_files << 'vlib/v/tests/const_comptime_eval_before_vinit_test.v' // _constructor used
}

View File

@ -181,7 +181,7 @@ fn (foptions &FormatOptions) format_pipe() {
input_text := os.get_raw_lines_joined()
file_ast := parser.parse_text(input_text, '', table, .parse_comments, prefs)
// checker.new_checker(table, prefs).check(file_ast)
formatted_content := fmt.fmt(file_ast, table, prefs, foptions.is_debug)
formatted_content := fmt.fmt(file_ast, table, prefs, foptions.is_debug, source_text: input_text)
print(formatted_content)
flush_stdout()
foptions.vlog('fmt.fmt worked and $formatted_content.len bytes were written to stdout.')

View File

@ -33,20 +33,7 @@ const vet_folders = [
'examples/term.ui',
]
const verify_known_failing_exceptions = [
// Handcrafted meaningful formatting of code parts (mostly arrays)
'examples/sokol/02_cubes_glsl/cube_glsl.v',
'examples/sokol/03_march_tracing_glsl/rt_glsl.v',
'examples/sokol/04_multi_shader_glsl/rt_glsl.v',
'examples/sokol/05_instancing_glsl/rt_glsl.v',
'vlib/v/checker/tests/modules/deprecated_module/main.v' /* adds deprecated_module. module prefix to imports, even though the folder has v.mod */,
'vlib/gg/m4/graphic.v',
'vlib/gg/m4/m4_test.v',
'vlib/gg/m4/matrix.v'
// TODOs and unfixed vfmt bugs
'vlib/v/tests/inout/string_interpolation_inner_expr_cbr.vv', /* for new string interpolation, prevent resolving to nested interpolation */
'vlib/v/tests/string_new_interpolation_test.v', /* new string interpolation */
]
const verify_known_failing_exceptions = []string{}
const vfmt_verify_list = [
'cmd/',
@ -55,11 +42,7 @@ const vfmt_verify_list = [
'vlib/',
]
const vfmt_known_failing_exceptions = arrays.merge(verify_known_failing_exceptions, [
'vlib/regex/regex_test.v' /* contains meaningfull formatting of the test case data */,
'vlib/crypto/sha512/sha512block_generic.v' /* formatting of large constant arrays wraps to too many lines */,
'vlib/crypto/aes/const.v' /* formatting of large constant arrays wraps to too many lines */,
])
const vfmt_known_failing_exceptions = arrays.merge(verify_known_failing_exceptions, []string{})
const vexe = os.getenv('VEXE')