# Test the allowEmptyGlob option for glob patterns

exec cue export --out cue
cmp stdout out/export

exec cue vet
cmp stdout out/vet

-- cue.mod/module.cue --
module: "cue.example"
language: version: "v0.11.0"

-- test.cue --
@extern(embed)

package foo

// Test allowEmptyGlob with no matching files
emptyGlob: _ @embed(glob="missing/*.json", allowEmptyGlob)

// Test allowEmptyGlob with matching files
nonEmptyGlob: _ @embed(glob="x/*.yaml", allowEmptyGlob)

// Test allowEmptyGlob with different file types
emptyText: _ @embed(glob="missing/*.txt", type=text, allowEmptyGlob)
emptyBinary: _ @embed(glob="missing/*.bin", type=binary, allowEmptyGlob)

-- x/test.yaml --
a: 1
b: 2

-- x/another.yaml --
c: 3
d: 4

-- out/export --
// Test allowEmptyGlob with no matching files
emptyGlob: {}

// Test allowEmptyGlob with matching files
nonEmptyGlob: {
	"x/another.yaml": {
		c: 3
		d: 4
	}
	"x/test.yaml": {
		a: 1
		b: 2
	}
}

// Test allowEmptyGlob with different file types
emptyText: {}
emptyBinary: {}
-- out/vet --
