Skip to content

Commit 459c023

Browse files
Merge pull request #11 from speee/fix-ruby34-hang-cleanup
Fix Ruby 3.4 CI hang by adding test cleanup
2 parents 60abd55 + b26ef1b commit 459c023

4 files changed

Lines changed: 44 additions & 10 deletions

File tree

test/error_test.rb

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44
class ErrorTest < Minitest::Test
55
FIXTURES_DIR = File.join(__dir__, 'fixtures')
66

7+
def setup
8+
@schmoozer = nil
9+
end
10+
11+
def teardown
12+
if @schmoozer&.pid
13+
@schmoozer.close rescue nil
14+
end
15+
end
16+
717
class ErrorSchmoozer < Schmooze::Base
818
dependencies nonexistant: 'this-package-is-not-here'
919
method :bogus, 'bogus'
@@ -54,8 +64,9 @@ def test_import_error_but_in_package_json
5464

5565
def test_javascript_error
5666
dir = File.join(FIXTURES_DIR, 'coffee')
67+
@schmoozer = CoffeeSchmoozer.new(dir)
5768
error = assert_raises Schmooze::JavaScript::SyntaxError do
58-
CoffeeSchmoozer.new(dir).compile('<=> 1')
69+
@schmoozer.compile('<=> 1')
5970
end
6071

6172
assert_equal <<-ERROR.strip, error.message
@@ -67,27 +78,28 @@ def test_javascript_error
6778

6879
def test_late_arriving_dependency
6980
dir = File.join(FIXTURES_DIR, 'late-dep')
70-
late = LateArrivingDependency.new(dir, {"NODE_PATH" => dir})
81+
@schmoozer = LateArrivingDependency.new(dir, {"NODE_PATH" => dir})
7182

7283
assert_raises Schmooze::DependencyError do
73-
late.test
84+
@schmoozer.test
7485
end
7586

7687
assert_raises Schmooze::DependencyError do
77-
late.test
88+
@schmoozer.test
7889
end
7990

8091
File.write(File.join(dir, 'empty.js'), 'module.exports = null;')
8192

82-
assert_equal late.test, 1
93+
assert_equal @schmoozer.test, 1
8394
ensure
8495
FileUtils.rm(File.join(dir, 'empty.js'), force: true)
8596
end
8697

8798
def test_unknown_error
8899
dir = File.join(FIXTURES_DIR, 'coffee')
100+
@schmoozer = UnknownErrorSchmoozer.new(dir)
89101
error = assert_raises Schmooze::JavaScript::UnknownError do
90-
UnknownErrorSchmoozer.new(dir).throw_string
102+
@schmoozer.throw_string
91103
end
92104
assert_equal '¯\_(ツ)_/¯', error.message
93105
end

test/garbage_test.rb

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,21 @@ class GarbageSchmoozer < Schmooze::Base
55
method :test, 'function(){ return 1; }'
66
end
77

8+
def setup
9+
@schmoozer = nil
10+
end
11+
12+
def teardown
13+
if @schmoozer&.pid
14+
@schmoozer.close rescue nil
15+
end
16+
end
17+
818
def test_process_is_not_started_until_used
9-
garbage = GarbageSchmoozer.new(__dir__)
10-
assert_nil garbage.pid
11-
garbage.test
12-
assert garbage.pid
19+
@schmoozer = GarbageSchmoozer.new(__dir__)
20+
assert_nil @schmoozer.pid
21+
@schmoozer.test
22+
assert @schmoozer.pid
1323
end
1424

1525
def test_process_is_closed

test/local_script_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ def setup
1111
@schmoozer = LocalScriptSchmoozer.new(File.join(__dir__, 'fixtures', 'local_script'))
1212
end
1313

14+
def teardown
15+
if @schmoozer&.pid
16+
@schmoozer.close rescue nil
17+
end
18+
end
19+
1420
def test_usage
1521
assert_equal 456, @schmoozer.test
1622
end

test/schmooze_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ def setup
2727
@schmoozer = CoffeeSchmoozer.new(File.join(__dir__, 'fixtures', 'coffee'))
2828
end
2929

30+
def teardown
31+
if @schmoozer&.pid
32+
@schmoozer.close rescue nil
33+
end
34+
end
35+
3036
def test_that_it_has_a_version_number
3137
refute_nil ::Schmooze::VERSION
3238
end

0 commit comments

Comments
 (0)