Repository navigation
fix: let tests use generated module clients - #75
Merged
Merged
Conversation
The runner already synthesizes the .git marker a nested client needs to find its workspace, but the tests joined the session running them, so a generated module client resolved its module address against this module rather than against the user's workspace and failed with 'does not contain a dagger config file'. In Go that is fatal rather than partial: Connect() serves the bound module eagerly and the generated dag package panics when it fails, so even a test that only calls dag.Container() dies. Give the test execs a session of their own, and point older clients at the CLI the engine mounts for exactly this case. Signed-off-by: Tom Chauveau <[email protected]>
The source mount is filtered to Go files, so a Dagger module inside the workspace arrives with its .go files but without dagger-module.toml, and serving it fails with 'does not contain a dagger config file' -- the directory is there, the config is not. Signed-off-by: Tom Chauveau <[email protected]>
The nesting fixture asserted DAGGER_SESSION_PORT and DAGGER_SESSION_TOKEN, which is exactly what giving the tests their own session removes. Open one with the CLI the engine mounts, the way an SDK does, and run the same query through it. The session lasts as long as its stdin, so the pipe stays open for the test. Its workspace assertion moves with the behaviour too: a test now sees the workspace its container carries, which holds what the runner mounted rather than every file of the repository, so it looks for a Go module instead of the repository's LICENSE. Signed-off-by: Tom Chauveau <[email protected]>
kpenfound
approved these changes
Oct 23, 2026
This was referenced Oct 26, 2026
sipsma
added a commit
that referenced
this pull request
Oct 27, 2026
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A test run by this module cannot use a generated Dagger module client, and in
Go the failure is total rather than partial:
Connect()serves the bound module eagerly and the generateddagpackage panicswhen that fails, so every test that touches
dagdies — including one that onlycalls
dag.Container()and never uses a module function. The equivalent TypeScriptand Python clients return an error and leave the core API usable.
Two causes, in order.
1. The tests join the session running them. A module address then resolves
against this module rather than against the user's workspace — the error says
from module "go". The runner already synthesizes the.gitmarker a nestedclient needs to find its workspace root, so that half was done; the session was
the missing piece.
2. The source mount is Go-only. With its own session the error changes to
workspace module source "…/.dagger/modules/fixtures" does not contain a dagger config file— the directory is there, with its.gofiles, butdagger-module.tomlis not a Go file and so is not insource(ws, test: true).The module is visible and unservable.
Fix
testExecandrunTestsrun withdaggerInDaggerNewSession: true, and set_EXPERIMENTAL_DAGGER_CLI_BIN=/dev/.dagger/dagger: with its own session a clientprovisions through a CLI, and the engine already mounts a version-matched one on
PATHfor exactly this case. Newer SDKs find it themselves; older ones only readthat variable.
testEnvalso mounts**/dagger-module.tomland**/dagger.json, so a moduleinside the workspace arrives complete.
Only the test execs change;
go generateand the build paths keep the sharedsession.
Verification
A workspace with a module, a generated client for it, and a
go testsuite thatcalls the core API, a module function, and a module
Servicebound into acontainer the test builds:
Confirmed on an uncached run (source touched to defeat the cache), not a replayed
result.
Known limit
Only what the Go filter selects, plus the module configs, is mounted — a test that
reads the workspace still sees a partial tree.
includeExtraFileswidens it.