summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-04-28 15:22:14 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2023-04-28 22:05:09 +0900
commit0bd278238462b4c9e89014e6a64fbd9d7d98700a (patch)
treee3441336d2051bb624670319e418f8fb97ec16db /tool
parent7ba37cb7aad715b2927a6fdad89185df92ca8f23 (diff)
downloadruby-0bd278238462b4c9e89014e6a64fbd9d7d98700a.tar.gz
Improve sync_test_lib.rb [ci skip]
- read files to copy once at first - take the destination top directory from command line arguments - fix a typo
Diffstat (limited to 'tool')
-rwxr-xr-xtool/sync_test_lib.rb21
1 files changed, 15 insertions, 6 deletions
diff --git a/tool/sync_test_lib.rb b/tool/sync_test_lib.rb
index d950b4994d..69d2c38e56 100755
--- a/tool/sync_test_lib.rb
+++ b/tool/sync_test_lib.rb
@@ -2,7 +2,13 @@
require "fileutils"
-test_lib_files = %w[core_assertions.rb find_executable.rb envutil.rb]
+test_lib_files = %w[
+ core_assertions.rb
+ find_executable.rb
+ envutil.rb
+].map do |file|
+ [file, File.read("#{__dir__}/lib/#{file}")]
+end
repos = %w[
bigdecimal cgi cmath date delegate did_you_mean digest drb erb etc
@@ -17,20 +23,23 @@ title = "Update test libraries from ruby/ruby #{Time.now.strftime("%Y-%m-%d")}"
commit = `git rev-parse HEAD`.chomp
message = "Update test libraries from https://github.com/ruby/ruby/commit/#{commit}"
+topdir = ARGV.shift || '..'
+
repos.each do |repo|
puts "#{repo}: start"
- Dir.chdir("../#{repo}") do
+ Dir.chdir("#{topdir}/#{repo}") do
if `git branch --list #{branch_name}`.empty?
system "git switch master"
system "git switch -c #{branch_name}"
else
- puts "#{repo}: "
+ puts "#{repo}: skip"
next
end
- test_lib_files.each do |file|
- FileUtils.cp("../ruby/tool/lib/#{file}", "test/lib/#{file}")
+ test_lib_files.each do |file, code|
+ FileUtils.mkdir_p("test/lib")
+ File.binwrite("test/lib/#{file}", code)
system "git add test/lib/#{file}"
end
@@ -47,5 +56,5 @@ repos.each do |repo|
system "git branch -D #{branch_name}"
end
rescue StandardError => e
- ptus e
+ puts e
end