Skip to content

Commit

Permalink
only run GC test in Ruby >= 3.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
apotonick committed Oct 8, 2024
1 parent e047d92 commit 981b5da
Showing 1 changed file with 30 additions and 27 deletions.
57 changes: 30 additions & 27 deletions test/activity_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,40 +88,43 @@ def call(*)
end
end

class GCBugTest < Minitest::Spec
it "still finds {.method} tasks after GC compression" do
intermediate = Activity::Schema::Intermediate.new(
{
Activity::Schema::Intermediate::TaskRef(:a) => [Activity::Schema::Intermediate::Out(:success, :b)],
Activity::Schema::Intermediate::TaskRef(:b, stop_event: true) => []
},
{:b => :success},
:a # start
)

module Step
extend T.def_tasks(:create)
end
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.2")
class GCBugTest < Minitest::Spec
it "still finds {.method} tasks after GC compression" do
intermediate = Activity::Schema::Intermediate.new(
{
Activity::Schema::Intermediate::TaskRef(:a) => [Activity::Schema::Intermediate::Out(:success, :b)],
Activity::Schema::Intermediate::TaskRef(:b, stop_event: true) => []
},
{:b => :success},
:a # start
)

module Step
extend T.def_tasks(:create)
end

implementation = {
:a => Schema::Implementation::Task(Step.method(:create), [Activity::Output(Activity::Right, :success)], []),
:b => Schema::Implementation::Task(Trailblazer::Activity::End.new(semantic: :success), [], []),
}
implementation = {
:a => Schema::Implementation::Task(Step.method(:create), [Activity::Output(Activity::Right, :success)], []),
:b => Schema::Implementation::Task(Trailblazer::Activity::End.new(semantic: :success), [], []),
}


activity = Activity.new(Activity::Schema::Intermediate::Compiler.(intermediate, implementation))
activity = Activity.new(Activity::Schema::Intermediate::Compiler.(intermediate, implementation))

assert_invoke activity, seq: %([:create])
assert_invoke activity, seq: %([:create])

# TODO: add tests for different Rubys
GC.verify_compaction_references(expand_heap: true, toward: :empty)
# TODO: add tests for different Rubys
GC.verify_compaction_references(expand_heap: true, toward: :empty)

# Without the fix, this *might* throw the following exception:
#
# NoMethodError: undefined method `[]' for nil
# /home/nick/projects/trailblazer-activity/lib/trailblazer/activity/circuit.rb:80:in `next_for'
# Without the fix, this *might* throw the following exception:
#
# NoMethodError: undefined method `[]' for nil
# /home/nick/projects/trailblazer-activity/lib/trailblazer/activity/circuit.rb:80:in `next_for'

assert_invoke activity, seq: %([:create])
end
assert_invoke activity, seq: %([:create])
end

end
end

0 comments on commit 981b5da

Please sign in to comment.