Skip to content

Commit

Permalink
Quiet test suite output
Browse files Browse the repository at this point in the history
  • Loading branch information
mperham committed Jul 14, 2022
1 parent f9955d6 commit 023b132
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion einhorn.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
gem.metadata = {
"bug_tracker_uri" => "https://github.com/contribsys/einhorn/issues",
"documentation_uri" => "https://github.com/contribsys/einhorn/wiki",
"changelog_uri" => "https://github.com/contribsys/einhorn/blob/main/Changes.md",
"changelog_uri" => "https://github.com/contribsys/einhorn/blob/main/Changes.md"
}

gem.add_development_dependency "rake"
Expand Down
8 changes: 8 additions & 0 deletions test/_lib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ def setup
# Put global stubs here
end
end

def quiet(lvl = 2)
old = Einhorn::State.verbosity
Einhorn::State.verbosity = lvl
yield
ensure
Einhorn::State.verbosity = old
end
20 changes: 15 additions & 5 deletions test/unit/einhorn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,40 @@ class EinhornTest < EinhornTestCase
# preloads the sleep worker since it has einhorn main
Einhorn::State.path = "#{__dir__}/_lib/sleep_worker.rb"
assert_equal(false, Einhorn::State.preloaded)
Einhorn.preload
quiet do
Einhorn.preload
end
assert_equal(true, Einhorn::State.preloaded)
# Attempt another preload
Einhorn.preload
quiet do
Einhorn.preload
end
assert_equal(true, Einhorn::State.preloaded)
end

it "updates preload to failed with previous success" do
Einhorn.stubs(:set_argv).returns
Einhorn::State.path = "#{__dir__}/_lib/sleep_worker.rb"
assert_equal(false, Einhorn::State.preloaded)
Einhorn.preload
quiet do
Einhorn.preload
end
assert_equal(true, Einhorn::State.preloaded)
# Change path to bad worker and preload again, should be false
Einhorn::State.path = "#{__dir__}/_lib/bad_worker.rb"
Einhorn.preload
quiet do
Einhorn.preload
end
assert_equal(false, Einhorn::State.preloaded)
end

it "preload is false after failing" do
Einhorn.stubs(:set_argv).returns
Einhorn::State.path = "#{__dir__}/bad_worker.rb"
assert_equal(false, Einhorn::State.preloaded)
Einhorn.preload
quiet do
Einhorn.preload
end
assert_equal(false, Einhorn::State.preloaded)
end
end
Expand Down

0 comments on commit 023b132

Please sign in to comment.