@@ -192,6 +192,7 @@ var allTests = integration.TestFuncs(
192
192
testFrontendDeduplicateSources ,
193
193
testDuplicateLayersProvenance ,
194
194
testSourcePolicyWithNamedContext ,
195
+ testEmptyStringArgInEnv ,
195
196
testInvalidJSONCommands ,
196
197
testHistoryError ,
197
198
testHistoryFinalizeTrace ,
@@ -273,6 +274,50 @@ func TestIntegration(t *testing.T) {
273
274
)... )
274
275
}
275
276
277
+ func testEmptyStringArgInEnv (t * testing.T , sb integration.Sandbox ) {
278
+ integration .SkipOnPlatform (t , "windows" )
279
+ f := getFrontend (t , sb )
280
+
281
+ dockerfile := []byte (`
282
+ FROM busybox AS build
283
+ ARG FOO
284
+ ARG BAR=
285
+ RUN env > env.txt
286
+
287
+ FROM scratch
288
+ COPY --from=build env.txt .
289
+ ` )
290
+ dir := integration .Tmpdir (
291
+ t ,
292
+ fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ),
293
+ )
294
+ c , err := client .New (sb .Context (), sb .Address ())
295
+ require .NoError (t , err )
296
+ defer c .Close ()
297
+
298
+ destDir := t .TempDir ()
299
+ _ , err = f .Solve (sb .Context (), c , client.SolveOpt {
300
+ Exports : []client.ExportEntry {
301
+ {
302
+ Type : client .ExporterLocal ,
303
+ OutputDir : destDir ,
304
+ },
305
+ },
306
+ LocalMounts : map [string ]fsutil.FS {
307
+ dockerui .DefaultLocalNameDockerfile : dir ,
308
+ dockerui .DefaultLocalNameContext : dir ,
309
+ },
310
+ }, nil )
311
+ require .NoError (t , err )
312
+
313
+ dt , err := os .ReadFile (filepath .Join (destDir , "env.txt" ))
314
+ require .NoError (t , err )
315
+
316
+ envStr := string (dt )
317
+ require .Contains (t , envStr , "BAR=" )
318
+ require .NotContains (t , envStr , "FOO=" )
319
+ }
320
+
276
321
func testDefaultEnvWithArgs (t * testing.T , sb integration.Sandbox ) {
277
322
integration .SkipOnPlatform (t , "windows" )
278
323
f := getFrontend (t , sb )
0 commit comments