Skip to content

Commit 312c247

Browse files
authored
Merge pull request moby#50914 from corhere/testutil-footguns
testutil/daemon: fix some footguns for running integration tests interactively
2 parents 9760b1f + d98a8c5 commit 312c247

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

testutil/daemon/daemon.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,11 @@ func NewDaemon(workingDir string, ops ...Option) (*Daemon, error) {
127127

128128
userlandProxy := true
129129
if env := os.Getenv("DOCKER_USERLANDPROXY"); env != "" {
130-
if val, err := strconv.ParseBool(env); err != nil {
131-
userlandProxy = val
130+
val, err := strconv.ParseBool(env)
131+
if err != nil {
132+
return nil, errors.Wrap(err, "failed to parse DOCKER_USERLANDPROXY")
132133
}
134+
userlandProxy = val
133135
}
134136
d := &Daemon{
135137
id: id,
@@ -214,10 +216,9 @@ func New(t testing.TB, ops ...Option) *Daemon {
214216
if dest == "" {
215217
dest = os.Getenv("DEST")
216218
}
219+
assert.Assert(t, dest != "", "Please set the DOCKER_INTEGRATION_DAEMON_DEST or the DEST environment variable")
217220
dest = filepath.Join(dest, t.Name())
218221

219-
assert.Check(t, dest != "", "Please set the DOCKER_INTEGRATION_DAEMON_DEST or the DEST environment variable")
220-
221222
if os.Getenv("DOCKER_ROOTLESS") != "" {
222223
if os.Getenv("DOCKER_REMAP_ROOT") != "" {
223224
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,
410411

411412
// TailLogs tails N lines from the daemon logs
412413
func (d *Daemon) TailLogs(n int) ([][]byte, error) {
414+
if d.logFile == nil {
415+
return nil, errors.New("d.logFile is nil")
416+
}
413417
logF, err := os.Open(d.logFile.Name())
414418
if err != nil {
415419
return nil, errors.Wrap(err, "error opening daemon log file after failed start")

0 commit comments

Comments
 (0)