mirror of
				https://gitea.com/Lydanne/buildx.git
				synced 2025-11-04 10:03:42 +08:00 
			
		
		
		
	test: tmpdir can be a test helper
Signed-off-by: Justin Chadwell <me@jedevc.com>
This commit is contained in:
		@@ -148,11 +148,10 @@ RUN cp /etc/foo /etc/bar
 | 
				
			|||||||
FROM scratch
 | 
					FROM scratch
 | 
				
			||||||
COPY --from=base /etc/bar /bar
 | 
					COPY --from=base /etc/bar /bar
 | 
				
			||||||
`)
 | 
					`)
 | 
				
			||||||
	dir, err := tmpdir(
 | 
						dir := tmpdir(
 | 
				
			||||||
		t,
 | 
							t,
 | 
				
			||||||
		fstest.CreateFile("Dockerfile", dockerfile, 0600),
 | 
							fstest.CreateFile("Dockerfile", dockerfile, 0600),
 | 
				
			||||||
		fstest.CreateFile("foo", []byte("foo"), 0600),
 | 
							fstest.CreateFile("foo", []byte("foo"), 0600),
 | 
				
			||||||
	)
 | 
						)
 | 
				
			||||||
	require.NoError(t, err)
 | 
					 | 
				
			||||||
	return dir
 | 
						return dir
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,14 +7,15 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	"github.com/containerd/continuity/fs/fstest"
 | 
						"github.com/containerd/continuity/fs/fstest"
 | 
				
			||||||
	"github.com/moby/buildkit/util/testutil/integration"
 | 
						"github.com/moby/buildkit/util/testutil/integration"
 | 
				
			||||||
 | 
						"github.com/stretchr/testify/require"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func tmpdir(t *testing.T, appliers ...fstest.Applier) (string, error) {
 | 
					func tmpdir(t *testing.T, appliers ...fstest.Applier) string {
 | 
				
			||||||
 | 
						t.Helper()
 | 
				
			||||||
	tmpdir := t.TempDir()
 | 
						tmpdir := t.TempDir()
 | 
				
			||||||
	if err := fstest.Apply(appliers...).Apply(tmpdir); err != nil {
 | 
						err := fstest.Apply(appliers...).Apply(tmpdir)
 | 
				
			||||||
		return "", err
 | 
						require.NoError(t, err)
 | 
				
			||||||
	}
 | 
						return tmpdir
 | 
				
			||||||
	return tmpdir, nil
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func buildxCmd(sb integration.Sandbox, args ...string) *exec.Cmd {
 | 
					func buildxCmd(sb integration.Sandbox, args ...string) *exec.Cmd {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user