about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--test/test_config.rb72
1 files changed, 39 insertions, 33 deletions
diff --git a/test/test_config.rb b/test/test_config.rb
index 2afcecb..2f87136 100644
--- a/test/test_config.rb
+++ b/test/test_config.rb
@@ -12,45 +12,51 @@ class TestConfig < Testcase
   end
 
   def test_multi_conf_example
-    tmpdir = Dir.mktmpdir
+    pid = fork do
+      tmpdir = Dir.mktmpdir
 
-    # modify the example config file for testing
-    path = "examples/yahns_multi.conf.rb"
-    cfgs = File.read(path)
-    cfgs.gsub!(%r{/path/to/}, "#{tmpdir}/")
-    conf = File.open("#{tmpdir}/yahns_multi.conf.rb", "w")
-    conf.sync = true
-    conf.write(cfgs)
-    File.open("#{tmpdir}/another.ru", "w") do |fp|
-      fp.puts("run Rack::Lobster.new\n")
-    end
-    FileUtils.mkpath("#{tmpdir}/another")
+      # modify the example config file for testing
+      path = "examples/yahns_multi.conf.rb"
+      cfgs = File.read(path)
+      cfgs.gsub!(%r{/path/to/}, "#{tmpdir}/")
+      conf = File.open("#{tmpdir}/yahns_multi.conf.rb", "w")
+      conf.sync = true
+      conf.write(cfgs)
+      File.open("#{tmpdir}/another.ru", "w") do |fp|
+        fp.puts("run Rack::Lobster.new\n")
+      end
+      FileUtils.mkpath("#{tmpdir}/another")
 
-    cfg = GTL.synchronize { Yahns::Config.new(conf.path) }
-    assert_instance_of Yahns::Config, cfg
-  ensure
-    FileUtils.rm_rf(tmpdir) if tmpdir
+      cfg = Yahns::Config.new(conf.path)
+      FileUtils.rm_rf(tmpdir)
+      exit!(Yahns::Config === cfg)
+    end
+    _, status = Process.waitpid2(pid)
+    assert status.success?
   end
 
   def test_rack_basic_conf_example
-    tmpdir = Dir.mktmpdir
+    pid = fork do
+      tmpdir = Dir.mktmpdir
 
-    # modify the example config file for testing
-    path = "examples/yahns_rack_basic.conf.rb"
-    cfgs = File.read(path)
-    cfgs.gsub!(%r{/path/to/}, "#{tmpdir}/")
-    Dir.mkdir("#{tmpdir}/my_app")
-    Dir.mkdir("#{tmpdir}/my_logs")
-    Dir.mkdir("#{tmpdir}/my_pids")
-    conf = File.open("#{tmpdir}/yahns_rack_basic.conf.rb", "w")
-    conf.sync = true
-    conf.write(cfgs)
-    File.open("#{tmpdir}/my_app/config.ru", "w") do |fp|
-      fp.puts("run Rack::Lobster.new\n")
+      # modify the example config file for testing
+      path = "examples/yahns_rack_basic.conf.rb"
+      cfgs = File.read(path)
+      cfgs.gsub!(%r{/path/to/}, "#{tmpdir}/")
+      Dir.mkdir("#{tmpdir}/my_app")
+      Dir.mkdir("#{tmpdir}/my_logs")
+      Dir.mkdir("#{tmpdir}/my_pids")
+      conf = File.open("#{tmpdir}/yahns_rack_basic.conf.rb", "w")
+      conf.sync = true
+      conf.write(cfgs)
+      File.open("#{tmpdir}/my_app/config.ru", "w") do |fp|
+        fp.puts("run Rack::Lobster.new\n")
+      end
+      cfg = Yahns::Config.new(conf.path)
+      FileUtils.rm_rf(tmpdir) if tmpdir
+      exit!(Yahns::Config === cfg)
     end
-    cfg = GTL.synchronize { Yahns::Config.new(conf.path) }
-    assert_instance_of Yahns::Config, cfg
-  ensure
-    FileUtils.rm_rf(tmpdir) if tmpdir
+    _, status = Process.waitpid2(pid)
+    assert status.success?
   end
 end