@@ -31,7 +31,8 @@ func bakeCmd(sb integration.Sandbox, opts ...cmdOpt) (string, error) {
3131}
3232
3333var bakeTests = []func (t * testing.T , sb integration.Sandbox ){
34- testBakePrint ,
34+ testBakePrintHCL ,
35+ testBakePrintCompose ,
3536 testBakeLocal ,
3637 testBakeLocalMulti ,
3738 testBakeRemote ,
@@ -62,7 +63,7 @@ var bakeTests = []func(t *testing.T, sb integration.Sandbox){
6263 testBakeCheckCallOutput ,
6364}
6465
65- func testBakePrint (t * testing.T , sb integration.Sandbox ) {
66+ func testBakePrintHCL (t * testing.T , sb integration.Sandbox ) {
6667 dockerfile := []byte (`
6768FROM busybox
6869ARG HELLO
@@ -125,6 +126,70 @@ target "build" {
125126` , stdout .String ())
126127}
127128
129+ func testBakePrintCompose (t * testing.T , sb integration.Sandbox ) {
130+ dockerfile := []byte (`
131+ FROM busybox
132+ ARG HELLO
133+ RUN echo "Hello ${HELLO}"
134+ ` )
135+ composefile := []byte (`
136+ services:
137+ build:
138+ build:
139+ context: .
140+ args:
141+ HELLO: foo
142+ ` )
143+ dir := tmpdir (
144+ t ,
145+ fstest .CreateFile ("compose.yml" , composefile , 0600 ),
146+ fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ),
147+ )
148+
149+ cmd := buildxCmd (sb , withDir (dir ), withArgs ("bake" , "--print" , "build" ))
150+ stdout := bytes.Buffer {}
151+ stderr := bytes.Buffer {}
152+ cmd .Stdout = & stdout
153+ cmd .Stderr = & stderr
154+ require .NoError (t , cmd .Run (), stdout .String (), stderr .String ())
155+
156+ var def struct {
157+ Group map [string ]* bake.Group `json:"group,omitempty"`
158+ Target map [string ]* bake.Target `json:"target"`
159+ }
160+ require .NoError (t , json .Unmarshal (stdout .Bytes (), & def ))
161+
162+ require .Len (t , def .Group , 1 )
163+ require .Contains (t , def .Group , "default" )
164+
165+ require .Equal (t , []string {"build" }, def .Group ["default" ].Targets )
166+ require .Len (t , def .Target , 1 )
167+ require .Contains (t , def .Target , "build" )
168+ require .Equal (t , "." , * def .Target ["build" ].Context )
169+ require .Equal (t , "Dockerfile" , * def .Target ["build" ].Dockerfile )
170+ require .Equal (t , map [string ]* string {"HELLO" : ptrstr ("foo" )}, def .Target ["build" ].Args )
171+
172+ require .Equal (t , `{
173+ "group": {
174+ "default": {
175+ "targets": [
176+ "build"
177+ ]
178+ }
179+ },
180+ "target": {
181+ "build": {
182+ "context": ".",
183+ "dockerfile": "Dockerfile",
184+ "args": {
185+ "HELLO": "foo"
186+ }
187+ }
188+ }
189+ }
190+ ` , stdout .String ())
191+ }
192+
128193func testBakeLocal (t * testing.T , sb integration.Sandbox ) {
129194 dockerfile := []byte (`
130195FROM scratch
0 commit comments