@@ -461,47 +461,45 @@ RUN busybox | head -1 | grep v1.36.1
461
461
462
462
func testBuildDetailsLink (t * testing.T , sb integration.Sandbox ) {
463
463
skipNoCompatBuildKit (t , sb , ">= 0.11.0-0" , "build details link" )
464
+ home := t .TempDir ()
464
465
buildDetailsPattern := regexp .MustCompile (`(?m)^View build details: docker-desktop://dashboard/build/[^/]+/[^/]+/[^/]+\n$` )
465
466
466
467
// build simple dockerfile
467
468
dockerfile := []byte (`FROM busybox:latest
468
469
RUN echo foo > /bar` )
469
470
dir := tmpdir (t , fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ))
470
- cmd := buildxCmd (sb , withArgs ("build" , "--output=type=cacheonly" , dir ))
471
+ cmd := buildxCmd (sb ,
472
+ withArgs ("build" , "--output=type=cacheonly" , dir ),
473
+ withEnv (fmt .Sprintf ("HOME=%s" , home )),
474
+ )
471
475
out , err := cmd .CombinedOutput ()
472
476
require .NoError (t , err , string (out ))
473
477
require .False (t , buildDetailsPattern .MatchString (string (out )), fmt .Sprintf ("build details link not expected in output, got %q" , out ))
474
478
475
479
// create desktop-build .lastaccess file
476
- home , err := os .UserHomeDir () // TODO: sandbox should create a temp home dir and expose it through its interface
477
- require .NoError (t , err )
478
480
dbDir := path .Join (home , ".docker" , "desktop-build" )
479
481
require .NoError (t , os .MkdirAll (dbDir , 0755 ))
480
- dblaFile , err := os .Create (path .Join (dbDir , ".lastaccess" ))
482
+ dblaLastaccess , err := os .Create (path .Join (dbDir , ".lastaccess" ))
481
483
require .NoError (t , err )
482
- defer func () {
483
- dblaFile .Close ()
484
- if err := os .Remove (dblaFile .Name ()); err != nil {
485
- t .Fatal (err )
486
- }
487
- }()
484
+ require .NoError (t , dblaLastaccess .Close ())
488
485
489
486
// build again
490
- cmd = buildxCmd (sb , withArgs ("build" , "--output=type=cacheonly" , dir ))
487
+ cmd = buildxCmd (sb ,
488
+ withArgs ("build" , "--output=type=cacheonly" , dir ),
489
+ withEnv (fmt .Sprintf ("HOME=%s" , home )),
490
+ )
491
491
out , err = cmd .CombinedOutput ()
492
492
require .NoError (t , err , string (out ))
493
493
require .True (t , buildDetailsPattern .MatchString (string (out )), fmt .Sprintf ("expected build details link in output, got %q" , out ))
494
494
495
- if isExperimental () {
496
- // FIXME: https://github.com/docker/buildx/issues/2382
497
- t .Skip ("build details link not displayed in experimental mode when build fails: https://github.com/docker/buildx/issues/2382" )
498
- }
499
-
500
495
// build erroneous dockerfile
501
496
dockerfile = []byte (`FROM busybox:latest
502
497
RUN exit 1` )
503
498
dir = tmpdir (t , fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ))
504
- cmd = buildxCmd (sb , withArgs ("build" , "--output=type=cacheonly" , dir ))
499
+ cmd = buildxCmd (sb ,
500
+ withArgs ("build" , "--output=type=cacheonly" , dir ),
501
+ withEnv (fmt .Sprintf ("HOME=%s" , home )),
502
+ )
505
503
out , err = cmd .CombinedOutput ()
506
504
require .Error (t , err , string (out ))
507
505
require .True (t , buildDetailsPattern .MatchString (string (out )), fmt .Sprintf ("expected build details link in output, got %q" , out ))
0 commit comments