Skip to content

Commit 32c38be

Browse files
committed
Privatise remaining public test helpers for consistency
1 parent 373f205 commit 32c38be

File tree

2 files changed

+33
-30
lines changed

2 files changed

+33
-30
lines changed

test/test_rack_middleware.rb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@
88
class TestOutputFirefox < Minitest::Test
99
include FirefoxTestHelpers
1010

11-
def build_app(...)
12-
Rack::Lint.new(Vernier::Middleware.new(...))
13-
end
14-
15-
def request(opts = {})
16-
Rack::MockRequest.env_for("", opts)
17-
end
18-
1911
def test_middleware_disabled
2012
app = lambda { |env| [200, { 'content-type' => 'text/plain' }, ["Hello, World!"]] }
2113
response = build_app(app).call(request)
@@ -34,4 +26,14 @@ def test_middleware_enabled
3426
profile_json = Zlib.gunzip(profile_gzip)
3527
assert_valid_firefox_profile(profile_json)
3628
end
29+
30+
private
31+
32+
def build_app(...)
33+
Rack::Lint.new(Vernier::Middleware.new(...))
34+
end
35+
36+
def request(opts = {})
37+
Rack::MockRequest.env_for("", opts)
38+
end
3739
end

test/test_time_collector.rb

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,6 @@
33
require "test_helper"
44

55
class TestTimeCollector < Minitest::Test
6-
SLOW_RUNNER = ENV["GITHUB_ACTIONS"] && ENV["RUNNER_OS"] == "macOS"
7-
DEFAULT_SLEEP_SCALE =
8-
if SLOW_RUNNER
9-
1
10-
else
11-
0.1
12-
end
13-
SLEEP_SCALE = ENV.fetch("TEST_SLEEP_SCALE", DEFAULT_SLEEP_SCALE).to_f # seconds/100ms
14-
SAMPLE_SCALE_INTERVAL = 10_000 * SLEEP_SCALE # Microseconds
15-
SAMPLE_SCALE_ALLOCATIONS = 100
16-
17-
def slow_method
18-
sleep SLEEP_SCALE
19-
end
20-
21-
def two_slow_methods
22-
slow_method
23-
1.times do
24-
slow_method
25-
end
26-
end
27-
286
def test_receives_gc_events
297
collector = Vernier::Collector.new(:wall)
308
collector.start
@@ -286,6 +264,29 @@ def test_includes_options_in_result_meta
286264

287265
private
288266

267+
SLOW_RUNNER = ENV["GITHUB_ACTIONS"] && ENV["RUNNER_OS"] == "macOS"
268+
DEFAULT_SLEEP_SCALE =
269+
if SLOW_RUNNER
270+
1
271+
else
272+
0.1
273+
end
274+
SLEEP_SCALE = ENV.fetch("TEST_SLEEP_SCALE", DEFAULT_SLEEP_SCALE).to_f # seconds/100ms
275+
SAMPLE_SCALE_INTERVAL = 10_000 * SLEEP_SCALE # Microseconds
276+
SAMPLE_SCALE_ALLOCATIONS = 100
277+
private_constant :SLOW_RUNNER, :DEFAULT_SLEEP_SCALE, :SLEEP_SCALE, :SAMPLE_SCALE_INTERVAL, :SAMPLE_SCALE_ALLOCATIONS
278+
279+
def slow_method
280+
sleep SLEEP_SCALE
281+
end
282+
283+
def two_slow_methods
284+
slow_method
285+
1.times do
286+
slow_method
287+
end
288+
end
289+
289290
def assert_similar expected, actual
290291
delta_ratio =
291292
if SLOW_RUNNER

0 commit comments

Comments
 (0)