Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathcli_test.rb
More file actions
Latest commit
73 lines (67 loc) · 2.2 KB
/
Copy pathcli_test.rb
File metadata and controls
73 lines (67 loc) · 2.2 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
70
71
72
73
require'rbconfig'
moduleCLITest
class << self
BIN_DIR=RbConfig::CONFIG['bindir']
DASH="\u2500".dup.force_encoding'utf-8'
defchk_cli(cmd,regex)
cmd_str=cmd[/\A[^ ]+/].ljust(10)
cmd_path="#{BIN_DIR}/#{cmd_str}".strip
ifFile.exist?cmd_path.strip
ifRUBY_PLATFORM[/mingw|mswin/]
unlessFile.exist?("#{cmd_path}.bat") || File.exist?("#{cmd_path}.cmd")
return"#{cmd_str}❌ missing windows binstub"
end
end
require'open3'
ret=''.dup
Open3.popen3(cmd){|stdin,stdout,stderr,wait_thr|
ret=stdout.read.strip
ret=stderr.read.stripifret.empty?
}
ifret[regex]
"#{cmd_str}✅ #{$1}"
else
@error += 1
"#{cmd_str}❌ version?"
end
else
@error += 1
"#{cmd_str}❌ missing binstub"
end
rescue=>e
@error += 1
"#{cmd_str}❌ #{e.class}#{e.message}"
end
defrun
re_version='(\d{1,2}\.\d{1,2}\.\d{1,2}(\.[a-z0-9.]+)?)'
@error=0
puts"\n#{DASH * 5} CLI Test #{DASH * 17}"
putschk_cli("bundle -v",/\A(?:Bundler version )?#{re_version}/)
putschk_cli("erb --version",/\A#{re_version}/)
putschk_cli("gem --version",/\A#{re_version}/)
putschk_cli("irb --version",/\Airb +#{re_version}/)
putschk_cli("racc --version",/\Aracc version #{re_version}/)
putschk_cli("rake -V",/\Arake, version #{re_version}/)
putschk_cli("rbs -v",/\Arbs #{re_version}/)
putschk_cli("rdbg -v",/\Ardbg #{re_version}/)
putschk_cli("rdoc -v",/\A#{re_version}/)
putschk_cli("test-unit --version",/\A(?:test-unit )?#{re_version}/)
putschk_cli("typeprof --version",/#{re_version}\z/)
puts''
cli_desc=%x[ruby -v].strip
ifcli_desc == RUBY_DESCRIPTION
putscli_desc,''
else
puts"'ruby -v' doesn't match RUBY_DESCRIPTION\n" \
"#{cli_desc} (ruby -v)\n" \
"#{RUBY_DESCRIPTION} (RUBY_DESCRIPTION)",''
@error += 1
end
unless@error.zero?
puts"bad exit"
exit1
end
end
end
end
CLITest.run