Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .dagger/modules/mod-test-e2e/dagger.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
{
"name": "mod-test-e2e",
"engineVersion": "v0.20.8",
"engineVersion": "v1.0.0-beta.10",
"sdk": {
"source": "dang"
},
"dependencies": [
{
"name": "mod-test",
"source": "../../../mod-test"
},
{
"name": "polyfill",
"source": "github.com/dagger/polyfill@main"
}
]
}
12 changes: 6 additions & 6 deletions .dagger/modules/mod-test-e2e/main.dang
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ type ModTestE2e {
mod-test should call a target module through the Dagger CLI and assert JSON strings.
"""
pub jsonStringCheck(ws: Workspace!): Void @check {
let module = polyfill.workspace(ws).moduleSource(echoModulePath)
let target = modTest.target(module.workspaceView, module.sourceRootPath)
let module = ws.moduleSource(echoModulePath)
let target = modTest.target(module.contextDirectory, module.sourceRootSubpath)
target.assertJsonString(["echo", "--value", "hello"], "hello")
}

"""
mod-test should assert JSON string-list output.
"""
pub jsonStringListCheck(ws: Workspace!): Void @check {
let module = polyfill.workspace(ws).moduleSource(echoModulePath)
let target = modTest.target(module.workspaceView, module.sourceRootPath)
let module = ws.moduleSource(echoModulePath)
let target = modTest.target(module.contextDirectory, module.sourceRootSubpath)

target.assertJsonListContains(["values", "--first", "one", "--second", "two"], "two")
target.assertJsonListEmpty(["empty"])
Expand All @@ -28,8 +28,8 @@ type ModTestE2e {
mod-test should assert failing target calls.
"""
pub failureCheck(ws: Workspace!): Void @check {
let module = polyfill.workspace(ws).moduleSource(echoModulePath)
let target = modTest.target(module.workspaceView, module.sourceRootPath)
let module = ws.moduleSource(echoModulePath)
let target = modTest.target(module.contextDirectory, module.sourceRootSubpath)

target.assertFailure(["fail"], "target fail should exit non-zero")
}
Expand Down
6 changes: 1 addition & 5 deletions dagger-module.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
name = "sdk-sdk"
engineVersion = "v1.0.0-0"
engineVersion = "v1.0.0-beta.10"

[runtime]
source = "dang"

[[dependencies]]
name = "polyfill"
source = "github.com/dagger/polyfill@main"

[[dependencies]]
name = "mod-test"
source = "./mod-test"
20 changes: 10 additions & 10 deletions harness.dang
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ type SdkHarness {
}

"""
Return the SDK module under test prepared by the workspace polyfill.
Return the SDK module under test from the native workspace API.
"""
pub sdkTarget(ws: Workspace!): SdkTarget! {
let module = sdkModule(ws)
target(module.workspaceView, module.sourceRootPath)
target(module.contextDirectory, module.sourceRootSubpath)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand that change, it was already using the native API, why this part changes?

@grouville grouville Aug 12, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's surprising 😇

The polyfill usage is hidden in this line: let sdkModule(ws: Workspace!): PolyfillModuleSource!

So workspaceView and sourceRootPath were fields from the polyfill wrapper PolyfillModuleSource.

Now sdkModule returns a native ModuleSource, whose equivalents are contextDirectory and sourceRootSubpath.

No behavior change was intended, just converting the types

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay lgtm then!

}

"""
Expand All @@ -35,35 +35,35 @@ type SdkHarness {
"""
pub contractView(ws: Workspace!): Directory! {
let module = sdkModule(ws)
let view = module.workspaceView
let view = module.contextDirectory

if (module.sourceRootPath == ".") {
if (module.sourceRootSubpath == ".") {
view
} else if (view.exists(module.sourceRootPath + "/dagger.json")) {
view.withFile("dagger.json", view.file(module.sourceRootPath + "/dagger.json"))
} else if (view.exists(module.sourceRootSubpath + "/dagger.json")) {
view.withFile("dagger.json", view.file(module.sourceRootSubpath + "/dagger.json"))
} else {
view.withFile("dagger-module.toml", view.file(module.sourceRootPath + "/dagger-module.toml"))
view.withFile("dagger-module.toml", view.file(module.sourceRootSubpath + "/dagger-module.toml"))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, we're not using the polyfill module is this function so why does it changes? is there a bug in the sdk-sdk module?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

}
}

"""
Return the workspace-relative source root path of the SDK module under test.
"""
pub sourceRootPath(ws: Workspace!): String! {
sdkModule(ws).sourceRootPath
sdkModule(ws).sourceRootSubpath
}

"""
Return the SDK module at the workspace root.
"""
let sdkModule(ws: Workspace!): PolyfillModuleSource! {
let sdkModule(ws: Workspace!): ModuleSource! {
let configs = ws.directory("/", include: ["dagger.json", "dagger-module.toml"])

if (configs.exists("dagger.json") == false and configs.exists("dagger-module.toml") == false) {
raise noSdkModuleMessage
}

polyfill.workspace(ws).moduleSource(".")
ws.moduleSource("/")
}

let noSdkModuleMessage: String! = "no SDK module detected at the workspace root. Run from an SDK module workspace, or pass one with -W <sdk-repo>"
Expand Down
4 changes: 2 additions & 2 deletions mod-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Example:

```dang
pub smoke(ws: Workspace!): Void @check {
let module = polyfill.workspace(ws).moduleSource(".dagger/modules/fixture")
let target = modTest.target(module.workspaceView, module.sourceRootPath)
let module = ws.moduleSource(".dagger/modules/fixture")
let target = modTest.target(module.contextDirectory, module.sourceRootSubpath)

target.assertJsonString(["echo", "--value", "hello"], "hello")
target.assertFailure(["fail"], "fail should return a non-zero status")
Expand Down