Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Make the test suite silent
  • Loading branch information
kddnewton committed Nov 9, 2022
commit 8faf11edfd407237c1eb07420bef0bb9a395c121
21 changes: 18 additions & 3 deletions test/ractor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,33 @@ def test_formatting
source = SyntaxTree.read(filepath)
program = SyntaxTree.parse(source)

Ractor.new(source, program, name: filepath) do |source, program|
SyntaxTree::Formatter.format(source, program)
with_silenced_warnings do
Ractor.new(source, program, name: filepath) do |source, program|
SyntaxTree::Formatter.format(source, program)
end
end
end

ractors.each(&:take)
ractors.each { |ractor| assert_kind_of String, ractor.take }
end

private

def filepaths
Dir.glob(File.expand_path("../lib/syntax_tree/{node,parser}.rb", __dir__))
end

# Ractors still warn about usage, so I'm disabling that warning here just to
# have clean test output.
def with_silenced_warnings
previous = $VERBOSE

begin
$VERBOSE = nil
yield
ensure
$VERBOSE = previous
end
end
end
end
7 changes: 3 additions & 4 deletions test/rake_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,11 @@ def invoke(task_name)
invocation = nil
stub = ->(args) { invocation = Invocation.new(args) }

begin
assert_raises SystemExit do
SyntaxTree::CLI.stub(:run, stub) { ::Rake::Task[task_name].invoke }
flunk
rescue SystemExit
invocation
end

invocation
end
end
end
Expand Down