Skip to content

Commit

Permalink
translate: keep _test.go suffix when mangling
Browse files Browse the repository at this point in the history
It has meaning that should be maintained.
  • Loading branch information
jellevandenhooff committed Nov 24, 2024
1 parent aad0d76 commit f654b83
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions internal/translate/testdata/constraints.translate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ package basicgosim

func Hello() {
}
-- hello_linux_test.go --
-- translated/constraints/hello_linux__test.go --
// Code generated by gosim. DO NOT EDIT.
package basicgosim_test

func Hello() {
}
-- translated/constraints/hello_linux_test_.go --
// Code generated by gosim. DO NOT EDIT.
-- hello_linux_test.go --
package basicgosim_test

func Hello() {
Expand Down
3 changes: 3 additions & 0 deletions internal/translate/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ func renameFile(cfg gosimtool.BuildConfig, filePath string) string {

// for now, after translate all files should be included in the build
// modify the filename minimally to neuter any excluded files
if strings.HasSuffix(withoutDot, "_test") {
return strings.TrimSuffix(withoutDot, "_test") + "__test" + ext
}
return withoutDot + "_" + ext
}

Expand Down
4 changes: 2 additions & 2 deletions internal/translate/translate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,15 @@ func TestRenameFile(t *testing.T) {
},
{
in: "foo/bar_linux_test.go",
out: "foo/bar_linux_test_.go",
out: "foo/bar_linux__test.go",
},
{
in: "foo/bar_linux_amd64.go",
out: "foo/bar_linux_amd64_.go",
},
{
in: "foo/bar_linux_amd64_test.go",
out: "foo/bar_linux_amd64_test_.go",
out: "foo/bar_linux_amd64__test.go",
},
{
in: "foo/bar_amd64.go",
Expand Down

0 comments on commit f654b83

Please sign in to comment.