specinfra 1.11.0 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 15732552ecb38106eeeaddf39492ea2612181a8d
4
- data.tar.gz: 0014a3d0dead5a721dfca1944c8627de316b12de
3
+ metadata.gz: f67f6404a72167028cc78c1347bd67da39f57205
4
+ data.tar.gz: d6fe99bbcc3f6b80d18319bb85b472ee0dd37abf
5
5
  SHA512:
6
- metadata.gz: 330a3e39284e1c610adbda642acb90fb1b35898ad3c64cfb7aef284a2ac9c2a2d7660681bb1f134935c5fd3ab1bb51e74942aa971afa45103fe82ed67f6d07b6
7
- data.tar.gz: 587aff1fff9c7d78ee72aa34d30cc5f0b919fab6ec82d0f2e0678f6e8fbf203f1383854b67159e319b8d1a807a0bb493769996dc70b049cabb09d80154dfbec3
6
+ metadata.gz: d73b47ee671274ed47e26b7d1a4b1dad79a7dd701fdc0af0fee4ba067425d30fd8608c29b7412884cd53b583733fc0d111545ed2cfd7021613bfd090a2b53a90
7
+ data.tar.gz: 647c9fbd5a46351fc3ff195d21ddc9f9dde50b5e6631429ec4c71aa46ee16711aa2a932af0a0dd7578a3f1fa7a2ee83313de7d030b32931f770341e23f09dc3a
@@ -181,6 +181,7 @@ module SpecInfra
181
181
 
182
182
  def check_os
183
183
  return SpecInfra.configuration.os if SpecInfra.configuration.os
184
+ arch = run_command('uname -m').stdout.strip
184
185
  # Fedora also has an /etc/redhat-release so the Fedora check must
185
186
  # come before the RedHat check
186
187
  if run_command('ls /etc/fedora-release').success?
@@ -194,19 +195,20 @@ module SpecInfra
194
195
  if line =~ /release (\d[\d.]*)/
195
196
  release = $1
196
197
  end
198
+
197
199
  if release =~ /7./
198
- { :family => 'RedHat7', :release => release }
200
+ { :family => 'RedHat7', :release => release, :arch => arch }
199
201
  else
200
- { :family => 'RedHat', :release => release }
202
+ { :family => 'RedHat', :release => release, :arch => arch }
201
203
  end
202
204
  elsif run_command('ls /etc/system-release').success?
203
- { :family => 'RedHat', :release => nil } # Amazon Linux
205
+ { :family => 'RedHat', :release => nil, :arch => arch } # Amazon Linux
204
206
  elsif run_command('ls /etc/SuSE-release').success?
205
207
  line = run_command('cat /etc/SuSE-release').stdout
206
208
  if line =~ /SUSE Linux Enterprise Server (\d+)/
207
209
  release = $1
208
210
  end
209
- { :family => 'SuSE', :release => release }
211
+ { :family => 'SuSE', :release => release, :arch => arch }
210
212
  elsif run_command('ls /etc/debian_version').success?
211
213
  lsb_release = run_command("lsb_release -ir")
212
214
  if lsb_release.success?
@@ -225,37 +227,37 @@ module SpecInfra
225
227
  end
226
228
  distro ||= 'Debian'
227
229
  release ||= nil
228
- { :family => distro.strip, :release => release }
230
+ { :family => distro.strip, :release => release, :arch => arch }
229
231
  elsif run_command('ls /etc/gentoo-release').success?
230
- { :family => 'Gentoo', :release => nil }
232
+ { :family => 'Gentoo', :release => nil, :arch => arch }
231
233
  elsif run_command('ls /usr/lib/setup/Plamo-*').success?
232
- { :family => 'Plamo', :release => nil }
234
+ { :family => 'Plamo', :release => nil, :arch => arch }
233
235
  elsif run_command('uname -s').stdout =~ /AIX/i
234
- { :family => 'AIX', :release => nil }
235
- elsif (os = run_command('uname -sr').stdout) && os =~ /SunOS/i
236
- if os =~ /5.10/
237
- { :family => 'Solaris10', :release => nil }
236
+ { :family => 'AIX', :release => nil, :arch => arch }
237
+ elsif ( uname = run_command('uname -sr').stdout) && uname =~ /SunOS/i
238
+ if uname =~ /5.10/
239
+ { :family => 'Solaris10', :release => nil, :arch => arch }
238
240
  elsif run_command('grep -q "Oracle Solaris 11" /etc/release').success?
239
- { :family => 'Solaris11', :release => nil }
241
+ { :family => 'Solaris11', :release => nil, :arch => arch }
240
242
  elsif run_command('grep -q SmartOS /etc/release').success?
241
- { :family => 'SmartOS', :release => nil }
243
+ { :family => 'SmartOS', :release => nil, :arch => arch }
242
244
  else
243
- { :family => 'Solaris', :release => nil }
245
+ { :family => 'Solaris', :release => nil, :arch => arch }
244
246
  end
245
247
  elsif run_command('uname -s').stdout =~ /Darwin/i
246
248
  { :family => 'Darwin', :release => nil }
247
- elsif (os = run_command('uname -sr').stdout) && os =~ /FreeBSD/i
248
- if os =~ /10./
249
- { :family => 'FreeBSD10', :release => nil }
249
+ elsif ( uname = run_command('uname -sr').stdout ) && uname =~ /FreeBSD/i
250
+ if uname =~ /10./
251
+ { :family => 'FreeBSD10', :release => nil, :arch => arch }
250
252
  else
251
- { :family => 'FreeBSD', :release => nil }
253
+ { :family => 'FreeBSD', :release => nil, :arch => arch }
252
254
  end
253
255
  elsif run_command('uname -sr').stdout =~ /Arch/i
254
- { :family => 'Arch', :release => nil }
256
+ { :family => 'Arch', :release => nil, :arch => arch }
255
257
  elsif run_command('uname -s').stdout =~ /OpenBSD/i
256
- { :family => 'OpenBSD', :release => nil }
258
+ { :family => 'OpenBSD', :release => nil, :arch => arch }
257
259
  else
258
- { :family => 'Base', :release => nil }
260
+ { :family => 'Base', :release => nil, :arch => arch }
259
261
  end
260
262
  end
261
263
 
@@ -19,6 +19,15 @@ module SpecInfra
19
19
  VALID_OPTIONS_KEYS.inject({}) { |o, k| o.merge!(k => send(k)) }
20
20
  end
21
21
 
22
+ # Define os method explicitly to avoid stack level
23
+ # too deep caused by Helpet::DetectOS#os
24
+ def os
25
+ if @os.nil? && defined?(RSpec) && RSpec.configuration.respond_to?(:os)
26
+ @os = RSpec.configuration.os
27
+ end
28
+ @os
29
+ end
30
+
22
31
  def method_missing(meth, val=nil)
23
32
  key = meth.to_s
24
33
  key.gsub!(/=$/, '')
@@ -2,17 +2,24 @@ module SpecInfra
2
2
  module Helper
3
3
  module DetectOS
4
4
  def commands
5
+ self.class.const_get('SpecInfra').const_get('Command').const_get(os[:family]).new
6
+ end
7
+
8
+ def os
5
9
  property[:os_by_host] = {} if ! property[:os_by_host]
6
10
  host = SpecInfra.configuration.ssh ? SpecInfra.configuration.ssh.host : 'localhost'
7
11
 
8
12
  if property[:os_by_host][host]
9
- os = property[:os_by_host][host]
13
+ os_by_host = property[:os_by_host][host]
10
14
  else
11
15
  # Set command object explicitly to avoid `stack too deep`
12
- os = backend(SpecInfra::Command::Base.new).check_os
13
- property[:os_by_host][host] = os
16
+ raise "crash me" if caller.length > 500
17
+ os_by_host = backend(SpecInfra::Command::Base.new).check_os
18
+
19
+ property[:os_by_host][host] = os_by_host
14
20
  end
15
- self.class.const_get('SpecInfra').const_get('Command').const_get(os[:family]).new
21
+
22
+ os_by_host
16
23
  end
17
24
  end
18
25
  end
@@ -1,3 +1,3 @@
1
1
  module SpecInfra
2
- VERSION = "1.11.0"
2
+ VERSION = "1.12.0"
3
3
  end
@@ -35,56 +35,61 @@ describe 'check_os' do
35
35
  context 'test ubuntu with lsb_release command' do
36
36
  subject { backend.check_os }
37
37
  it do
38
- mock_success_response = double(
39
- :run_command_response,
40
- :success? => true,
41
- :stdout => "Distributor ID:\tUbuntu\nRelease:\t12.04\n"
42
- )
43
- mock_failure_response = double :run_command_response, :success? => false
44
38
  backend.should_receive(:run_command).at_least(1).times do |args|
45
39
  if ['ls /etc/debian_version', 'lsb_release -ir'].include? args
46
- mock_success_response
40
+ double(
41
+ :run_command_response,
42
+ :success? => true,
43
+ :stdout => "Distributor ID:\tUbuntu\nRelease:\t12.04\n"
44
+ )
45
+ elsif args == 'uname -m'
46
+ double :run_command_response, :success? => true, :stdout => "x86_64\n"
47
47
  else
48
- mock_failure_response
48
+ double :run_command_response, :success? => false
49
49
  end
50
50
  end
51
- should eq({:family => 'Ubuntu', :release => '12.04'})
51
+ should eq({:family => 'Ubuntu', :release => '12.04', :arch => 'x86_64' })
52
52
  end
53
53
  end
54
54
 
55
55
  context 'test ubuntu with /etc/lsb-release' do
56
56
  subject { backend.check_os }
57
57
  it do
58
- mock_success_response = double(
59
- :run_command_response,
60
- :success? => true,
61
- :stdout => %Q(DISTRIB_ID=Ubuntu
58
+ backend.should_receive(:run_command).at_least(1).times do |args|
59
+ if ['ls /etc/debian_version', 'cat /etc/lsb-release'].include? args
60
+ double(
61
+ :run_command_response,
62
+ :success? => true,
63
+ :stdout => <<-EOF
64
+ DISTRIB_ID=Ubuntu
62
65
  DISTRIB_RELEASE=12.04
63
66
  DISTRIB_CODENAME=precise
64
67
  DISTRIB_DESCRIPTION="Ubuntu 12.04.2 LTS"
65
- )
66
- )
67
- mock_failure_response = double :run_command_response, :success? => false
68
- backend.should_receive(:run_command).at_least(1).times do |args|
69
- if ['ls /etc/debian_version', 'cat /etc/lsb-release'].include? args
70
- mock_success_response
68
+ EOF
69
+ )
70
+ elsif args == 'uname -m'
71
+ double :run_command_response, :success? => true, :stdout => "x86_64\n"
71
72
  else
72
- mock_failure_response
73
+ double :run_command_response, :success? => false
73
74
  end
74
75
  end
75
- should eq({:family => 'Ubuntu', :release => '12.04'})
76
+ should eq({:family => 'Ubuntu', :release => '12.04', :arch => 'x86_64' })
76
77
  end
77
78
  end
78
79
 
79
80
  context 'test debian (no lsb_release or lsb-release)' do
80
81
  subject { backend.check_os }
81
82
  it do
82
- mock_success_response = double :run_command_response, :success? => true
83
- mock_failure_response = double :run_command_response, :success? => false
84
83
  backend.should_receive(:run_command).at_least(1).times do |args|
85
- args == 'ls /etc/debian_version' ? mock_success_response : mock_failure_response
84
+ if args == 'ls /etc/debian_version'
85
+ double :run_command_response, :success? => true
86
+ elsif args == 'uname -m'
87
+ double :run_command_response, :success? => true, :stdout => "x86_64\n"
88
+ else
89
+ double :run_command_response, :success? => false
90
+ end
86
91
  end
87
- should eq({:family => 'Debian', :release => nil})
92
+ should eq({:family => 'Debian', :release => nil, :arch => 'x86_64' })
88
93
  end
89
94
  end
90
95
  end
@@ -7,3 +7,8 @@ end
7
7
  describe RSpec.configuration.path do
8
8
  it { should eq SpecInfra.configuration.path }
9
9
  end
10
+
11
+ SpecInfra.configuration.os = 'foo'
12
+ describe SpecInfra.configuration.os do
13
+ it { should eq 'foo' }
14
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specinfra
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0
4
+ version: 1.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gosuke Miyashita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-07 00:00:00.000000000 Z
11
+ date: 2014-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler