Skip to content

Commit

Permalink
internal/filetypes: File.Default is indeed not unused
Browse files Browse the repository at this point in the history
We just didn't have test cases for it in this package.
Removing the unification broke plenty of cmd/cue tests.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I1905ca3e32e1bc1a82c85d46ef6560775c9be36d
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1193533
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>
  • Loading branch information
mvdan committed Apr 22, 2024
1 parent 6169eed commit 7b2f27e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 0 additions & 1 deletion internal/filetypes/filetypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ func toFile(modeVal, fileVal cue.Value, filename string) (*build.File, error) {
if concrete, hasDefault := hasEncoding(fileVal); !concrete {
if filename == "-" {
if !hasDefault {
// TODO(mvdan): unused?
fileVal = fileVal.Unify(modeVal.LookupPath(cue.MakePath(cue.Str("Default"))))
}
} else if ext := fileExt(filename); ext != "" {
Expand Down
14 changes: 14 additions & 0 deletions internal/filetypes/filetypes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,20 @@ func TestParseFile(t *testing.T) {
}, {
in: "file.bar",
out: `unknown file extension .bar`,
}, {
in: "-",
mode: Input,
out: &build.File{
Filename: "-",
Encoding: "cue",
},
}, {
in: "-",
mode: Export,
out: &build.File{
Filename: "-",
Encoding: "json",
},
}}
for _, tc := range testCases {
t.Run(tc.in, func(t *testing.T) {
Expand Down

0 comments on commit 7b2f27e

Please sign in to comment.