Skip to content

Commit ec9de2a

Browse files
committed
[Misc #21458] Add post-install-check
1 parent 9598ed9 commit ec9de2a

5 files changed

Lines changed: 93 additions & 4 deletions

File tree

.github/workflows/macos.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ jobs:
111111
run: |
112112
echo IRB::VERSION | make runirb RUNOPT="-- -f"
113113
114+
- name: make install
115+
run: make DESTDIR=../install install-nodoc
116+
114117
- name: Set test options for skipped tests
115118
run: |
116119
set -x

.github/workflows/ubuntu.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ jobs:
103103
run: |
104104
echo IRB::VERSION | $SETARCH make runirb RUNOPT="-- -f"
105105
106+
- name: make install
107+
run: make DESTDIR=../install install-nodoc
108+
106109
- name: Set test options for skipped tests
107110
run: |
108111
set -x

.github/workflows/windows.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ jobs:
176176

177177
- run: nmake
178178

179+
- name: nmake install
180+
run: nmake DESTDIR=../install install-nodoc
181+
179182
- name: Set up Launchable
180183
uses: ./.github/actions/launchable/setup
181184
with:

common.mk

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,18 +493,23 @@ $(ruby_pc): $(srcdir)/template/ruby.pc.in config.status
493493

494494
INSTALL_ALL = all
495495

496-
install-all: pre-install-all do-install-all post-install-all
496+
post-install-check:
497+
$(DESTDIR)/$(bindir)/$(PROGRAM) -C $(srcdir) tool/post-install.rb
498+
499+
install-all: pre-install-all do-install-all $(DOT_WAIT) post-install-all
497500
pre-install-all:: all pre-install-local pre-install-ext pre-install-gem pre-install-doc
498501
do-install-all: pre-install-all $(DOT_WAIT) docs
499502
$(INSTRUBY) --make="$(MAKE)" $(INSTRUBY_ARGS) --install=$(INSTALL_ALL) $(INSTALL_DOC_OPTS)
500-
post-install-all:: post-install-local post-install-ext post-install-gem post-install-doc
503+
post-install-all:: post-install-local post-install-ext post-install-gem post-install-doc \
504+
$(DOT_WAIT) post-install-check
501505
@$(NULLCMD)
502506

503-
install-nodoc: pre-install-nodoc do-install-nodoc post-install-nodoc
507+
install-nodoc: pre-install-nodoc do-install-nodoc $(DOT_WAIT) post-install-nodoc
504508
pre-install-nodoc:: pre-install-local pre-install-ext pre-install-gem
505509
do-install-nodoc: main pre-install-nodoc
506510
$(INSTRUBY) --make="$(MAKE)" $(INSTRUBY_ARGS) --install=$(INSTALL_ALL) --exclude=doc
507-
post-install-nodoc:: post-install-local post-install-ext post-install-gem
511+
post-install-nodoc:: post-install-local post-install-ext post-install-gem \
512+
$(DOT_WAIT) post-install-check
508513

509514
install-local: pre-install-local do-install-local post-install-local
510515
pre-install-local:: pre-install-bin pre-install-lib pre-install-man

tool/post-install.rb

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
require 'rbconfig'
2+
3+
module CLITest
4+
class << self
5+
BIN_DIR = RbConfig::CONFIG['bindir']
6+
RUBY_INSTALL_NAME = RbConfig::CONFIG["ruby_install_name"]
7+
abort unless RUBY_INSTALL_NAME.include?("ruby")
8+
9+
ENV["PATH"] = [BIN_DIR, ENV["PATH"]].compact.join(File::PATH_SEPARATOR)
10+
11+
DASH = "\u2500"
12+
PASSED = "\u{2705}"
13+
FAILED = "\u{274c}"
14+
15+
def executable_name(name)
16+
"#{BIN_DIR}/#{RUBY_INSTALL_NAME.sub("ruby", name)}"
17+
end
18+
19+
def chk_cli(cmd, regex)
20+
cmd_name, args = cmd.split(" ", 2)
21+
cmd_str = cmd_name.ljust(10)
22+
cmd_name = executable_name(cmd_name)
23+
cmd = [cmd_name, args].compact.join(" ")
24+
if File.exist? cmd_name
25+
require 'open3'
26+
ret = ''.dup
27+
Open3.popen3(cmd) {|stdin, stdout, stderr, wait_thr|
28+
ret = stdout.read.strip
29+
}
30+
if ret[regex]
31+
"#{cmd_str}#{PASSED} #{$1}"
32+
else
33+
@error += 1
34+
"#{cmd_str}#{FAILED} version? (#{ret}, #{regex})"
35+
end
36+
else
37+
@error += 1
38+
"#{cmd_str}#{FAILED} missing binstub"
39+
end
40+
rescue => e
41+
@error += 1
42+
"#{cmd_str}#{FAILED} #{e.class}"
43+
end
44+
45+
def run
46+
re_version = '(\d{1,2}\.\d{1,2}\.\d{1,2}(\.[a-z0-9.]+)?)'
47+
@error = 0
48+
puts "\n#{DASH * 5} CLI Test #{DASH * 17}"
49+
puts chk_cli("bundle -v", /\ABundler version #{re_version}/)
50+
puts chk_cli("gem --version", /\A#{re_version}/)
51+
puts chk_cli("irb --version", /\Airb +#{re_version}/)
52+
puts chk_cli("racc --version", /\Aracc version #{re_version}/)
53+
puts chk_cli("rake -V", /\Arake, version #{re_version}/)
54+
puts chk_cli("rbs -v" , / #{re_version}\z/)
55+
puts chk_cli("rdbg -v", / #{re_version}\z/)
56+
puts chk_cli("rdoc -v", /\A#{re_version}/)
57+
puts ''
58+
59+
cli_desc = %x[#{executable_name("ruby")} -v].strip
60+
if cli_desc == RUBY_DESCRIPTION
61+
puts cli_desc, ''
62+
else
63+
puts "'ruby -v' doesn't match RUBY_DESCRIPTION\n" \
64+
"#{cli_desc} (ruby -v)\n" \
65+
"#{RUBY_DESCRIPTION} (RUBY_DESCRIPTION)", ''
66+
@error += 1
67+
end
68+
69+
unless @error.zero?
70+
abort "bad exit"
71+
end
72+
end
73+
end
74+
end
75+
CLITest.run

0 commit comments

Comments
 (0)