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

ruby-changes:60477

From: Takashi <ko1@a...>
Date: Mon, 23 Mar 2020 04:19:55 +0900 (JST)
Subject: [ruby-changes:60477] dec0f582e4 (master): Workaround an encoding problem in run_without_tabs

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

From dec0f582e41c84fd24be7b0f1633bf8979ee2db7 Mon Sep 17 00:00:00 2001
From: Takashi Kokubun <takashikkbn@g...>
Date: Sun, 22 Mar 2020 12:18:46 -0700
Subject: Workaround an encoding problem in run_without_tabs

It's to be fixed properly later. But this should be able to avoid the failure.

https://travis-ci.org/github/ruby/ruby/jobs/665580361
https://rubyci.org/logs/rubyci.s3.amazonaws.com/solaris10-gcc/ruby-master/log/20200322T190003Z.fail.html.gz

diff --git a/tool/run_without_tabs.rb b/tool/run_without_tabs.rb
index bf74468..54252c5 100644
--- a/tool/run_without_tabs.rb
+++ b/tool/run_without_tabs.rb
@@ -21,27 +21,36 @@ targets = Dir.glob(File.join(srcdir, 'vm*.*')) - SKIPPED_FILES.map { |f| File.jo https://github.com/ruby/ruby/blob/trunk/tool/run_without_tabs.rb#L21
 sources = {}
 mtimes = {}
 
-if skip = targets.any? { |target| !File.writable?(target) }
-  puts "tool/run_without_tabs.rb: srcdir has non-writable files. Skipping tab expansion."
-end
-
 targets.each do |target|
-  sources[target] = File.read(target)
+  unless File.writable?(target)
+    puts "tool/run_without_tabs.rb: Skipping #{target.dump} as it's not writable."
+    next
+  end
+  source = File.read(target)
+  begin
+    expanded = source.gsub(/^\t+/) { |tab| ' ' * 8 * tab.length }
+  rescue ArgumentError # invalid byte sequence in UTF-8 (Travis, RubyCI)
+    puts "tool/run_without_tabs.rb: Skipping #{target.dump} as the encoding is #{source.encoding}."
+    next
+  end
+
+  sources[target] = source
   mtimes[target] = File.mtime(target)
 
-  expanded = sources[target].force_encoding('UTF-8').gsub(/^\t+/) { |tab| ' ' * 8 * tab.length }
   if sources[target] == expanded
     puts "#{target.dump} has no hard tab indentation. This should be ignored in tool/run_without_tabs.rb."
   end
   File.write(target, expanded)
   FileUtils.touch(target, mtime: mtimes[target])
-end unless skip
+end
 
 result = system(*ARGV)
 
 targets.each do |target|
-  File.write(target, sources.fetch(target))
-  FileUtils.touch(target, mtime: mtimes.fetch(target))
-end unless skip
+  if sources.key?(target)
+    File.write(target, sources[target])
+    FileUtils.touch(target, mtime: mtimes.fetch(target))
+  end
+end
 
 exit result
-- 
cgit v0.10.2


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

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