Skip to content

Commit d0acb14

Browse files
authored
Merge pull request #461 from JuliaParallel/jps/options-fix-prev
tests: Test for previous option preservation
2 parents 8f86256 + 4cba2f6 commit d0acb14

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Diff for: src/options.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ scope. Note that setting an option here will propagate its value across Julia
1313
or Dagger tasks spawned by `f()` or its callees (i.e. the options propagate).
1414
"""
1515
function with_options(f, options::NamedTuple)
16-
with(options_context => options) do
16+
prev_options = options_context[]
17+
with(options_context => merge(prev_options, options)) do
1718
f()
1819
end
1920
end

Diff for: test/options.jl

+10
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ end
5050
end
5151
end
5252

53+
# Test previous option preservation
54+
Dagger.with_options(scope=Dagger.scope(worker=last_wid)) do
55+
Dagger.with_options(meta=true) do
56+
@test haskey(Dagger.get_options(), :meta)
57+
@test Dagger.get_options(:meta) == true
58+
@test haskey(Dagger.get_options(), :scope)
59+
@test Dagger.get_options(:scope) == Dagger.scope(worker=last_wid)
60+
end
61+
end
62+
5363
# Test scope/single is applied
5464
for wid in workers()
5565
for (option, value) in [

0 commit comments

Comments
 (0)