From 2dc7dd7f9bc4bb963f74d77faf35179291bf036d Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Tue, 6 Apr 2021 11:47:39 -0400 Subject: [PATCH] test: introduce helpers for skips and for a valgrind block --- test/helper.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/helper.rb b/test/helper.rb index 4be9f82ac9..a8595b1d8c 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -138,6 +138,21 @@ 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 + skip_unless_libxml2("valgrind tests should only run with libxml2") + 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|