This repository was archived by the owner on May 15, 2021. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathdownload-test_readline.rb
More file actions
69 lines (57 loc) · 2.37 KB
/
Copy pathdownload-test_readline.rb
File metadata and controls
69 lines (57 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# frozen_string_literal: true
# From ruby/ruby, copies readline test files & tool/lib files
# Replicates testing used in Ruby master
require 'uri'
require 'net/http'
require 'openssl'
require 'fileutils'
module HTTPS_DL
# number of concurrent connections
CONNECTIONS = 4
HOST = "https://raw.githubusercontent.com"
URI_GH = URI HOST
BASE = "ruby/ruby/master"
# 1st - ruby/ruby dir , 2nd - reline dir , 3rd - filename
FILES = [
["test/readline" , "test/ext/readline" , "helper.rb" ],
["test/readline" , "test/ext/readline" , "test_readline.rb" ],
["test/readline" , "test/ext/readline" , "test_readline_history.rb" ],
["tool/lib" , "tool/lib" , "colorize.rb" ],
["tool/lib" , "tool/lib" , "envutil.rb" ],
["tool/lib" , "tool/lib" , "find_executable.rb" ],
["tool/lib" , "tool/lib" , "leakchecker.rb" ],
["tool/lib/minitest" , "tool/lib/minitest" , "unit.rb" ],
["tool/lib/test" , "tool/lib/test" , "unit.rb" ],
["tool/lib/test/unit", "tool/lib/test/unit", "assertions.rb" ],
["tool/lib/test/unit", "tool/lib/test/unit", "core_assertions.rb" ],
["tool/lib/test/unit", "tool/lib/test/unit", "parallel.rb" ],
["tool/lib/test/unit", "tool/lib/test/unit", "testcase.rb" ]
]
class << self
def run
files = FILES
dirs = FILES.map { |l| l[1] }.uniq
dirs.each { |dir| FileUtils.mkdir_p("./#{dir}") unless Dir.exist? dir }
connections = []
CONNECTIONS.times do
connections << Thread.new do
Net::HTTP.start(URI_GH.host, URI_GH.port, :use_ssl => true,:verify_mode => OpenSSL::SSL::VERIFY_PEER) do |http|
while (path, dir, file = files.shift)
uri = URI("#{HOST}/#{BASE}/#{path}/#{file}")
req = Net::HTTP::Get.new uri.request_uri
http.request req do |res|
unless Net::HTTPOK === res
STDOUT.puts "Can't download #{path}/#{file} from #{HOST}/#{BASE}/"
exit 1
end
File.binwrite "./#{dir}/#{file}", res.body
end
end
end
end
end
connections.each { |th| th.join }
end
end
end
HTTPS_DL.run