From 059f0d72aa4663f851187dd98b78a8fda4ce7767 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 27 Dec 2014 04:39:00 +0000 Subject: test: favor Process.spawn when possible Process.spawn allows vfork() + execve() usage in Ruby 2.2.0 to improve performance over normal fork() + execve(). --- test/test_player_integration.rb | 7 +++---- test/test_splitfx.rb | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/test/test_player_integration.rb b/test/test_player_integration.rb index d4bae8d..66f599e 100644 --- a/test/test_player_integration.rb +++ b/test/test_player_integration.rb @@ -5,10 +5,9 @@ class TestPlayerIntegration < Testcase include PlayerIntegration def test_cmd_rate - pid = fork do - @fmt.to_env.each { |k,v| ENV[k] = v } - exec("sox -n $SOXFMT - synth 3 pinknoise | #@cmd") - end + env = ENV.to_hash.merge(@fmt.to_env) + cmd = "sox -n $SOXFMT - synth 3 pinknoise | #@cmd" + pid = Process.spawn(env, cmd) t = Time.now _, _ = Process.waitpid2(pid) elapsed = Time.now - t diff --git a/test/test_splitfx.rb b/test/test_splitfx.rb index fd1873e..ab0dcd2 100644 --- a/test/test_splitfx.rb +++ b/test/test_splitfx.rb @@ -31,9 +31,9 @@ class TestSplitfx < Testcase # compare results with expected output res_cmd = "sox 1.flac 2.flac -ts32 -c2 -r44100 result.s32" - res_pid = fork { exec res_cmd } + res_pid = Process.spawn(res_cmd) exp_cmd = "sox foo.flac -ts32 -c2 -r44100 expect.s32 trim 4" - exp_pid = fork { exec exp_cmd } + exp_pid = Process.spawn(exp_cmd) _, s = Process.waitpid2(res_pid) assert s.success?, "#{res_cmd}: #{s.inspect}" _, s = Process.waitpid2(exp_pid) -- cgit v1.2.3-24-ge0c7