Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions formatter/formatter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package formatter
import (
"flag"
"fmt"
"github.com/google/go-jsonnet/internal/testutils"
"io"
"io/ioutil"
"path/filepath"
"regexp"
"strings"
"testing"

"github.com/google/go-jsonnet/internal/testutils"
)

var update = flag.Bool("update", false, "update .golden files")
Expand Down Expand Up @@ -42,7 +43,7 @@ func runTest(t *testing.T, test *formatterTest, changedGoldensList *ChangedGolde

input := read(test.input)
var outBuilder strings.Builder
output, err := Format(test.name, string(input), Options{})
output, err := Format(test.name, string(input), DefaultOptions())
if err != nil {
errWriter := ErrorWriter{
Writer: &outBuilder,
Expand Down
2 changes: 2 additions & 0 deletions formatter/testdata/empty_comment.fmt.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//
{}
2 changes: 2 additions & 0 deletions formatter/testdata/empty_comment.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#
{}
2 changes: 1 addition & 1 deletion internal/formatter/enforce_comment_style.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (c *EnforceCommentStyle) FodderElement(p pass.ASTPass, element *ast.FodderE
*comment = "#" + (*comment)[2:]
}
if c.Options.CommentStyle == CommentStyleSlash && (*comment)[0] == '#' {
if !c.seenFirstFodder && (*comment)[1] == '!' {
if !c.seenFirstFodder && len(*comment) > 1 && (*comment)[1] == '!' {
return
}
*comment = "//" + (*comment)[1:]
Expand Down