[前][次][番号順一覧][スレッド一覧]

ruby-changes:68045

From: Lars <ko1@a...>
Date: Mon, 20 Sep 2021 00:15:53 +0900 (JST)
Subject: [ruby-changes:68045] 70cefcfa0f (master): Adjust test to set+get big values on all platforms and add MINGW-UCRT

https://git.ruby-lang.org/ruby.git/commit/?id=70cefcfa0f

From 70cefcfa0f769f7269cf0c950a4516036dd1a1ea Mon Sep 17 00:00:00 2001
From: Lars Kanis <kanis@c...>
Date: Tue, 22 Jun 2021 08:52:49 +0200
Subject: Adjust test to set+get big values on all platforms and add MINGW-UCRT

Previously the test verified on MSWIN that huge values can not be stored in environment variables but that they can on others.
IMHO the intention of the test should not change between platforms.
Therefore this adjusts the test to have the same intention - that is to store a big value.

This also fixes compatibility with MINGW-UCRT, which previously failed with:
  <Errno::EINVAL: Invalid argument - ruby_setenv(foo)>
    test/ruby/test_env.rb:512:in `[]='
    test/ruby/test_env.rb:512:in `block in test_huge_value'
---
 test/ruby/test_env.rb | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/test/ruby/test_env.rb b/test/ruby/test_env.rb
index 583b432..ea0f367 100644
--- a/test/ruby/test_env.rb
+++ b/test/ruby/test_env.rb
@@ -503,15 +503,15 @@ class TestEnv < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_env.rb#L503
   end
 
   def test_huge_value
-    huge_value = "bar" * 40960
-    ENV["foo"] = "bar"
-    if /mswin/ =~ RUBY_PLATFORM
-      assert_raise(Errno::EINVAL) { ENV["foo"] = huge_value }
-      assert_equal("bar", ENV["foo"])
+    if /mswin/ =~ RUBY_PLATFORM || /ucrt/ =~ RbConfig::CONFIG['sitearch']
+      # On Windows >= Vista each environment variable can be max 32768 characters
+      huge_value = "bar" * 10900
     else
-      assert_nothing_raised { ENV["foo"] = huge_value }
-      assert_equal(huge_value, ENV["foo"])
+      huge_value = "bar" * 40960
     end
+    ENV["foo"] = "overwritten"
+    assert_nothing_raised { ENV["foo"] = huge_value }
+    assert_equal(huge_value, ENV["foo"])
   end
 
   if /mswin|mingw/ =~ RUBY_PLATFORM
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]