Skip to content

Commit

Permalink
test: introduce helpers for skips and for a valgrind block
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Apr 6, 2021
1 parent cb36a56 commit c75ce9b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion test/helper.rb
Expand Up @@ -127,7 +127,7 @@ def teardown

def stress_memory_while(&block)
# force the test to explicitly declare a skip
raise "JRuby doesn't do GC" if Nokogiri.jruby?
raise "memory stress tests shouldn't be run on JRuby" if Nokogiri.jruby?

old_stress = GC.stress
begin
Expand All @@ -138,6 +138,23 @@ def stress_memory_while(&block)
end
end

def skip_unless_libxml2(msg="this test should only run with libxml2")
skip(msg) unless Nokogiri.uses_libxml?
end

def skip_unless_jruby(msg="this test should only run with jruby")
skip(msg) unless Nokogiri.jruby?
end

def refute_valgrind_errors
# force the test to explicitly declare a skip
raise "memory stress tests shouldn't be run on JRuby" if Nokogiri.jruby?

yield.tap do
GC.start(full_mark: true) if GC_LEVEL == "minor"
end
end

def assert_indent(amount, doc, message = nil)
nodes = []
doc.traverse do |node|
Expand Down

0 comments on commit c75ce9b

Please sign in to comment.