From 4acc7563a111fd35524b07150990dc3ef842a685 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 28 Nov 2021 21:49:03 +0900 Subject: [PATCH] Consider environment variable case-insensitiveness --- tool/lib/leakchecker.rb | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tool/lib/leakchecker.rb b/tool/lib/leakchecker.rb index 052bea5e53..ed50796940 100644 --- a/tool/lib/leakchecker.rb +++ b/tool/lib/leakchecker.rb @@ -209,13 +209,28 @@ class LeakChecker return leaked end - def find_env - ENV.to_h + e = ENV["_Ruby_Env_Ignorecase_"], ENV["_RUBY_ENV_IGNORECASE_"] + begin + ENV["_Ruby_Env_Ignorecase_"] = ENV["_RUBY_ENV_IGNORECASE_"] = nil + ENV["_RUBY_ENV_IGNORECASE_"] = "ENV_CASE_TEST" + ENV_IGNORECASE = ENV["_Ruby_Env_Ignorecase_"] == "ENV_CASE_TEST" + ensure + ENV["_Ruby_Env_Ignorecase_"], ENV["_RUBY_ENV_IGNORECASE_"] = e + end + + if ENV_IGNORECASE + def find_env + ENV.to_h {|k, v| [k.upcase, v]} + end + else + def find_env + ENV.to_h + end end def check_env(test_name) old_env = @env_info - new_env = ENV.to_h + new_env = find_env return false if old_env == new_env (old_env.keys | new_env.keys).sort.each {|k| if old_env.has_key?(k)