Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def auto_time_skipping_disabled(&)
raise 'Block required' unless block_given?
return super unless supports_time_skipping?

already_disabled = @auto_time_skipping
already_disabled = !@auto_time_skipping
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@auto_time_skipping = false
begin
yield
Expand Down
28 changes: 28 additions & 0 deletions temporalio/test/testing/workflow_environment_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,34 @@ def test_time_skipping_auto
end
end

def test_auto_time_skipping_disabled
skip_if_not_x86!
Copy link
Copy Markdown
Contributor Author

@igillis-clara igillis-clara May 2, 2025

Choose a reason for hiding this comment

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

I don't know if this line is required -- seemed to run fine on my apple silicon Mac 🤷 but left it for consistency

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks! Yeah it runs in macos due to rosetta x64 translator, but technically we don't support time-skipping on ARM (though it was added recently, we just have to update the auto downloader).

Temporalio::Testing::WorkflowEnvironment.start_time_skipping(logger: Logger.new($stdout)) do |env|
worker = Temporalio::Worker.new(
client: env.client,
task_queue: "tq-#{SecureRandom.uuid}",
workflows: [SlowWorkflow]
)
worker.run do
# Check that timestamp is around now
assert_in_delta(Time.now, env.current_time, 30.0)

# Run workflow
handle = env.client.start_workflow(
SlowWorkflow,
id: "wf-#{SecureRandom.uuid}",
task_queue: worker.task_queue
)
env.auto_time_skipping_disabled do
handle.signal(SlowWorkflow.some_signal)
end
# Check that timestamp is now about two days from now
assert_equal 'all done', handle.result
assert_in_delta Time.now + SlowWorkflow::TWO_DAYS, env.current_time, 30.0
end
end
end

def test_time_skipping_manual
skip_if_not_x86!
Temporalio::Testing::WorkflowEnvironment.start_time_skipping(logger: Logger.new($stdout)) do |env|
Expand Down
Loading