forked from SeleniumHQ/selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchecks.rb
95 lines (71 loc) · 1.44 KB
/
checks.rb
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
require 'rbconfig'
# Platform checks
def windows?
(/mswin|msys|mingw32/ =~ RbConfig::CONFIG['host_os']) != nil
end
def mac?
(/darwin|mac os/ =~ RbConfig::CONFIG['host_os']) != nil
end
def linux?
(/linux/ =~ RbConfig::CONFIG['host_os']) != nil
end
def cygwin?
RUBY_PLATFORM.downcase.include?("cygwin")
end
def unix?
linux? or mac?
end
def classpath_separator?
if cygwin? then
";"
else
File::PATH_SEPARATOR
end
end
def all?
true
end
PRESENT_CACHE = {}
# Checking for particular applications
def present?(arg)
if PRESENT_CACHE.has_key?(arg)
return PRESENT_CACHE[arg]
end
prefixes = ENV['PATH'].split(File::PATH_SEPARATOR)
bool = prefixes.any? do |prefix|
File.exists?(prefix + File::SEPARATOR + arg)
end
if !bool && mac?
bool = File.exists?("/Applications/#{arg}.app")
end
PRESENT_CACHE[arg] = bool
bool
end
def chrome?
present?("chromedriver") || present?("chromedriver.exe")
end
def opera?
present?("opera") || present?("Opera")
end
def java?
present?("java") || present?("java.exe")
end
def javac?
present?("javac") || present?("javac.exe")
end
def jar?
present?("jar") || present?("jar.exe")
end
# Think of the confusion if we called this "g++"
def gcc?
linux? && present?("g++")
end
def python?
present?("python") || present?("python.exe")
end
def msbuild_installed?
windows? && present?("msbuild.exe")
end
def vcs_revision
@vcs_revision ||= `git rev-parse --short HEAD`
end