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

ruby-changes:60615

From: Nobuyoshi <ko1@a...>
Date: Wed, 1 Apr 2020 12:50:06 +0900 (JST)
Subject: [ruby-changes:60615] 5a81562dfe (master): `Dir.glob` always returns an array

https://git.ruby-lang.org/ruby.git/commit/?id=5a81562dfe

From 5a81562dfed2d5839e28b654d4f0f69de632aa8e Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Wed, 1 Apr 2020 12:37:01 +0900
Subject: `Dir.glob` always returns an array

It is not needed to test itself, but the element should be tested
instead.

diff --git a/test/fiddle/helper.rb b/test/fiddle/helper.rb
index f5c7bd2..f405b53 100644
--- a/test/fiddle/helper.rb
+++ b/test/fiddle/helper.rb
@@ -31,12 +31,8 @@ when /linux/ https://github.com/ruby/ruby/blob/trunk/test/fiddle/helper.rb#L31
       # In the ARM 32-bit libc package such as libc6:armhf libc6:armel,
       # libc.so and libm.so are installed to /lib/arm-linux-gnu*.
       # It's not installed to /lib32.
-      dirs = Dir.glob('/lib/arm-linux-gnu*')
-      if dirs.length > 0
-        libdir = dirs[0] if dirs && File.directory?(dirs[0])
-      else # handle alpine environment
-        libdir = '/lib' if File.directory? '/lib'
-      end
+      dir, = Dir.glob('/lib/arm-linux-gnu*')
+      libdir = dir if dir && File.directory?(dir)
     else
       libdir = '/lib32' if File.directory? '/lib32'
     end
@@ -46,10 +42,9 @@ when /linux/ https://github.com/ruby/ruby/blob/trunk/test/fiddle/helper.rb#L42
   end
 
   # Handle musl libc
-  libc = Dir.glob(File.join(libdir, "libc.musl*.so*"))
-  if libc && libc.length > 0
-    libc_so = libc[0]
-    libm_so = libc[0]
+  libc_so, = Dir.glob(File.join(libdir, "libc.musl*.so*"))
+  if libc_so
+    libm_so = libc_so
   else
     # glibc
     libc_so = File.join(libdir, "libc.so.6")
-- 
cgit v0.10.2


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

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