Merge pull request #50914 from corhere/testutil-footguns

testutil/daemon: fix some footguns for running integration tests interactively
This commit is contained in:
Sebastiaan van Stijn
2025-09-06 02:03:43 +02:00
committed by GitHub

View File

@@ -127,9 +127,11 @@ func NewDaemon(workingDir string, ops ...Option) (*Daemon, error) {
userlandProxy := true
if env := os.Getenv("DOCKER_USERLANDPROXY"); env != "" {
if val, err := strconv.ParseBool(env); err != nil {
userlandProxy = val
val, err := strconv.ParseBool(env)
if err != nil {
return nil, errors.Wrap(err, "failed to parse DOCKER_USERLANDPROXY")
}
userlandProxy = val
}
d := &Daemon{
id: id,
@@ -214,10 +216,9 @@ func New(t testing.TB, ops ...Option) *Daemon {
if dest == "" {
dest = os.Getenv("DEST")
}
assert.Assert(t, dest != "", "Please set the DOCKER_INTEGRATION_DAEMON_DEST or the DEST environment variable")
dest = filepath.Join(dest, t.Name())
assert.Check(t, dest != "", "Please set the DOCKER_INTEGRATION_DAEMON_DEST or the DEST environment variable")
if os.Getenv("DOCKER_ROOTLESS") != "" {
if os.Getenv("DOCKER_REMAP_ROOT") != "" {
t.Skip("DOCKER_ROOTLESS doesn't support DOCKER_REMAP_ROOT currently")
@@ -410,6 +411,9 @@ func (d *Daemon) ScanLogs(ctx context.Context, match func(s string) bool) (bool,
// TailLogs tails N lines from the daemon logs
func (d *Daemon) TailLogs(n int) ([][]byte, error) {
if d.logFile == nil {
return nil, errors.New("d.logFile is nil")
}
logF, err := os.Open(d.logFile.Name())
if err != nil {
return nil, errors.Wrap(err, "error opening daemon log file after failed start")