diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-04-28 15:47:59 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-04-28 22:05:09 +0900 |
commit | 9ea1281a7632dfa9b4ada9348ca4d6347616b70d (patch) | |
tree | b4a0cae781ee6e08cbc5a9a2b4da07dc126c75a2 /tool | |
parent | afc98e3b551b11baa4a9257d7578d3151404fcc0 (diff) | |
download | ruby-9ea1281a7632dfa9b4ada9348ca4d6347616b70d.tar.gz |
Add sync_tool.rake [ci skip]
Diffstat (limited to 'tool')
-rw-r--r-- | tool/rakelib/sync_tool.rake | 15 | ||||
-rwxr-xr-x | tool/sync_test_lib.rb | 25 |
2 files changed, 29 insertions, 11 deletions
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/ |