about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-04-30 18:17:33 +0000
committerEric Wong <bofh@yhbt.net>2021-05-01 23:43:28 +0000
commit93e154e16b87f943a20fa720e002c67c9d17c30b (patch)
tree3b47769da644b6987a5cb050c63ff4a00db977ea
parent3ed7dfc218475c9b6b95f62e0eba6975ecd52e45 (diff)
downloadunicorn-93e154e16b87f943a20fa720e002c67c9d17c30b.tar.gz
Ruby's handling of encodings hasn't changed much in over
a decade and these tests haven't failed for me since August 2013:

  https://yhbt.net/unicorn-public/9af083d7f6b97c0f5ebbdd9a42b58478a6f874b7/s/

So lets take a small step in reducing energy consumption
and save potential developers over 10s of CPU time.
-rw-r--r--test/unit/test_util.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/test/unit/test_util.rb b/test/unit/test_util.rb
index 4a820ea..bc7b233 100644
--- a/test/unit/test_util.rb
+++ b/test/unit/test_util.rb
@@ -51,7 +51,7 @@ class TestUtil < Test::Unit::TestCase
   def test_reopen_logs_renamed_with_encoding
     tmp = Tempfile.new('')
     tmp_path = tmp.path.dup.freeze
-    Encoding.list.each { |encoding|
+    Encoding.list.sample(5).each { |encoding|
       File.open(tmp_path, "a:#{encoding.to_s}") { |fp|
         fp.sync = true
         assert_equal encoding, fp.external_encoding
@@ -74,8 +74,9 @@ class TestUtil < Test::Unit::TestCase
   def test_reopen_logs_renamed_with_internal_encoding
     tmp = Tempfile.new('')
     tmp_path = tmp.path.dup.freeze
-    Encoding.list.each { |ext|
-      Encoding.list.each { |int|
+    full = Encoding.list
+    full.sample(2).each { |ext|
+      full.sample(2).each { |int|
         next if ext == int
         File.open(tmp_path, "a:#{ext.to_s}:#{int.to_s}") { |fp|
           fp.sync = true