From efaf8e57190e108c310e2b4c8892b791a6cbd0d3 Mon Sep 17 00:00:00 2001 From: Adrian Hesketh Date: Sun, 26 May 2024 15:00:09 +0100 Subject: [PATCH] chore: add test to fmt cmd --- .version | 2 +- cmd/templ/fmtcmd/main_test.go | 109 ++++++++++++++++++ cmd/templ/fmtcmd/testdata.txtar | 34 ++++++ cmd/templ/lspcmd/lsp_test.go | 47 +------- .../testdata/go.mod.embed | 0 .../{lspcmd => testproject}/testdata/go.sum | 0 .../{lspcmd => testproject}/testdata/main.go | 0 .../testdata/templates.templ | 0 .../testdata/templates_templ.go | 2 +- cmd/templ/testproject/testproject.go | 48 ++++++++ parser/v2/format_test.go | 2 +- ...ntation__when_close_tag_is_on_new_line.txt | 0 ...tation__when_close_tag_is_on_same_line.txt | 0 ...n_one_line_are_not_placed_on_new_lines.txt | 0 .../br_elements_are_placed_on_new_lines.txt | 0 .../children_indented__closing_elm.txt | 0 .../children_indented__first_child.txt | 0 .../comments_are_preserved.txt | 0 ..._indentation_rules_as_regular_elements.txt | 0 ...pressions_result_in_all_attrs_indented.txt | 0 ...ssions_result_in_all_attrs_indented__2.txt | 0 ...ns_with_else_blocks_are_also_formatted.txt | 0 ...tes__but_use_single_quotes_if_required.txt | 0 .../css_is_indented_by_one_level.txt | 0 .../css_whitespace_is_tidied.txt | 0 .../cssarguments_multiline.txt | 0 .../empty_elements_stay_on_the_same_line.txt | 0 .../for_loops_are_placed_on_a_new_line.txt | 0 .../formatting_does_not_alter_whitespace.txt | 0 ...ions_are_formatted_by_the_go_formatter.txt | 0 .../godoc_comments_are_preserved.txt | 0 ...if_statements_are_placed_on_a_new_line.txt | 0 ..._elements_are_not_placed_on_a_new_line.txt | 0 ...line_are_not_split_into_multiple_lines.txt | 0 ...not_converted_to_self_closing_elements.txt | 0 .../scriptarguments_multiline.txt | 0 ...ing_between_string_expressions_is_kept.txt | 0 ...ing_expressions_is_not_magically_added.txt | 0 ...ween_string_spreads_attributes_is_kept.txt | 0 ...ch_statements_are_placed_on_a_new_line.txt | 0 .../tables_are_formatted_well.txt | 0 ...are_formatted_correctly_when_multiline.txt | 0 ...e_formatted_the_same_as_other_elements.txt | 0 ...platearguments_multiline_with_generics.txt | 0 .../templatefile_can_be_round_tripped.txt | 0 .../templatefile_can_start_with_comments.txt | 0 ...can_start_with_comments_and_whitespace.txt | 0 ...with_multiline_comments_and_whitespace.txt | 0 ..._with_multiple_comments_and_whitespace.txt | 0 .../templateheader_with_build_tags.txt | 0 ...iline_block_containing_multiline_block.txt | 0 ...mplelement_multiline_block_indentation.txt | 0 .../templelement_multiline_in_div.txt | 0 .../templelement_param_spacing.txt | 0 .../templelement_simple_block_indentation.txt | 0 .../templelement_simple_in_div.txt | 0 .../templelement_simple_no_change.txt | 0 ...are_converted_to_self_closing_elements.txt | 0 ...n_new_lines__the_children_are_indented.txt | 0 59 files changed, 197 insertions(+), 47 deletions(-) create mode 100644 cmd/templ/fmtcmd/main_test.go create mode 100644 cmd/templ/fmtcmd/testdata.txtar rename cmd/templ/{lspcmd => testproject}/testdata/go.mod.embed (100%) rename cmd/templ/{lspcmd => testproject}/testdata/go.sum (100%) rename cmd/templ/{lspcmd => testproject}/testdata/main.go (100%) rename cmd/templ/{lspcmd => testproject}/testdata/templates.templ (100%) rename cmd/templ/{lspcmd => testproject}/testdata/templates_templ.go (96%) create mode 100644 cmd/templ/testproject/testproject.go rename parser/v2/{testdata => formattestdata}/all_children_indented__with_nested_indentation__when_close_tag_is_on_new_line.txt (100%) rename parser/v2/{testdata => formattestdata}/all_children_indented__with_nested_indentation__when_close_tag_is_on_same_line.txt (100%) rename parser/v2/{testdata => formattestdata}/br_and_hr_all_on_one_line_are_not_placed_on_new_lines.txt (100%) rename parser/v2/{testdata => formattestdata}/br_elements_are_placed_on_new_lines.txt (100%) rename parser/v2/{testdata => formattestdata}/children_indented__closing_elm.txt (100%) rename parser/v2/{testdata => formattestdata}/children_indented__first_child.txt (100%) rename parser/v2/{testdata => formattestdata}/comments_are_preserved.txt (100%) rename parser/v2/{testdata => formattestdata}/conditional_expressions_have_the_same_child_indentation_rules_as_regular_elements.txt (100%) rename parser/v2/{testdata => formattestdata}/conditional_expressions_result_in_all_attrs_indented.txt (100%) rename parser/v2/{testdata => formattestdata}/conditional_expressions_result_in_all_attrs_indented__2.txt (100%) rename parser/v2/{testdata => formattestdata}/conditional_expressions_with_else_blocks_are_also_formatted.txt (100%) rename parser/v2/{testdata => formattestdata}/constant_attributes_prerfer_double_quotes__but_use_single_quotes_if_required.txt (100%) rename parser/v2/{testdata => formattestdata}/css_is_indented_by_one_level.txt (100%) rename parser/v2/{testdata => formattestdata}/css_whitespace_is_tidied.txt (100%) rename parser/v2/{testdata => formattestdata}/cssarguments_multiline.txt (100%) rename parser/v2/{testdata => formattestdata}/empty_elements_stay_on_the_same_line.txt (100%) rename parser/v2/{testdata => formattestdata}/for_loops_are_placed_on_a_new_line.txt (100%) rename parser/v2/{testdata => formattestdata}/formatting_does_not_alter_whitespace.txt (100%) rename parser/v2/{testdata => formattestdata}/go_expressions_are_formatted_by_the_go_formatter.txt (100%) rename parser/v2/{testdata => formattestdata}/godoc_comments_are_preserved.txt (100%) rename parser/v2/{testdata => formattestdata}/if_statements_are_placed_on_a_new_line.txt (100%) rename parser/v2/{testdata => formattestdata}/inline_elements_are_not_placed_on_a_new_line.txt (100%) rename parser/v2/{testdata => formattestdata}/non_empty_elements_with_children_that_are_all_on_the_same_line_are_not_split_into_multiple_lines.txt (100%) rename parser/v2/{testdata => formattestdata}/script_tags_are_not_converted_to_self_closing_elements.txt (100%) rename parser/v2/{testdata => formattestdata}/scriptarguments_multiline.txt (100%) rename parser/v2/{testdata => formattestdata}/spacing_between_string_expressions_is_kept.txt (100%) rename parser/v2/{testdata => formattestdata}/spacing_between_string_expressions_is_not_magically_added.txt (100%) rename parser/v2/{testdata => formattestdata}/spacing_between_string_spreads_attributes_is_kept.txt (100%) rename parser/v2/{testdata => formattestdata}/switch_statements_are_placed_on_a_new_line.txt (100%) rename parser/v2/{testdata => formattestdata}/tables_are_formatted_well.txt (100%) rename parser/v2/{testdata => formattestdata}/templ_expression_attributes_are_formatted_correctly_when_multiline.txt (100%) rename parser/v2/{testdata => formattestdata}/templ_expression_elements_are_formatted_the_same_as_other_elements.txt (100%) rename parser/v2/{testdata => formattestdata}/templatearguments_multiline_with_generics.txt (100%) rename parser/v2/{testdata => formattestdata}/templatefile_can_be_round_tripped.txt (100%) rename parser/v2/{testdata => formattestdata}/templatefile_can_start_with_comments.txt (100%) rename parser/v2/{testdata => formattestdata}/templatefile_can_start_with_comments_and_whitespace.txt (100%) rename parser/v2/{testdata => formattestdata}/templatefile_can_start_with_multiline_comments_and_whitespace.txt (100%) rename parser/v2/{testdata => formattestdata}/templatefile_can_start_with_multiple_comments_and_whitespace.txt (100%) rename parser/v2/{testdata => formattestdata}/templateheader_with_build_tags.txt (100%) rename parser/v2/{testdata => formattestdata}/templelement_multiline_block_containing_multiline_block.txt (100%) rename parser/v2/{testdata => formattestdata}/templelement_multiline_block_indentation.txt (100%) rename parser/v2/{testdata => formattestdata}/templelement_multiline_in_div.txt (100%) rename parser/v2/{testdata => formattestdata}/templelement_param_spacing.txt (100%) rename parser/v2/{testdata => formattestdata}/templelement_simple_block_indentation.txt (100%) rename parser/v2/{testdata => formattestdata}/templelement_simple_in_div.txt (100%) rename parser/v2/{testdata => formattestdata}/templelement_simple_no_change.txt (100%) rename parser/v2/{testdata => formattestdata}/void_elements_are_converted_to_self_closing_elements.txt (100%) rename parser/v2/{testdata => formattestdata}/when_an_element_contains_children_that_are_on_new_lines__the_children_are_indented.txt (100%) diff --git a/.version b/.version index c46f26d3e..75088f8d2 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -0.2.708 \ No newline at end of file +0.2.709 \ No newline at end of file diff --git a/cmd/templ/fmtcmd/main_test.go b/cmd/templ/fmtcmd/main_test.go new file mode 100644 index 000000000..801b7c086 --- /dev/null +++ b/cmd/templ/fmtcmd/main_test.go @@ -0,0 +1,109 @@ +package fmtcmd + +import ( + _ "embed" + "fmt" + "io" + "log/slog" + "os" + "path/filepath" + "strings" + "testing" + + "github.com/google/go-cmp/cmp" + "golang.org/x/tools/txtar" +) + +//go:embed testdata.txtar +var testDataTxTar []byte + +type testProject struct { + dir string + cleanup func() + testFiles map[string]testFile +} + +type testFile struct { + name string + input, expected string +} + +func setupProjectDir() (tp testProject, err error) { + tp.dir, err = os.MkdirTemp("", "fmtcmd_test_*") + if err != nil { + return tp, fmt.Errorf("failed to make test dir: %w", err) + } + tp.testFiles = make(map[string]testFile) + testData := txtar.Parse(testDataTxTar) + for i := 0; i < len(testData.Files); i += 2 { + file := testData.Files[i] + err = os.WriteFile(filepath.Join(tp.dir, file.Name), file.Data, 0660) + if err != nil { + return tp, fmt.Errorf("failed to write file: %w", err) + } + tp.testFiles[file.Name] = testFile{ + name: filepath.Join(tp.dir, file.Name), + input: string(file.Data), + expected: string(testData.Files[i+1].Data), + } + } + tp.cleanup = func() { + os.RemoveAll(tp.dir) + } + return tp, nil +} + +func TestFormat(t *testing.T) { + log := slog.New(slog.NewJSONHandler(io.Discard, nil)) + t.Run("can format a single file from stdin to stdout", func(t *testing.T) { + tp, err := setupProjectDir() + if err != nil { + t.Fatalf("failed to setup project dir: %v", err) + } + defer tp.cleanup() + stdin := strings.NewReader(tp.testFiles["a.templ"].input) + stdout := new(strings.Builder) + Run(log, stdin, stdout, Arguments{ + ToStdout: true, + }) + if diff := cmp.Diff(tp.testFiles["a.templ"].expected, stdout.String()); diff != "" { + t.Error(diff) + } + }) + t.Run("can process a single file to stdout", func(t *testing.T) { + tp, err := setupProjectDir() + if err != nil { + t.Fatalf("failed to setup project dir: %v", err) + } + defer tp.cleanup() + stdout := new(strings.Builder) + Run(log, nil, stdout, Arguments{ + ToStdout: true, + Files: []string{ + tp.testFiles["a.templ"].name, + }, + }) + if diff := cmp.Diff(tp.testFiles["a.templ"].expected, stdout.String()); diff != "" { + t.Error(diff) + } + }) + t.Run("can process a single file in place", func(t *testing.T) { + tp, err := setupProjectDir() + if err != nil { + t.Fatalf("failed to setup project dir: %v", err) + } + defer tp.cleanup() + Run(log, nil, nil, Arguments{ + Files: []string{ + tp.testFiles["a.templ"].name, + }, + }) + data, err := os.ReadFile(tp.testFiles["a.templ"].name) + if err != nil { + t.Fatalf("failed to read file: %v", err) + } + if diff := cmp.Diff(tp.testFiles["a.templ"].expected, string(data)); diff != "" { + t.Error(diff) + } + }) +} diff --git a/cmd/templ/fmtcmd/testdata.txtar b/cmd/templ/fmtcmd/testdata.txtar new file mode 100644 index 000000000..220c1e80f --- /dev/null +++ b/cmd/templ/fmtcmd/testdata.txtar @@ -0,0 +1,34 @@ +-- a.templ -- +package test + +templ a() { +

A +

+} +-- a.templ -- +package test + +templ a() { +
+

+ A +

+
+} +-- b.templ -- +package test + +templ b() { +

B +

+} +-- a.templ -- +package test + +templ b() { +
+

+ B +

+
+} diff --git a/cmd/templ/lspcmd/lsp_test.go b/cmd/templ/lspcmd/lsp_test.go index 20f725b3a..36ac96ea0 100644 --- a/cmd/templ/lspcmd/lsp_test.go +++ b/cmd/templ/lspcmd/lsp_test.go @@ -1,14 +1,10 @@ package lspcmd import ( - "bytes" "context" - "embed" "fmt" "io" "os" - "path/filepath" - "strings" "sync" "testing" "time" @@ -17,49 +13,12 @@ import ( "github.com/a-h/protocol" "github.com/a-h/templ/cmd/templ/generatecmd/modcheck" "github.com/a-h/templ/cmd/templ/lspcmd/lspdiff" + "github.com/a-h/templ/cmd/templ/testproject" "go.lsp.dev/jsonrpc2" "go.lsp.dev/uri" "go.uber.org/zap" ) -//go:embed testdata/* -var testdata embed.FS - -func createTestProject(moduleRoot string) (dir string, err error) { - dir, err = os.MkdirTemp("", "templ_watch_test_*") - if err != nil { - return dir, fmt.Errorf("failed to make test dir: %w", err) - } - files, err := testdata.ReadDir("testdata") - if err != nil { - return dir, fmt.Errorf("failed to read embedded dir: %w", err) - } - for _, file := range files { - src := filepath.Join("testdata", file.Name()) - data, err := testdata.ReadFile(src) - if err != nil { - return dir, fmt.Errorf("failed to read file: %w", err) - } - - target := filepath.Join(dir, file.Name()) - if file.Name() == "go.mod.embed" { - data = bytes.ReplaceAll(data, []byte("{moduleRoot}"), []byte(moduleRoot)) - target = filepath.Join(dir, "go.mod") - } - err = os.WriteFile(target, data, 0660) - if err != nil { - return dir, fmt.Errorf("failed to copy file: %w", err) - } - } - return dir, nil -} - -func mustReplaceLine(file string, line int, replacement string) string { - lines := strings.Split(file, "\n") - lines[line-1] = replacement - return strings.Join(lines, "\n") -} - func TestCompletion(t *testing.T) { if testing.Short() { return @@ -145,7 +104,7 @@ func TestCompletion(t *testing.T) { for i, test := range tests { t.Run(fmt.Sprintf("test-%d", i), func(t *testing.T) { // Edit the file. - updated := mustReplaceLine(string(templFile), test.line, test.replacement) + updated := testproject.MustReplaceLine(string(templFile), test.line, test.replacement) err = server.DidChange(ctx, &protocol.DidChangeTextDocumentParams{ TextDocument: protocol.VersionedTextDocumentIdentifier{ TextDocumentIdentifier: protocol.TextDocumentIdentifier{ @@ -454,7 +413,7 @@ func Setup(ctx context.Context, log *zap.Logger) (clientCtx context.Context, app return ctx, appDir, client, server, teardown, fmt.Errorf("could not find local templ go.mod file: %v", err) } - appDir, err = createTestProject(moduleRoot) + appDir, err = testproject.Create(moduleRoot) if err != nil { return ctx, appDir, client, server, teardown, fmt.Errorf("failed to create test project: %v", err) } diff --git a/cmd/templ/lspcmd/testdata/go.mod.embed b/cmd/templ/testproject/testdata/go.mod.embed similarity index 100% rename from cmd/templ/lspcmd/testdata/go.mod.embed rename to cmd/templ/testproject/testdata/go.mod.embed diff --git a/cmd/templ/lspcmd/testdata/go.sum b/cmd/templ/testproject/testdata/go.sum similarity index 100% rename from cmd/templ/lspcmd/testdata/go.sum rename to cmd/templ/testproject/testdata/go.sum diff --git a/cmd/templ/lspcmd/testdata/main.go b/cmd/templ/testproject/testdata/main.go similarity index 100% rename from cmd/templ/lspcmd/testdata/main.go rename to cmd/templ/testproject/testdata/main.go diff --git a/cmd/templ/lspcmd/testdata/templates.templ b/cmd/templ/testproject/testdata/templates.templ similarity index 100% rename from cmd/templ/lspcmd/testdata/templates.templ rename to cmd/templ/testproject/testdata/templates.templ diff --git a/cmd/templ/lspcmd/testdata/templates_templ.go b/cmd/templ/testproject/testdata/templates_templ.go similarity index 96% rename from cmd/templ/lspcmd/testdata/templates_templ.go rename to cmd/templ/testproject/testdata/templates_templ.go index a6e2a0c2a..4d14ba55a 100644 --- a/cmd/templ/lspcmd/testdata/templates_templ.go +++ b/cmd/templ/testproject/testdata/templates_templ.go @@ -31,7 +31,7 @@ func Page(count int) templ.Component { var templ_7745c5c3_Var2 string templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", count)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `cmd/templ/lspcmd/testdata/templates.templ`, Line: 13, Col: 54} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `cmd/templ/testproject/testdata/templates.templ`, Line: 13, Col: 54} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) if templ_7745c5c3_Err != nil { diff --git a/cmd/templ/testproject/testproject.go b/cmd/templ/testproject/testproject.go new file mode 100644 index 000000000..b1a553d83 --- /dev/null +++ b/cmd/templ/testproject/testproject.go @@ -0,0 +1,48 @@ +package testproject + +import ( + "bytes" + "embed" + "fmt" + "os" + "path/filepath" + "strings" +) + +//go:embed testdata/* +var testdata embed.FS + +func Create(moduleRoot string) (dir string, err error) { + dir, err = os.MkdirTemp("", "templ_test_*") + if err != nil { + return dir, fmt.Errorf("failed to make test dir: %w", err) + } + files, err := testdata.ReadDir("testdata") + if err != nil { + return dir, fmt.Errorf("failed to read embedded dir: %w", err) + } + for _, file := range files { + src := filepath.Join("testdata", file.Name()) + data, err := testdata.ReadFile(src) + if err != nil { + return dir, fmt.Errorf("failed to read file: %w", err) + } + + target := filepath.Join(dir, file.Name()) + if file.Name() == "go.mod.embed" { + data = bytes.ReplaceAll(data, []byte("{moduleRoot}"), []byte(moduleRoot)) + target = filepath.Join(dir, "go.mod") + } + err = os.WriteFile(target, data, 0660) + if err != nil { + return dir, fmt.Errorf("failed to copy file: %w", err) + } + } + return dir, nil +} + +func MustReplaceLine(file string, line int, replacement string) string { + lines := strings.Split(file, "\n") + lines[line-1] = replacement + return strings.Join(lines, "\n") +} diff --git a/parser/v2/format_test.go b/parser/v2/format_test.go index 9fb574529..3c6ee1eb2 100644 --- a/parser/v2/format_test.go +++ b/parser/v2/format_test.go @@ -10,7 +10,7 @@ import ( ) func TestFormatting(t *testing.T) { - files, _ := filepath.Glob("testdata/*.txt") + files, _ := filepath.Glob("formattestdata/*.txt") if len(files) == 0 { t.Errorf("no test files found") } diff --git a/parser/v2/testdata/all_children_indented__with_nested_indentation__when_close_tag_is_on_new_line.txt b/parser/v2/formattestdata/all_children_indented__with_nested_indentation__when_close_tag_is_on_new_line.txt similarity index 100% rename from parser/v2/testdata/all_children_indented__with_nested_indentation__when_close_tag_is_on_new_line.txt rename to parser/v2/formattestdata/all_children_indented__with_nested_indentation__when_close_tag_is_on_new_line.txt diff --git a/parser/v2/testdata/all_children_indented__with_nested_indentation__when_close_tag_is_on_same_line.txt b/parser/v2/formattestdata/all_children_indented__with_nested_indentation__when_close_tag_is_on_same_line.txt similarity index 100% rename from parser/v2/testdata/all_children_indented__with_nested_indentation__when_close_tag_is_on_same_line.txt rename to parser/v2/formattestdata/all_children_indented__with_nested_indentation__when_close_tag_is_on_same_line.txt diff --git a/parser/v2/testdata/br_and_hr_all_on_one_line_are_not_placed_on_new_lines.txt b/parser/v2/formattestdata/br_and_hr_all_on_one_line_are_not_placed_on_new_lines.txt similarity index 100% rename from parser/v2/testdata/br_and_hr_all_on_one_line_are_not_placed_on_new_lines.txt rename to parser/v2/formattestdata/br_and_hr_all_on_one_line_are_not_placed_on_new_lines.txt diff --git a/parser/v2/testdata/br_elements_are_placed_on_new_lines.txt b/parser/v2/formattestdata/br_elements_are_placed_on_new_lines.txt similarity index 100% rename from parser/v2/testdata/br_elements_are_placed_on_new_lines.txt rename to parser/v2/formattestdata/br_elements_are_placed_on_new_lines.txt diff --git a/parser/v2/testdata/children_indented__closing_elm.txt b/parser/v2/formattestdata/children_indented__closing_elm.txt similarity index 100% rename from parser/v2/testdata/children_indented__closing_elm.txt rename to parser/v2/formattestdata/children_indented__closing_elm.txt diff --git a/parser/v2/testdata/children_indented__first_child.txt b/parser/v2/formattestdata/children_indented__first_child.txt similarity index 100% rename from parser/v2/testdata/children_indented__first_child.txt rename to parser/v2/formattestdata/children_indented__first_child.txt diff --git a/parser/v2/testdata/comments_are_preserved.txt b/parser/v2/formattestdata/comments_are_preserved.txt similarity index 100% rename from parser/v2/testdata/comments_are_preserved.txt rename to parser/v2/formattestdata/comments_are_preserved.txt diff --git a/parser/v2/testdata/conditional_expressions_have_the_same_child_indentation_rules_as_regular_elements.txt b/parser/v2/formattestdata/conditional_expressions_have_the_same_child_indentation_rules_as_regular_elements.txt similarity index 100% rename from parser/v2/testdata/conditional_expressions_have_the_same_child_indentation_rules_as_regular_elements.txt rename to parser/v2/formattestdata/conditional_expressions_have_the_same_child_indentation_rules_as_regular_elements.txt diff --git a/parser/v2/testdata/conditional_expressions_result_in_all_attrs_indented.txt b/parser/v2/formattestdata/conditional_expressions_result_in_all_attrs_indented.txt similarity index 100% rename from parser/v2/testdata/conditional_expressions_result_in_all_attrs_indented.txt rename to parser/v2/formattestdata/conditional_expressions_result_in_all_attrs_indented.txt diff --git a/parser/v2/testdata/conditional_expressions_result_in_all_attrs_indented__2.txt b/parser/v2/formattestdata/conditional_expressions_result_in_all_attrs_indented__2.txt similarity index 100% rename from parser/v2/testdata/conditional_expressions_result_in_all_attrs_indented__2.txt rename to parser/v2/formattestdata/conditional_expressions_result_in_all_attrs_indented__2.txt diff --git a/parser/v2/testdata/conditional_expressions_with_else_blocks_are_also_formatted.txt b/parser/v2/formattestdata/conditional_expressions_with_else_blocks_are_also_formatted.txt similarity index 100% rename from parser/v2/testdata/conditional_expressions_with_else_blocks_are_also_formatted.txt rename to parser/v2/formattestdata/conditional_expressions_with_else_blocks_are_also_formatted.txt diff --git a/parser/v2/testdata/constant_attributes_prerfer_double_quotes__but_use_single_quotes_if_required.txt b/parser/v2/formattestdata/constant_attributes_prerfer_double_quotes__but_use_single_quotes_if_required.txt similarity index 100% rename from parser/v2/testdata/constant_attributes_prerfer_double_quotes__but_use_single_quotes_if_required.txt rename to parser/v2/formattestdata/constant_attributes_prerfer_double_quotes__but_use_single_quotes_if_required.txt diff --git a/parser/v2/testdata/css_is_indented_by_one_level.txt b/parser/v2/formattestdata/css_is_indented_by_one_level.txt similarity index 100% rename from parser/v2/testdata/css_is_indented_by_one_level.txt rename to parser/v2/formattestdata/css_is_indented_by_one_level.txt diff --git a/parser/v2/testdata/css_whitespace_is_tidied.txt b/parser/v2/formattestdata/css_whitespace_is_tidied.txt similarity index 100% rename from parser/v2/testdata/css_whitespace_is_tidied.txt rename to parser/v2/formattestdata/css_whitespace_is_tidied.txt diff --git a/parser/v2/testdata/cssarguments_multiline.txt b/parser/v2/formattestdata/cssarguments_multiline.txt similarity index 100% rename from parser/v2/testdata/cssarguments_multiline.txt rename to parser/v2/formattestdata/cssarguments_multiline.txt diff --git a/parser/v2/testdata/empty_elements_stay_on_the_same_line.txt b/parser/v2/formattestdata/empty_elements_stay_on_the_same_line.txt similarity index 100% rename from parser/v2/testdata/empty_elements_stay_on_the_same_line.txt rename to parser/v2/formattestdata/empty_elements_stay_on_the_same_line.txt diff --git a/parser/v2/testdata/for_loops_are_placed_on_a_new_line.txt b/parser/v2/formattestdata/for_loops_are_placed_on_a_new_line.txt similarity index 100% rename from parser/v2/testdata/for_loops_are_placed_on_a_new_line.txt rename to parser/v2/formattestdata/for_loops_are_placed_on_a_new_line.txt diff --git a/parser/v2/testdata/formatting_does_not_alter_whitespace.txt b/parser/v2/formattestdata/formatting_does_not_alter_whitespace.txt similarity index 100% rename from parser/v2/testdata/formatting_does_not_alter_whitespace.txt rename to parser/v2/formattestdata/formatting_does_not_alter_whitespace.txt diff --git a/parser/v2/testdata/go_expressions_are_formatted_by_the_go_formatter.txt b/parser/v2/formattestdata/go_expressions_are_formatted_by_the_go_formatter.txt similarity index 100% rename from parser/v2/testdata/go_expressions_are_formatted_by_the_go_formatter.txt rename to parser/v2/formattestdata/go_expressions_are_formatted_by_the_go_formatter.txt diff --git a/parser/v2/testdata/godoc_comments_are_preserved.txt b/parser/v2/formattestdata/godoc_comments_are_preserved.txt similarity index 100% rename from parser/v2/testdata/godoc_comments_are_preserved.txt rename to parser/v2/formattestdata/godoc_comments_are_preserved.txt diff --git a/parser/v2/testdata/if_statements_are_placed_on_a_new_line.txt b/parser/v2/formattestdata/if_statements_are_placed_on_a_new_line.txt similarity index 100% rename from parser/v2/testdata/if_statements_are_placed_on_a_new_line.txt rename to parser/v2/formattestdata/if_statements_are_placed_on_a_new_line.txt diff --git a/parser/v2/testdata/inline_elements_are_not_placed_on_a_new_line.txt b/parser/v2/formattestdata/inline_elements_are_not_placed_on_a_new_line.txt similarity index 100% rename from parser/v2/testdata/inline_elements_are_not_placed_on_a_new_line.txt rename to parser/v2/formattestdata/inline_elements_are_not_placed_on_a_new_line.txt diff --git a/parser/v2/testdata/non_empty_elements_with_children_that_are_all_on_the_same_line_are_not_split_into_multiple_lines.txt b/parser/v2/formattestdata/non_empty_elements_with_children_that_are_all_on_the_same_line_are_not_split_into_multiple_lines.txt similarity index 100% rename from parser/v2/testdata/non_empty_elements_with_children_that_are_all_on_the_same_line_are_not_split_into_multiple_lines.txt rename to parser/v2/formattestdata/non_empty_elements_with_children_that_are_all_on_the_same_line_are_not_split_into_multiple_lines.txt diff --git a/parser/v2/testdata/script_tags_are_not_converted_to_self_closing_elements.txt b/parser/v2/formattestdata/script_tags_are_not_converted_to_self_closing_elements.txt similarity index 100% rename from parser/v2/testdata/script_tags_are_not_converted_to_self_closing_elements.txt rename to parser/v2/formattestdata/script_tags_are_not_converted_to_self_closing_elements.txt diff --git a/parser/v2/testdata/scriptarguments_multiline.txt b/parser/v2/formattestdata/scriptarguments_multiline.txt similarity index 100% rename from parser/v2/testdata/scriptarguments_multiline.txt rename to parser/v2/formattestdata/scriptarguments_multiline.txt diff --git a/parser/v2/testdata/spacing_between_string_expressions_is_kept.txt b/parser/v2/formattestdata/spacing_between_string_expressions_is_kept.txt similarity index 100% rename from parser/v2/testdata/spacing_between_string_expressions_is_kept.txt rename to parser/v2/formattestdata/spacing_between_string_expressions_is_kept.txt diff --git a/parser/v2/testdata/spacing_between_string_expressions_is_not_magically_added.txt b/parser/v2/formattestdata/spacing_between_string_expressions_is_not_magically_added.txt similarity index 100% rename from parser/v2/testdata/spacing_between_string_expressions_is_not_magically_added.txt rename to parser/v2/formattestdata/spacing_between_string_expressions_is_not_magically_added.txt diff --git a/parser/v2/testdata/spacing_between_string_spreads_attributes_is_kept.txt b/parser/v2/formattestdata/spacing_between_string_spreads_attributes_is_kept.txt similarity index 100% rename from parser/v2/testdata/spacing_between_string_spreads_attributes_is_kept.txt rename to parser/v2/formattestdata/spacing_between_string_spreads_attributes_is_kept.txt diff --git a/parser/v2/testdata/switch_statements_are_placed_on_a_new_line.txt b/parser/v2/formattestdata/switch_statements_are_placed_on_a_new_line.txt similarity index 100% rename from parser/v2/testdata/switch_statements_are_placed_on_a_new_line.txt rename to parser/v2/formattestdata/switch_statements_are_placed_on_a_new_line.txt diff --git a/parser/v2/testdata/tables_are_formatted_well.txt b/parser/v2/formattestdata/tables_are_formatted_well.txt similarity index 100% rename from parser/v2/testdata/tables_are_formatted_well.txt rename to parser/v2/formattestdata/tables_are_formatted_well.txt diff --git a/parser/v2/testdata/templ_expression_attributes_are_formatted_correctly_when_multiline.txt b/parser/v2/formattestdata/templ_expression_attributes_are_formatted_correctly_when_multiline.txt similarity index 100% rename from parser/v2/testdata/templ_expression_attributes_are_formatted_correctly_when_multiline.txt rename to parser/v2/formattestdata/templ_expression_attributes_are_formatted_correctly_when_multiline.txt diff --git a/parser/v2/testdata/templ_expression_elements_are_formatted_the_same_as_other_elements.txt b/parser/v2/formattestdata/templ_expression_elements_are_formatted_the_same_as_other_elements.txt similarity index 100% rename from parser/v2/testdata/templ_expression_elements_are_formatted_the_same_as_other_elements.txt rename to parser/v2/formattestdata/templ_expression_elements_are_formatted_the_same_as_other_elements.txt diff --git a/parser/v2/testdata/templatearguments_multiline_with_generics.txt b/parser/v2/formattestdata/templatearguments_multiline_with_generics.txt similarity index 100% rename from parser/v2/testdata/templatearguments_multiline_with_generics.txt rename to parser/v2/formattestdata/templatearguments_multiline_with_generics.txt diff --git a/parser/v2/testdata/templatefile_can_be_round_tripped.txt b/parser/v2/formattestdata/templatefile_can_be_round_tripped.txt similarity index 100% rename from parser/v2/testdata/templatefile_can_be_round_tripped.txt rename to parser/v2/formattestdata/templatefile_can_be_round_tripped.txt diff --git a/parser/v2/testdata/templatefile_can_start_with_comments.txt b/parser/v2/formattestdata/templatefile_can_start_with_comments.txt similarity index 100% rename from parser/v2/testdata/templatefile_can_start_with_comments.txt rename to parser/v2/formattestdata/templatefile_can_start_with_comments.txt diff --git a/parser/v2/testdata/templatefile_can_start_with_comments_and_whitespace.txt b/parser/v2/formattestdata/templatefile_can_start_with_comments_and_whitespace.txt similarity index 100% rename from parser/v2/testdata/templatefile_can_start_with_comments_and_whitespace.txt rename to parser/v2/formattestdata/templatefile_can_start_with_comments_and_whitespace.txt diff --git a/parser/v2/testdata/templatefile_can_start_with_multiline_comments_and_whitespace.txt b/parser/v2/formattestdata/templatefile_can_start_with_multiline_comments_and_whitespace.txt similarity index 100% rename from parser/v2/testdata/templatefile_can_start_with_multiline_comments_and_whitespace.txt rename to parser/v2/formattestdata/templatefile_can_start_with_multiline_comments_and_whitespace.txt diff --git a/parser/v2/testdata/templatefile_can_start_with_multiple_comments_and_whitespace.txt b/parser/v2/formattestdata/templatefile_can_start_with_multiple_comments_and_whitespace.txt similarity index 100% rename from parser/v2/testdata/templatefile_can_start_with_multiple_comments_and_whitespace.txt rename to parser/v2/formattestdata/templatefile_can_start_with_multiple_comments_and_whitespace.txt diff --git a/parser/v2/testdata/templateheader_with_build_tags.txt b/parser/v2/formattestdata/templateheader_with_build_tags.txt similarity index 100% rename from parser/v2/testdata/templateheader_with_build_tags.txt rename to parser/v2/formattestdata/templateheader_with_build_tags.txt diff --git a/parser/v2/testdata/templelement_multiline_block_containing_multiline_block.txt b/parser/v2/formattestdata/templelement_multiline_block_containing_multiline_block.txt similarity index 100% rename from parser/v2/testdata/templelement_multiline_block_containing_multiline_block.txt rename to parser/v2/formattestdata/templelement_multiline_block_containing_multiline_block.txt diff --git a/parser/v2/testdata/templelement_multiline_block_indentation.txt b/parser/v2/formattestdata/templelement_multiline_block_indentation.txt similarity index 100% rename from parser/v2/testdata/templelement_multiline_block_indentation.txt rename to parser/v2/formattestdata/templelement_multiline_block_indentation.txt diff --git a/parser/v2/testdata/templelement_multiline_in_div.txt b/parser/v2/formattestdata/templelement_multiline_in_div.txt similarity index 100% rename from parser/v2/testdata/templelement_multiline_in_div.txt rename to parser/v2/formattestdata/templelement_multiline_in_div.txt diff --git a/parser/v2/testdata/templelement_param_spacing.txt b/parser/v2/formattestdata/templelement_param_spacing.txt similarity index 100% rename from parser/v2/testdata/templelement_param_spacing.txt rename to parser/v2/formattestdata/templelement_param_spacing.txt diff --git a/parser/v2/testdata/templelement_simple_block_indentation.txt b/parser/v2/formattestdata/templelement_simple_block_indentation.txt similarity index 100% rename from parser/v2/testdata/templelement_simple_block_indentation.txt rename to parser/v2/formattestdata/templelement_simple_block_indentation.txt diff --git a/parser/v2/testdata/templelement_simple_in_div.txt b/parser/v2/formattestdata/templelement_simple_in_div.txt similarity index 100% rename from parser/v2/testdata/templelement_simple_in_div.txt rename to parser/v2/formattestdata/templelement_simple_in_div.txt diff --git a/parser/v2/testdata/templelement_simple_no_change.txt b/parser/v2/formattestdata/templelement_simple_no_change.txt similarity index 100% rename from parser/v2/testdata/templelement_simple_no_change.txt rename to parser/v2/formattestdata/templelement_simple_no_change.txt diff --git a/parser/v2/testdata/void_elements_are_converted_to_self_closing_elements.txt b/parser/v2/formattestdata/void_elements_are_converted_to_self_closing_elements.txt similarity index 100% rename from parser/v2/testdata/void_elements_are_converted_to_self_closing_elements.txt rename to parser/v2/formattestdata/void_elements_are_converted_to_self_closing_elements.txt diff --git a/parser/v2/testdata/when_an_element_contains_children_that_are_on_new_lines__the_children_are_indented.txt b/parser/v2/formattestdata/when_an_element_contains_children_that_are_on_new_lines__the_children_are_indented.txt similarity index 100% rename from parser/v2/testdata/when_an_element_contains_children_that_are_on_new_lines__the_children_are_indented.txt rename to parser/v2/formattestdata/when_an_element_contains_children_that_are_on_new_lines__the_children_are_indented.txt