Skip to content

Commit

Permalink
v1alpha2: fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
nxcc committed Feb 8, 2024
1 parent 7d767ca commit bdd2db9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 3 additions & 3 deletions internal/cuegen/v1alpha2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ type Cuegen struct {
EmptyDir string
}

var cuegenProcess = regexp.MustCompile("(?m)^//cuegen: process$")

func (cg Cuegen) Exec() error {

emptyDir := ""
Expand Down Expand Up @@ -177,9 +179,7 @@ func (cg Cuegen) buildLoadConfig(emptydir string) (*load.Config, error) {

output := string(data)

rx := regexp.MustCompile("(?m)^//cuegen: process$")
if rx.MatchString(output) {
log.Printf("Process: [%v] %v", pack.Name, filename)
if cuegenProcess.MatchString(output) {
p := cuepp.CuePP{
Tempdir: emptydir,
Debug: true,
Expand Down
14 changes: 12 additions & 2 deletions tests/v1alpha2/local/readfile.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ exec sh -c 'sed -i "s:WORK:$WORK:g" main/cuegen.cue'
exec sh -c 'cd main && find && cuegen .'
stdout 'answer_one: "42"'
stdout 'answer_main: "43"'
stdout 'answer_config: "44"'

-- pkg/one/one.cue --
//cuegen: process
package one
import "cuegen.local/config"
answer_one: string @readfile(answer.txt=trim)
answer_config: config.answer_config

-- pkg/one/answer.txt --
42
Expand All @@ -28,16 +32,22 @@ cuegen: {
}

-- main/main.cue --
//cuegen: process
package main
import "example.com/pkg/one"
objects: [
{answer_one: one.answer_one},
{answer_main: string @readfile(answer.txt=trim)}, // OK
{answer_main: string @readfile(answer.txt=trim)},
{answer_config: one.answer_config},
]

-- main/answer.txt --
43

-- main/config/answer.txt --
44

-- main/config/values.cue --
//cuegen: process
package config
answer_config: string @readfile(answer.txt=trim) // OK
answer_config: string @readfile(answer.txt=trim)

0 comments on commit bdd2db9

Please sign in to comment.