Skip to content

go: hand tests their new session through the environment - #80

Merged
sipsma merged 1 commit into
mainfrom
sipsma/test-session-env
Oct 27, 2026
Merged

sipsma merged 1 commit into
mainfrom
sipsma/test-session-env

Conversation

@sipsma

@sipsma sipsma commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Problem

Since #75 (which gives tests a session of their own so that a module address resolves against the user's workspace), every test of a Dagger Go module fails on load:

panic: DAGGER_SESSION_PORT is not set
dagger/gobuild/internal/dagger/core.getClientParams()

A new-session exec leaves DAGGER_SESSION_PORT and DAGGER_SESSION_TOKEN unset, and the code the Go SDK generates for a Dagger module reads them in init. gobuild is such a module, so single-module-check and skips-non-modules-check fail on main and on every PR. #75's own CI ran before gobuild had tests.

single-module-check shows green on main only because Go's test cache, kept in a cache volume that persists between runs, replayed an earlier pass (ok dagger/gobuild (cached)). Go doesn't treat environment variables read during package init as test inputs.

Fix

Run the tests under the engine-mounted CLI's dagger api with-session. Tests still get a new session of their own, but it now comes through the two variables every SDK client connects through. _EXPERIMENTAL_DAGGER_CLI_BIN is no longer needed. The nesting fixture reads its session from the environment again.

Known limit

A Go test that runs the dagger CLI as a subprocess can't join that session yet: the CLI refuses with "connecting a Dagger CLI to the session served by dagger run is not supported yet". Tests that use an SDK client are unaffected. Letting a CLI join will be a separate change in dagger/dagger.

Verification

On a Dagger Cloud engine (v1.0.0-beta.20):

  • single-module-check and skips-non-modules-check pass, with gobuild's tests actually run, not replayed from cache.
  • The full dagger check passes.
  • In a separate project, a Dagger Go module's own unit test panics on main and passes with this change. A Go test calling a module through a generated client, fix: let tests use generated module clients #75's case, passes both before and after.

@grouville
grouville self-requested a review October 27, 2026 06:20
Tests have run in a session of their own since #75, so that a module
address resolves against the user's workspace. But a new session leaves
DAGGER_SESSION_PORT and DAGGER_SESSION_TOKEN unset, and a Dagger Go
module's own package panics on load without them. Every test of a Dagger
Go module failed, gobuild's among them.

Run the tests under the engine-mounted CLI's api with-session instead. It
opens the same kind of new session and hands it to the tests through
those two variables, which every SDK's client connects through.

Signed-off-by: Erik Sipsma <[email protected]>
@sipsma
sipsma force-pushed the sipsma/test-session-env branch from ba12d4d to 0289177 Compare October 27, 2026 06:26
@sipsma
sipsma merged commit 0a718a4 into main Oct 27, 2026
64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants