@@ -6882,6 +6882,7 @@ func testReproSourceDateEpoch(t *testing.T, sb integration.Sandbox) {
6882
6882
dockerfile string
6883
6883
files []fstest.Applier
6884
6884
expectedDigest string
6885
+ noCacheExport bool
6885
6886
}
6886
6887
testCases := []testCase {
6887
6888
{
@@ -6909,6 +6910,14 @@ COPY --link foo foo
6909
6910
files : []fstest.Applier {fstest .CreateFile ("foo" , []byte ("foo" ), 0600 )},
6910
6911
expectedDigest : "sha256:9f75e4bdbf3d825acb36bb603ddef4a25742afb8ccb674763ffc611ae047d8a6" ,
6911
6912
},
6913
+ {
6914
+ // https://github.com/moby/buildkit/issues/4793
6915
+ name : "NoAdditionalLayer" ,
6916
+ dockerfile : `FROM amd64/debian:bullseye-20230109-slim
6917
+ ` ,
6918
+ expectedDigest : "sha256:eeba8ef81dec46359d099c5d674009da54e088fa8f29945d4d7fb3a7a88c450e" ,
6919
+ noCacheExport : true , // "skipping cache export for empty result"
6920
+ },
6912
6921
}
6913
6922
6914
6923
// https://explore.ggcr.dev/?image=amd64%2Fdebian%3Abullseye-20230109-slim
@@ -6968,7 +6977,10 @@ COPY --link foo foo
6968
6977
require .NoError (t , err )
6969
6978
6970
6979
desc , manifest , img := readImage (t , ctx , target )
6971
- _ , cacheManifest , _ := readImage (t , ctx , target + "-cache" )
6980
+ var cacheManifest ocispecs.Manifest
6981
+ if ! tc .noCacheExport {
6982
+ _ , cacheManifest , _ = readImage (t , ctx , target + "-cache" )
6983
+ }
6972
6984
t .Log ("The digest may change depending on the BuildKit version, the snapshotter configuration, etc." )
6973
6985
require .Equal (t , tc .expectedDigest , desc .Digest .String ())
6974
6986
@@ -6986,9 +6998,11 @@ COPY --link foo foo
6986
6998
require .Equal (t , fmt .Sprintf ("%d" , tm .Unix ()), l .Annotations ["buildkit/rewritten-timestamp" ])
6987
6999
}
6988
7000
}
6989
- // Cache layers must *not* have rewritten-timestamp
6990
- for _ , l := range cacheManifest .Layers {
6991
- require .Empty (t , l .Annotations ["buildkit/rewritten-timestamp" ])
7001
+ if ! tc .noCacheExport {
7002
+ // Cache layers must *not* have rewritten-timestamp
7003
+ for _ , l := range cacheManifest .Layers {
7004
+ require .Empty (t , l .Annotations ["buildkit/rewritten-timestamp" ])
7005
+ }
6992
7006
}
6993
7007
6994
7008
// Build again, after pruning the base image layer cache.
0 commit comments