Skip to content

Commit be98e2b

Browse files
committed
[Misc #21458] Additional post-install-check
1 parent 9dabf45 commit be98e2b

1 file changed

Lines changed: 71 additions & 9 deletions

File tree

tool/post-install.rb

Lines changed: 71 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,79 @@ def run
5454
re_version = '(\d{1,2}\.\d{1,2}\.\d{1,2}(\.[a-z0-9.]+)?)'
5555
@error = 0
5656
puts '', "#{DASH * 5} CLI Test ".ljust(32, DASH)
57-
chk_cli("bundle -v", /\ABundler version #{re_version}/, &print)
58-
chk_cli("gem --version", /\A#{re_version}/, &print)
59-
chk_cli("irb --version", /\Airb +#{re_version}/, &print)
60-
chk_cli("racc --version", /\Aracc version #{re_version}/, &print)
61-
chk_cli("rake -V", /\Arake, version #{re_version}/, &print)
62-
chk_cli("rbs -v", /\Arbs #{re_version}\z/, &print)
63-
chk_cli("rdbg -v", /\Ardbg #{re_version}\z/, &print)
64-
chk_cli("rdoc -v", /\A#{re_version}/, &print)
65-
chk_cli("typeprof --version", /\Atypeprof #{re_version}/, &print)
57+
bundle = chk_cli("bundle -v", /\ABundler version #{re_version}/, &print)
58+
gem = chk_cli("gem --version", /\A#{re_version}/, &print)
59+
irb = chk_cli("irb --version", /\Airb +#{re_version}/, &print)
60+
racc = chk_cli("racc --version", /\Aracc version #{re_version}/, &print)
61+
rake = chk_cli("rake -V", /\Arake, version #{re_version}/, &print)
62+
rbs = chk_cli("rbs -v", /\Arbs #{re_version}\z/, &print)
63+
rdbg = chk_cli("rdbg -v", /\Ardbg #{re_version}\z/, &print)
64+
rdoc = chk_cli("rdoc -v", /\A#{re_version}/, &print)
65+
typeprof = chk_cli("typeprof --version", /\Atypeprof #{re_version}/, &print)
6666
puts ''
6767

68+
if @error.zero?
69+
dash_item = DASH * 7
70+
puts '', "#{DASH * 5} Run Tools ".ljust(32, DASH)
71+
require "tmpdir"
72+
Dir.mktmpdir do |dir|
73+
if bundle
74+
puts "#{dash_item} #{bundle}"
75+
File.write(dir + "/Gemfile", "")
76+
system(bundle, chdir: dir, exception: false) or @error += 1
77+
end
78+
if gem
79+
puts "#{dash_item} #{gem}"
80+
system(gem, "list", chdir: dir, exception: false) or @error += 1
81+
end
82+
if irb
83+
puts "#{dash_item} #{irb}"
84+
File.write(dir + "/irb_input", "IRB::VERSION\n")
85+
system(irb, "irb_input", chdir: dir, exception: false) or @error += 1
86+
end
87+
if racc
88+
puts "#{dash_item} #{racc}"
89+
end
90+
if rake
91+
puts "#{dash_item} #{rake}"
92+
File.write(dir + "/Rakefile", <<~RUBY)
93+
task :default => :version do
94+
puts 'OK'
95+
end
96+
task :version do
97+
print Rake::VERSION, " "
98+
end
99+
RUBY
100+
system(rake, chdir: dir, exception: false) or @error += 1
101+
end
102+
if rbs
103+
puts "#{dash_item} #{rbs}"
104+
end
105+
if rdbg
106+
puts "#{dash_item} #{rdbg}"
107+
end
108+
if rdoc
109+
puts "#{dash_item} #{rdoc}"
110+
File.write(dir + "/main.rb", <<~RUBY)
111+
# Class for test
112+
class Test
113+
end
114+
RUBY
115+
File.write(dir + "/.document", "main.rb\n")
116+
File.write(dir + "/.rdoc_options", <<~YAML)
117+
---
118+
main_page: main.rb
119+
YAML
120+
system(rdoc, "-C", ".", chdir: dir, exception: false) or @error += 1
121+
end
122+
if typeprof
123+
puts "#{dash_item} #{typeprof}"
124+
File.write(dir + "/typeprof-target.rb", "p __FILE__\n")
125+
system(typeprof, "typeprof-target.rb", chdir: dir, exception: false) or @error += 1
126+
end
127+
end
128+
end
129+
68130
cli_desc = %x[#{RUBY_INSTALL_NAME} -v][/\A.*/]
69131
if cli_desc == RUBY_DESCRIPTION
70132
puts cli_desc, ''

0 commit comments

Comments
 (0)