From 9ea1281a7632dfa9b4ada9348ca4d6347616b70d Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 28 Apr 2023 15:47:59 +0900 Subject: Add sync_tool.rake [ci skip] --- tool/rakelib/sync_tool.rake | 15 +++++++++++++++ tool/sync_test_lib.rb | 25 ++++++++++++++----------- 2 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 tool/rakelib/sync_tool.rake (limited to 'tool') diff --git a/tool/rakelib/sync_tool.rake b/tool/rakelib/sync_tool.rake new file mode 100644 index 0000000000..ee69efffcb --- /dev/null +++ b/tool/rakelib/sync_tool.rake @@ -0,0 +1,15 @@ +task :sync_tool, [:from] do |t, from: (File.identical?(__dir__, "rakelib") ? "../ruby/tool" : __dir__)| + require 'fileutils' + + { + "rakelib/sync_tool.rake" => "rakelib", + "lib/core_assertions.rb" => "test/lib", + "lib/envutil.rb" => "test/lib", + "lib/find_executable.rb" => "test/lib", + "lib/helper.rb" => "test/lib", + }.each do |src, dest| + FileUtils.mkpath(dest) + FileUtils.cp "#{from}/#{src}", dest + rescue Errno::ENOENT + end +end diff --git a/tool/sync_test_lib.rb b/tool/sync_test_lib.rb index b2878b463f..021c3cbda8 100755 --- a/tool/sync_test_lib.rb +++ b/tool/sync_test_lib.rb @@ -2,13 +2,14 @@ require "fileutils" -test_lib_files = %w[ - core_assertions.rb - find_executable.rb - envutil.rb - helper.rb -].map do |file| - [file, File.read("#{__dir__}/lib/#{file}")] +test_lib_files = [ + ["lib/core_assertions.rb", "test/lib"], + ["lib/find_executable.rb", "test/lib"], + ["lib/envutil.rb", "test/lib"], + ["lib/helper.rb", "test/lib"], + ["rakelib/sync_tool.rake", "rakelib"], +].map do |file, dest| + [file, dest, File.read("#{__dir__}/#{file}")] end repos = %w[ @@ -25,6 +26,7 @@ commit = `git rev-parse HEAD`.chomp message = "Update test libraries from https://github.com/ruby/ruby/commit/#{commit}" topdir = ARGV.shift || '..' +repos = ARGV unless ARGV.empty? repos.each do |repo| puts "#{repo}: start" @@ -38,10 +40,11 @@ repos.each do |repo| next end - test_lib_files.each do |file, code| - FileUtils.mkdir_p("test/lib") - File.binwrite("test/lib/#{file}", code) - system "git add test/lib/#{file}" + test_lib_files.each do |file, dest, code| + FileUtils.mkdir_p(dest) + file = "#{dest}/#{File.basename(file)}" + File.binwrite(file, code) + system "git add #{file}" end if `git commit -m '#{message}'`.chomp =~ /nothing to commit/ -- cgit v1.2.1