vanagon 0.15.29 → 0.15.30

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
  SHA256:
3
- metadata.gz: 877a697fd57ce53c0dd89e1b099fe85c72f9287b5a5b7e15d04b6bcc97e5f2c0
4
- data.tar.gz: 0b3560e9264fcffed179d31aa158ffe323b06afd52c79497fd2878e2f34c68e9
3
+ metadata.gz: 4917406e87bb1c0bcd88d6ace341e339c44911e20d8247f1db35f647ec410f4e
4
+ data.tar.gz: c537dce6713fe063b707c1f690d6349a21939722d7571229192765071e444c74
5
5
  SHA512:
6
- metadata.gz: 6934be1647dd79e6eef5134e9d0ce6a5b1e3741d1cdd312a93577e7b679e5d2e0c5cd1ee75826b64cca0356dcbee60a274470c75bf562d45dddbd49570ab73f3
7
- data.tar.gz: 4e6108cdf712ab062d1910f05fa05ea64c2ec54dc8500a7dd314bab495c41f5f9ef171ca466ba3aeb4f251ecc0d9697c46f3bac05b94923f62ba3ef25fed5e8d
6
+ metadata.gz: 037d6022077165c30e43d4357a2dac1cfdd231edf3afdb54537e01c29211f8e3229ea95af1d816817f310d3e4c98d2d049c68705fb304ff307d3c9ff5f154a5e
7
+ data.tar.gz: b77851bd99b21a4fcd95ce8e7378305ea79dec14d24851b432fbabc484f62b56ee9bed79ec44fe7072186bac968f5d3d15d943de097ba487fc864b1d3f917d08
@@ -7,7 +7,7 @@ require 'vanagon/extensions/hashable'
7
7
  load File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "vanagon.rb"))
8
8
 
9
9
  optparse = Vanagon::OptParse.new("#{File.basename(__FILE__)} <project-name> <platform-name> [options]", %i[workdir configdir engine])
10
- options = optparse.parse! ARGV
10
+ optparse.parse! ARGV
11
11
 
12
12
  project = ARGV[0]
13
13
  platform = ARGV[1]
data/bin/render CHANGED
@@ -9,7 +9,6 @@ options = optparse.parse! ARGV
9
9
 
10
10
  project = ARGV[0]
11
11
  platforms = ARGV[1]
12
- targets = ARGV[2]
13
12
 
14
13
  if project.nil? or platforms.nil?
15
14
  warn "project and platform are both required arguments."
@@ -13,7 +13,7 @@ class Vanagon
13
13
  # Equality. How does it even work?
14
14
  #
15
15
  # @return [true, false] true if all attributes have equal values. false otherwise.
16
- def ==(other) # rubocop:disable Metrics/AbcSize
16
+ def ==(other)
17
17
  other.name == self.name && \
18
18
  other.group == self.group && \
19
19
  other.shell == self.shell && \
@@ -411,7 +411,7 @@ class Vanagon
411
411
  # This environment is included in the configure, build and install steps.
412
412
  #
413
413
  # @param env [Hash] mapping of keys to values to add to the environment for the component
414
- def environment(*env) # rubocop:disable Metrics/AbcSize
414
+ def environment(*env)
415
415
  if env.size == 1 && env.first.is_a?(Hash)
416
416
  warn <<-WARNING.undent
417
417
  the component DSL method signature #environment({Key => Value}) is deprecated
@@ -120,7 +120,7 @@ class Vanagon
120
120
  location = URI.parse(response.header['location'])
121
121
  download(uri + location, target_file)
122
122
  when Net::HTTPSuccess
123
- open(File.join(@workdir, target_file), 'w') do |io|
123
+ File.open(File.join(@workdir, target_file), 'w') do |io|
124
124
  response.read_body { |chunk| io.write(chunk) }
125
125
  end
126
126
  else
@@ -74,6 +74,16 @@ class Vanagon
74
74
  # @deprecated Please use the component DSL method #mirror(<URI>)
75
75
  # instead. This method will be removed before Vanagon 1.0.0.
76
76
  def parse_and_rewrite(uri)
77
+ return uri if rewrite_rules.empty?
78
+ if uri.match?(/^git:http/)
79
+ warn <<-HERE.undent
80
+ `fustigit` parsing doesn't get along with how we specify the source
81
+ type by prefixing `git`. As `rewrite_rules` are deprecated, we'll
82
+ replace `git:http` with `http` in your uri. At some point this will
83
+ break.
84
+ HERE
85
+ uri.sub!(/^git:http/, 'http')
86
+ end
77
87
  url = URI.parse(uri)
78
88
  return url unless url.scheme
79
89
  rewrite(url.to_s, url.scheme)
@@ -3,7 +3,7 @@ require 'json'
3
3
 
4
4
  module SetJson
5
5
  def to_json(*options)
6
- to_a.to_json *options
6
+ to_a.to_json(*options)
7
7
  end
8
8
  end
9
9
 
@@ -72,11 +72,11 @@ class Vanagon
72
72
  def add_repo_target(definition)
73
73
  if File.extname(definition.path) == '.deb'
74
74
  # repo definition is an deb (like puppetlabs-release)
75
- "curl -o local.deb '#{definition}' && dpkg -i local.deb; rm -f local.deb"
75
+ "#{@curl} -o local.deb '#{definition}' && dpkg -i local.deb; rm -f local.deb"
76
76
  else
77
77
  reponame = "#{SecureRandom.hex}-#{File.basename(definition.path)}"
78
78
  reponame = "#{reponame}.list" if File.extname(reponame) != '.list'
79
- "curl -o '/etc/apt/sources.list.d/#{reponame}' '#{definition}'"
79
+ "#{@curl} -o '/etc/apt/sources.list.d/#{reponame}' '#{definition}'"
80
80
  end
81
81
  end
82
82
 
@@ -87,7 +87,7 @@ class Vanagon
87
87
  def add_gpg_key(gpg_key)
88
88
  gpgname = "#{SecureRandom.hex}-#{File.basename(gpg_key.path)}"
89
89
  gpgname = "#{gpgname}.gpg" if gpgname !~ /\.gpg$/
90
- "curl -o '/etc/apt/trusted.gpg.d/#{gpgname}' '#{gpg_key}'"
90
+ "#{@curl} -o '/etc/apt/trusted.gpg.d/#{gpgname}' '#{gpg_key}'"
91
91
  end
92
92
 
93
93
  # Returns the commands to add a given repo target and optionally a gpg key to the build system
@@ -140,6 +140,7 @@ class Vanagon
140
140
  @tar = "tar"
141
141
  @patch = "/usr/bin/patch"
142
142
  @num_cores = "/usr/bin/nproc"
143
+ @curl = "curl --silent --show-error --fail"
143
144
  @valid_operators = ['<', '>', '<=', '>=', '=', '<<', '>>']
144
145
  super(name)
145
146
  end
@@ -412,6 +412,14 @@ class Vanagon
412
412
  def add_build_repository(*args)
413
413
  @platform.add_build_repository(*args)
414
414
  end
415
+
416
+ def setting(name, value)
417
+ @platform.settings[name] = value
418
+ end
419
+
420
+ def settings
421
+ @platform.settings
422
+ end
415
423
  end
416
424
  end
417
425
  end
@@ -21,7 +21,7 @@ class Vanagon
21
21
  if definition.scheme =~ /^(http|ftp)/
22
22
  if File.extname(definition.path) == '.rpm'
23
23
  # repo definition is an rpm (like puppetlabs-release)
24
- commands << "curl -o local.rpm '#{definition}'; rpm -Uvh local.rpm; rm -f local.rpm"
24
+ commands << "curl --silent --show-error --fail -o local.rpm '#{definition}'; rpm -Uvh local.rpm; rm -f local.rpm"
25
25
  else
26
26
  commands << "yes | zypper -n --no-gpg-checks #{flag} -t YUM --repo '#{definition}'"
27
27
  end
@@ -68,14 +68,14 @@ class Vanagon
68
68
  if definition.scheme =~ /^(http|ftp)/
69
69
  if File.extname(definition.path) == '.rpm'
70
70
  # repo definition is an rpm (like puppetlabs-release)
71
- commands << "curl -o local.rpm '#{definition}'; rpm -Uvh local.rpm; rm -f local.rpm"
71
+ commands << "#{@curl} -o local.rpm '#{definition}'; rpm -Uvh local.rpm; rm -f local.rpm"
72
72
  else
73
73
  reponame = "#{SecureRandom.hex}-#{File.basename(definition.path)}"
74
74
  reponame = "#{reponame}.repo" if File.extname(reponame) != '.repo'
75
75
  if is_cisco_wrlinux?
76
- commands << "curl -o '/etc/yum/repos.d/#{reponame}' '#{definition}'"
76
+ commands << "#{@curl} -o '/etc/yum/repos.d/#{reponame}' '#{definition}'"
77
77
  else
78
- commands << "curl -o '/etc/yum.repos.d/#{reponame}' '#{definition}'"
78
+ commands << "#{@curl} -o '/etc/yum.repos.d/#{reponame}' '#{definition}'"
79
79
  end
80
80
  end
81
81
  end
@@ -103,6 +103,7 @@ class Vanagon
103
103
  @patch ||= "/usr/bin/patch"
104
104
  @num_cores ||= "/bin/grep -c 'processor' /proc/cpuinfo"
105
105
  @rpmbuild ||= "/usr/bin/rpmbuild"
106
+ @curl = "curl --silent --show-error --fail"
106
107
  super(name)
107
108
  end
108
109
  end
@@ -156,7 +156,7 @@ class Vanagon
156
156
  if build_dependency =~ /^http.*\.gz/
157
157
  # Fetch, unpack, install...this assumes curl is present.
158
158
  package = build_dependency.sub(/^http.*\//, '')
159
- http << "tmpdir=$(#{mktemp}); (cd ${tmpdir} && curl -O #{build_dependency} && gunzip -c #{package} | pkgadd -d /dev/stdin -a /var/tmp/noask all)"
159
+ http << "tmpdir=$(#{mktemp}); (cd ${tmpdir} && curl --silent --show-error --fail -O #{build_dependency} && gunzip -c #{package} | pkgadd -d /dev/stdin -a /var/tmp/noask all)"
160
160
  else
161
161
  # Opencsw dependencies. At this point we assume that pkgutil is installed.
162
162
  pkgutil << build_dependency
@@ -199,5 +199,3 @@ class Vanagon
199
199
  end
200
200
  end
201
201
  end
202
-
203
-
@@ -135,9 +135,9 @@ class Vanagon
135
135
  # Platform names currently contain some information about the platform. Fields
136
136
  # within the name are delimited by the '-' character, and this regex can be used to
137
137
  # extract those fields.
138
- PLATFORM_REGEX = /^(.*)-(.*)-(.*)$/
138
+ PLATFORM_REGEX = /^(.*)-(.*)-(.*)$/.freeze
139
139
 
140
- VERSION_REGEX = /^([=<>]+)\s*([^<>=]*)$/
140
+ VERSION_REGEX = /^([=<>]+)\s*([^<>=]*)$/.freeze
141
141
 
142
142
  # Loads a given platform from the configdir
143
143
  #
@@ -220,6 +220,7 @@ class Vanagon
220
220
  # @return [Vanagon::Platform] the platform with the given name
221
221
  def initialize(name) # rubocop:disable Metrics/AbcSize
222
222
  @name = name
223
+ @settings = {}
223
224
  @os_name = os_name
224
225
  @os_version = os_version
225
226
  @architecture = architecture
@@ -344,6 +345,20 @@ class Vanagon
344
345
  return !!@name.match(/^fedora-.*$/)
345
346
  end
346
347
 
348
+ # Utility matcher to determine is the platform is a debian variety
349
+ #
350
+ # @return [true, false] true if it is a debian variety, false otherwise
351
+ def is_debian?
352
+ return !!@name.match(/^debian-.*$/)
353
+ end
354
+
355
+ # Utility matcher to determine is the platform is a ubuntu variety
356
+ #
357
+ # @return [true, false] true if it is a ubuntu variety, false otherwise
358
+ def is_ubuntu?
359
+ return !!@name.match(/^ubuntu-.*$/)
360
+ end
361
+
347
362
  # Utility matcher to determine is the platform is an aix variety
348
363
  #
349
364
  # @return [true, false] true if it is an aix variety, false otherwise
@@ -7,7 +7,7 @@ require 'digest'
7
7
  require 'ostruct'
8
8
 
9
9
  # Used to parse the vendor field into name and email
10
- VENDOR_REGEX = /^(.*) <(.*)>$/
10
+ VENDOR_REGEX = /^(.*) <(.*)>$/.freeze
11
11
 
12
12
  class Vanagon
13
13
  class Project
@@ -139,7 +139,7 @@ class Vanagon
139
139
  @components = []
140
140
  @requires = []
141
141
  @directories = []
142
- @settings = {}
142
+ @settings = platform.settings
143
143
  # Environments are like Hashes but with specific constraints
144
144
  # around their keys and values.
145
145
  @environment = Vanagon::Environment.new
@@ -756,7 +756,8 @@ class Vanagon
756
756
  # We don't want to load any of the upstream components, so we're going to
757
757
  # pass an array with an empty string as the component list for load_project
758
758
  no_components = ['']
759
- upstream_project = Vanagon::Project.load_project(upstream_project_name, File.join(working_directory, upstream_source.dirname, "configs", "projects"), platform, no_components)
759
+ upstream_platform = Vanagon::Platform.load_platform(platform.name, File.join(working_directory, upstream_source.dirname, "configs", "platforms"))
760
+ upstream_project = Vanagon::Project.load_project(upstream_project_name, File.join(working_directory, upstream_source.dirname, "configs", "projects"), upstream_platform, no_components)
760
761
  @settings.merge!(upstream_project.settings)
761
762
  upstream_project.cleanup
762
763
  end
@@ -34,9 +34,9 @@ class Vanagon
34
34
 
35
35
  # If Digest::const_get fails, it'll raise a LoadError when it tries to
36
36
  # pull in the subclass `type`. We catch that error, and fail instead.
37
- rescue LoadError
38
- fail "Don't know how to produce a sum of type: '#{type}' for '#{file}'"
39
- end
37
+ rescue LoadError
38
+ fail "Don't know how to produce a sum of type: '#{type}' for '#{file}'"
39
+ end
40
40
 
41
41
  # Simple wrapper around Net::HTTP. Will make a request of the given type to
42
42
  # the given url and return the body as parsed by JSON.
@@ -112,9 +112,12 @@ class Vanagon
112
112
  # @return [String, false] Returns either the full path to the command or false if the command cannot be found
113
113
  # @raise [RuntimeError] If the command is required and cannot be found
114
114
  def find_program_on_path(command, required = true)
115
+ extensions = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
115
116
  ENV['PATH'].split(File::PATH_SEPARATOR).each do |path_elem|
116
- location = File.join(path_elem, command)
117
- return location if FileTest.executable?(location)
117
+ extensions.each do |ext|
118
+ location = File.join(path_elem, "#{command}#{ext}")
119
+ return location if FileTest.executable?(location)
120
+ end
118
121
  end
119
122
 
120
123
  if required
@@ -14,7 +14,7 @@ end
14
14
 
15
15
  describe Vanagon::Component::Rules do
16
16
  let(:platform) do
17
- OpenStruct.new(:patch => "/usr/bin/patch", :make => '/usr/bin/make')
17
+ OpenStruct.new(:patch => "/usr/bin/patch", :make => '/usr/bin/make', :settings => {})
18
18
  end
19
19
 
20
20
  let(:project) do
@@ -33,14 +33,20 @@ describe 'Vanagon::Platform::DSL' do
33
33
  expect(SecureRandom).to receive(:hex).and_return(hex_value)
34
34
  plat.instance_eval(deb_platform_block)
35
35
  plat.apt_repo(apt_definition)
36
- expect(plat._platform.provisioning).to include("curl -o '/etc/apt/sources.list.d/#{hex_value}-pl-puppet-agent-0.2.1-wheezy.list' '#{apt_definition}'")
36
+ expect(plat._platform.provisioning[0]).to include('apt-get', 'install', 'curl')
37
+ expect(plat._platform.provisioning[1]).to include(
38
+ 'curl', '--silent', '--show-error', '--fail',
39
+ "-o '/etc/apt/sources.list.d/#{hex_value}-pl-puppet-agent-0.2.1-wheezy.list' '#{apt_definition}'")
37
40
  end
38
41
 
39
42
  it "installs a deb when given a deb" do
40
43
  plat = Vanagon::Platform::DSL.new('debian-test-fixture')
41
44
  plat.instance_eval(deb_platform_block)
42
45
  plat.apt_repo(apt_definition_deb)
43
- expect(plat._platform.provisioning).to include("curl -o local.deb '#{apt_definition_deb}' && dpkg -i local.deb; rm -f local.deb")
46
+ expect(plat._platform.provisioning[0]).to include('apt-get', 'install', 'curl')
47
+ expect(plat._platform.provisioning[1]).to include(
48
+ 'curl', '--silent', '--show-error', '--fail',
49
+ "-o local.deb '#{apt_definition_deb}' && dpkg -i local.deb; rm -f local.deb")
44
50
  end
45
51
 
46
52
  it "installs a gpg key if given one" do
@@ -48,7 +54,9 @@ describe 'Vanagon::Platform::DSL' do
48
54
  expect(SecureRandom).to receive(:hex).and_return(hex_value).twice
49
55
  plat.instance_eval(deb_platform_block)
50
56
  plat.apt_repo(apt_definition, apt_definition_gpg)
51
- expect(plat._platform.provisioning).to include("curl -o '/etc/apt/trusted.gpg.d/#{hex_value}-keyring.gpg' '#{apt_definition_gpg}'")
57
+ expect(plat._platform.provisioning[0]).to include('apt-get', 'install', 'curl')
58
+ expect(plat._platform.provisioning[1]).to include(
59
+ 'curl', '--silent', '--show-error', '--fail', "-o '/etc/apt", hex_value)
52
60
  end
53
61
  end
54
62
 
@@ -58,7 +66,10 @@ describe 'Vanagon::Platform::DSL' do
58
66
  expect(SecureRandom).to receive(:hex).and_return(hex_value)
59
67
  plat.instance_eval(el_5_platform_block)
60
68
  plat.yum_repo(el_definition)
61
- expect(plat._platform.provisioning).to include("curl -o '/etc/yum.repos.d/#{hex_value}-pl-puppet-agent-0.2.1-el-7-x86_64.repo' '#{el_definition}'")
69
+ expect(plat._platform.provisioning[0]).to include('rpm -q curl', 'yum -y install curl')
70
+ expect(plat._platform.provisioning[1]).to include(
71
+ 'curl', '--silent', '--show-error', '--fail',
72
+ "-o '/etc/yum.repos.d/#{hex_value}-pl-puppet-agent-0.2.1-el-7-x86_64.repo' '#{el_definition}'")
62
73
  end
63
74
 
64
75
  it "works for specifically redhat platforms" do
@@ -66,7 +77,10 @@ describe 'Vanagon::Platform::DSL' do
66
77
  expect(SecureRandom).to receive(:hex).and_return(hex_value)
67
78
  plat.instance_eval(redhat_7_platform_block)
68
79
  plat.yum_repo(el_definition)
69
- expect(plat._platform.provisioning).to include("curl -o '/etc/yum.repos.d/#{hex_value}-pl-puppet-agent-0.2.1-el-7-x86_64.repo' '#{el_definition}'")
80
+ expect(plat._platform.provisioning[0]).to include('rpm -q curl', 'yum -y install curl')
81
+ expect(plat._platform.provisioning[1]).to include(
82
+ 'curl','--silent', '--show-error', '--fail',
83
+ "-o '/etc/yum.repos.d/#{hex_value}-pl-puppet-agent-0.2.1-el-7-x86_64.repo' '#{el_definition}'")
70
84
  end
71
85
 
72
86
  # This test currently covers wrlinux 5 and 7
@@ -75,7 +89,10 @@ describe 'Vanagon::Platform::DSL' do
75
89
  expect(SecureRandom).to receive(:hex).and_return(hex_value)
76
90
  plat.instance_eval(cicso_wrlinux_platform_block)
77
91
  plat.yum_repo(cisco_wrlinux_definition)
78
- expect(plat._platform.provisioning).to include("curl -o '/etc/yum/repos.d/#{hex_value}-pl-puppet-agent-0.2.1-cisco-wrlinux-5-x86_64.repo' '#{cisco_wrlinux_definition}'")
92
+ expect(plat._platform.provisioning[0]).to include('rpm -q curl', 'yum -y install curl')
93
+ expect(plat._platform.provisioning[1]).to include(
94
+ 'curl','--silent', '--show-error', '--fail',
95
+ "-o '/etc/yum/repos.d/#{hex_value}-pl-puppet-agent-0.2.1-cisco-wrlinux-5-x86_64.repo' '#{cisco_wrlinux_definition}'")
79
96
  end
80
97
 
81
98
  describe "installs a rpm when given a rpm" do
@@ -83,8 +100,9 @@ describe 'Vanagon::Platform::DSL' do
83
100
  plat = Vanagon::Platform::DSL.new('el-5-fixture')
84
101
  plat.instance_eval(el_5_platform_block)
85
102
  plat.yum_repo(el_definition_rpm)
86
- expect(plat._platform.provisioning).to include("rpm -q curl > /dev/null || yum -y install curl")
87
- expect(plat._platform.provisioning).to include("curl -o local.rpm '#{el_definition_rpm}'; rpm -Uvh local.rpm; rm -f local.rpm")
103
+ expect(plat._platform.provisioning[0]).to include('rpm -q curl', 'yum -y install curl')
104
+ expect(plat._platform.provisioning[1]).to include(
105
+ 'curl', '--silent', '--show-error', '--fail', "-o local.rpm '#{el_definition_rpm}'; rpm -Uvh local.rpm; rm -f local.rpm")
88
106
  end
89
107
  end
90
108
  end
@@ -101,7 +119,9 @@ describe 'Vanagon::Platform::DSL' do
101
119
  plat = Vanagon::Platform::DSL.new('sles-test-fixture')
102
120
  plat.instance_eval(sles_platform_block)
103
121
  plat.zypper_repo(sles_definition_rpm)
104
- expect(plat._platform.provisioning).to include("curl -o local.rpm '#{sles_definition_rpm}'; rpm -Uvh local.rpm; rm -f local.rpm")
122
+ expect(plat._platform.provisioning[0]).to include(
123
+ 'curl', '--silent', '--show-error', '--fail',
124
+ "-o local.rpm '#{sles_definition_rpm}'; rpm -Uvh local.rpm; rm -f local.rpm")
105
125
  end
106
126
  end
107
127
 
@@ -31,6 +31,10 @@ describe "Vanagon::Platform::Windows" do
31
31
  },
32
32
  ]
33
33
 
34
+ let(:vanagon_platform) do
35
+ OpenStruct.new(:settings => {})
36
+ end
37
+
34
38
  platforms.each do |plat|
35
39
  context "on #{plat[:name]}" do
36
40
  let(:platform) { plat }
@@ -203,7 +207,7 @@ describe "Vanagon::Platform::Windows" do
203
207
  describe "generate_wix_dirs" do
204
208
 
205
209
  it "returns one directory with install_service defaults" do
206
- proj = Vanagon::Project::DSL.new('test-fixture', {}, [])
210
+ proj = Vanagon::Project::DSL.new('test-fixture', vanagon_platform, [])
207
211
  proj.instance_eval(project_block)
208
212
  cur_plat.instance_eval(plat[:block])
209
213
  comp = Vanagon::Component::DSL.new('service-test', {}, cur_plat._platform)
@@ -219,7 +223,7 @@ describe "Vanagon::Platform::Windows" do
219
223
  end
220
224
 
221
225
  it "returns one directory with non-default name" do
222
- proj = Vanagon::Project::DSL.new('test-fixture', {}, [])
226
+ proj = Vanagon::Project::DSL.new('test-fixture', vanagon_platform, [])
223
227
  proj.instance_eval(project_block)
224
228
  cur_plat.instance_eval(plat[:block])
225
229
  comp = Vanagon::Component::DSL.new('service-test', {}, cur_plat._platform)
@@ -235,7 +239,7 @@ describe "Vanagon::Platform::Windows" do
235
239
  end
236
240
 
237
241
  it "returns nested directory correctly with \\" do
238
- proj = Vanagon::Project::DSL.new('test-fixture', {}, [])
242
+ proj = Vanagon::Project::DSL.new('test-fixture', vanagon_platform, [])
239
243
  proj.instance_eval(project_block)
240
244
  cur_plat.instance_eval(plat[:block])
241
245
  comp = Vanagon::Component::DSL.new('service-test', {}, cur_plat._platform)
@@ -255,7 +259,7 @@ describe "Vanagon::Platform::Windows" do
255
259
 
256
260
 
257
261
  it "adds a second directory for the same input but different components" do
258
- proj = Vanagon::Project::DSL.new('test-fixture', {}, [])
262
+ proj = Vanagon::Project::DSL.new('test-fixture', vanagon_platform, [])
259
263
  proj.instance_eval(project_block)
260
264
  cur_plat.instance_eval(plat[:block])
261
265
  comp = Vanagon::Component::DSL.new('service-test', {}, cur_plat._platform)
@@ -274,7 +278,7 @@ describe "Vanagon::Platform::Windows" do
274
278
  end
275
279
 
276
280
  it "returns correctly formatted multiple nested directories" do
277
- proj = Vanagon::Project::DSL.new('test-fixture', {}, [])
281
+ proj = Vanagon::Project::DSL.new('test-fixture', vanagon_platform, [])
278
282
  proj.instance_eval(project_block)
279
283
  cur_plat.instance_eval(plat[:block])
280
284
  comp = Vanagon::Component::DSL.new('service-test-1', {}, cur_plat._platform)
@@ -8,11 +8,14 @@ describe 'Vanagon::Project::DSL' do
8
8
  "project 'test-fixture' do |proj|
9
9
  end" }
10
10
  let(:configdir) { '/a/b/c' }
11
+ let(:platform) do
12
+ OpenStruct.new(:settings => {})
13
+ end
11
14
 
12
15
  describe '#version_from_git' do
13
16
  it 'sets the version based on the git describe' do
14
17
  expect(Vanagon::Driver).to receive(:configdir).and_return(configdir)
15
- proj = Vanagon::Project::DSL.new('test-fixture', {})
18
+ proj = Vanagon::Project::DSL.new('test-fixture', platform)
16
19
  proj.instance_eval(project_block)
17
20
 
18
21
  # Lying is bad. You shouldn't lie. But sometimes when you're
@@ -35,7 +38,7 @@ end" }
35
38
  end
36
39
  it 'sets the version based on the git describe with multiple dashes' do
37
40
  expect(Vanagon::Driver).to receive(:configdir).and_return(configdir)
38
- proj = Vanagon::Project::DSL.new('test-fixture', {})
41
+ proj = Vanagon::Project::DSL.new('test-fixture', platform)
39
42
  proj.instance_eval(project_block)
40
43
 
41
44
  # See previous description of "indescribable cyclopean obelisk"
@@ -60,7 +63,7 @@ end" }
60
63
  log = double
61
64
  diff = double
62
65
  expect(Vanagon::Driver).to receive(:configdir).and_return(configdir)
63
- proj = Vanagon::Project::DSL.new('test-fixture', {})
66
+ proj = Vanagon::Project::DSL.new('test-fixture', platform)
64
67
  proj.instance_eval(project_block)
65
68
  repo = double("repo")
66
69
  expect(::Git)
@@ -91,7 +94,7 @@ end" }
91
94
  }
92
95
 
93
96
  expect(Vanagon::Driver).to receive(:configdir).exactly(branches.length).times.and_return(configdir)
94
- proj = Vanagon::Project::DSL.new('test-fixture', {})
97
+ proj = Vanagon::Project::DSL.new('test-fixture', platform)
95
98
  proj.instance_eval(project_block)
96
99
 
97
100
  branches.each do |branch, version|
@@ -116,7 +119,7 @@ end" }
116
119
  ]
117
120
 
118
121
  expect(Vanagon::Driver).to receive(:configdir).exactly(branches.length).times.and_return(configdir)
119
- proj = Vanagon::Project::DSL.new('test-fixture', {})
122
+ proj = Vanagon::Project::DSL.new('test-fixture', platform)
120
123
  proj.instance_eval(project_block)
121
124
 
122
125
  branches.each do |branch|
@@ -137,7 +140,7 @@ end" }
137
140
 
138
141
  describe '#directory' do
139
142
  it 'adds a directory to the list of directories' do
140
- proj = Vanagon::Project::DSL.new('test-fixture', {})
143
+ proj = Vanagon::Project::DSL.new('test-fixture', platform)
141
144
  proj.instance_eval(project_block)
142
145
  proj.directory('/a/b/c/d', mode: '0755')
143
146
  expect(proj._project.directories).to include(Vanagon::Common::Pathname.new('/a/b/c/d', mode: '0755'))
@@ -146,7 +149,7 @@ end" }
146
149
 
147
150
  describe '#user' do
148
151
  it 'sets a user for the project' do
149
- proj = Vanagon::Project::DSL.new('test-fixture', {})
152
+ proj = Vanagon::Project::DSL.new('test-fixture', platform)
150
153
  proj.instance_eval(project_block)
151
154
  proj.user('test-user')
152
155
  expect(proj._project.user).to eq(Vanagon::Common::User.new('test-user'))
@@ -155,7 +158,7 @@ end" }
155
158
 
156
159
  describe '#target_repo' do
157
160
  it 'sets the target_repo for the project' do
158
- proj = Vanagon::Project::DSL.new('test-fixture', {})
161
+ proj = Vanagon::Project::DSL.new('test-fixture', platform)
159
162
  proj.instance_eval(project_block)
160
163
  proj.target_repo "pc1"
161
164
  expect(proj._project.repo).to eq("pc1")
@@ -164,7 +167,7 @@ end" }
164
167
 
165
168
  describe '#noarch' do
166
169
  it 'sets noarch on the project to true' do
167
- proj = Vanagon::Project::DSL.new('test-fixture', {})
170
+ proj = Vanagon::Project::DSL.new('test-fixture', platform)
168
171
  proj.instance_eval(project_block)
169
172
  proj.noarch
170
173
  expect(proj._project.noarch).to eq(true)
@@ -173,20 +176,20 @@ end" }
173
176
 
174
177
  describe '#generate_source_artifacts' do
175
178
  it 'defaults to false' do
176
- proj = Vanagon::Project::DSL.new('test-fixture', {})
179
+ proj = Vanagon::Project::DSL.new('test-fixture', platform)
177
180
  proj.instance_eval(project_block)
178
181
  expect(proj._project.source_artifacts).to eq(false)
179
182
  end
180
183
 
181
184
  it 'sets source_artifacts to true' do
182
- proj = Vanagon::Project::DSL.new('test-fixture', {})
185
+ proj = Vanagon::Project::DSL.new('test-fixture', platform)
183
186
  proj.instance_eval(project_block)
184
187
  proj.generate_source_artifacts true
185
188
  expect(proj._project.source_artifacts).to eq(true)
186
189
  end
187
190
 
188
191
  it 'sets source_artifacts to false' do
189
- proj = Vanagon::Project::DSL.new('test-fixture', {})
192
+ proj = Vanagon::Project::DSL.new('test-fixture', platform)
190
193
  proj.instance_eval(project_block)
191
194
  proj.generate_source_artifacts false
192
195
  expect(proj._project.source_artifacts).to eq(false)
@@ -195,7 +198,7 @@ end" }
195
198
 
196
199
  describe '#identifier' do
197
200
  it 'sets the identifier for the project' do
198
- proj = Vanagon::Project::DSL.new('test-fixture', {})
201
+ proj = Vanagon::Project::DSL.new('test-fixture', platform)
199
202
  proj.instance_eval(project_block)
200
203
  proj.identifier "com.example"
201
204
  expect(proj._project.identifier).to eq("com.example")
@@ -204,14 +207,14 @@ end" }
204
207
 
205
208
  describe '#cleanup_during_build' do
206
209
  it 'sets @cleanup to true' do
207
- proj = Vanagon::Project::DSL.new('test-fixture', {})
210
+ proj = Vanagon::Project::DSL.new('test-fixture', platform)
208
211
  proj.instance_eval(project_block)
209
212
  proj.cleanup_during_build
210
213
  expect(proj._project.cleanup).to eq(true)
211
214
  end
212
215
 
213
216
  it 'defaults to nil' do
214
- proj = Vanagon::Project::DSL.new('test-fixture', {})
217
+ proj = Vanagon::Project::DSL.new('test-fixture', platform)
215
218
  proj.instance_eval(project_block)
216
219
  expect(proj._project.cleanup).to be_nil
217
220
  end
@@ -221,7 +224,7 @@ end" }
221
224
  let(:version_file) { '/opt/puppetlabs/puppet/VERSION' }
222
225
 
223
226
  it 'sets version_file for the project' do
224
- proj = Vanagon::Project::DSL.new('test-fixture', {})
227
+ proj = Vanagon::Project::DSL.new('test-fixture', platform)
225
228
  proj.instance_eval(project_block)
226
229
  proj.write_version_file(version_file)
227
230
  expect(proj._project.version_file.path).to eq(version_file)
@@ -230,14 +233,14 @@ end" }
230
233
 
231
234
  describe "#release" do
232
235
  it 'sets the release for the project' do
233
- proj = Vanagon::Project::DSL.new('test-fixture', {})
236
+ proj = Vanagon::Project::DSL.new('test-fixture', platform)
234
237
  proj.instance_eval(project_block)
235
238
  proj.release '12'
236
239
  expect(proj._project.release).to eq('12')
237
240
  end
238
241
 
239
242
  it 'defaults to 1' do
240
- proj = Vanagon::Project::DSL.new('test-fixture', {})
243
+ proj = Vanagon::Project::DSL.new('test-fixture', platform)
241
244
  proj.instance_eval(project_block)
242
245
  expect(proj._project.release).to eq('1')
243
246
  end
@@ -254,7 +257,7 @@ end" }
254
257
  end
255
258
 
256
259
  it 'adds the package provide to the list of provides' do
257
- proj = Vanagon::Project::DSL.new('test-fixture', {})
260
+ proj = Vanagon::Project::DSL.new('test-fixture', platform)
258
261
  proj.instance_eval(project_block)
259
262
  proj.provides('thing1')
260
263
  proj.provides('thing2')
@@ -337,7 +340,7 @@ end" }
337
340
  end
338
341
 
339
342
  it 'adds the package replacement to the list of replacements' do
340
- proj = Vanagon::Project::DSL.new('test-fixture', {})
343
+ proj = Vanagon::Project::DSL.new('test-fixture', platform)
341
344
  proj.instance_eval(project_block)
342
345
  proj.replaces('thing1')
343
346
  proj.replaces('thing2')
@@ -416,7 +419,7 @@ end" }
416
419
  end
417
420
 
418
421
  it 'adds the package conflict to the list of conflicts' do
419
- proj = Vanagon::Project::DSL.new('test-fixture', {})
422
+ proj = Vanagon::Project::DSL.new('test-fixture', platform)
420
423
  proj.instance_eval(project_block)
421
424
  proj.conflicts('thing1')
422
425
  proj.conflicts('thing2')
@@ -529,19 +532,19 @@ end"
529
532
  end
530
533
 
531
534
  it 'stores the component in the project if the included components set is empty' do
532
- proj = Vanagon::Project::DSL.new('test-fixture', {}, [])
535
+ proj = Vanagon::Project::DSL.new('test-fixture', platform, [])
533
536
  proj.instance_eval(project_block)
534
537
  expect(proj._project.components).to include(component)
535
538
  end
536
539
 
537
540
  it 'stores the component in the project if the component name is listed in the included components set' do
538
- proj = Vanagon::Project::DSL.new('test-fixture', {}, ['some-component'])
541
+ proj = Vanagon::Project::DSL.new('test-fixture', platform, ['some-component'])
539
542
  proj.instance_eval(project_block)
540
543
  expect(proj._project.components).to include(component)
541
544
  end
542
545
 
543
546
  it 'does not store the component if the included components set is not empty and does not include the component name' do
544
- proj = Vanagon::Project::DSL.new('test-fixture', {}, ['some-different-component'])
547
+ proj = Vanagon::Project::DSL.new('test-fixture', platform, ['some-different-component'])
545
548
  proj.instance_eval(project_block)
546
549
  expect(proj._project.components).to_not include(component)
547
550
  end
@@ -565,19 +568,19 @@ end"
565
568
  }
566
569
 
567
570
  it 'has an empty project.fetch_artifact when fetch_artifact is not called' do
568
- proj = Vanagon::Project::DSL.new('test-fixture', {}, [])
571
+ proj = Vanagon::Project::DSL.new('test-fixture', platform, [])
569
572
  proj.instance_eval(empty_project_block)
570
573
  expect(proj._project.artifacts_to_fetch).to eq([])
571
574
  end
572
575
 
573
576
  it 'Adds a path to project.fetch_artifact when fetch_artifact is called' do
574
- proj = Vanagon::Project::DSL.new('test-fixture', {}, [])
577
+ proj = Vanagon::Project::DSL.new('test-fixture', platform, [])
575
578
  proj.instance_eval(project_block)
576
579
  expect(proj._project.artifacts_to_fetch).to eq(['foo/bar/baz.file'])
577
580
  end
578
581
 
579
582
  it 'Adds multiple paths to project.fetch_artifact when fetch_artifact is called more than once' do
580
- proj = Vanagon::Project::DSL.new('test-fixture', {}, [])
583
+ proj = Vanagon::Project::DSL.new('test-fixture', platform, [])
581
584
  proj.instance_eval(project_block_multiple)
582
585
  expect(proj._project.artifacts_to_fetch).to eq(['foo/bar/baz.file', 'foo/foobar/foobarbaz.file'])
583
586
  end
@@ -600,19 +603,19 @@ end"
600
603
  }
601
604
 
602
605
  it 'has no_packaging set to false by default' do
603
- proj = Vanagon::Project::DSL.new('test-fixture', {}, [])
606
+ proj = Vanagon::Project::DSL.new('test-fixture', platform, [])
604
607
  proj.instance_eval(empty_project_block)
605
608
  expect(proj._project.no_packaging).to eq(false)
606
609
  end
607
610
 
608
611
  it 'sets no_packaging to true when proj.no_packaging true is called' do
609
- proj = Vanagon::Project::DSL.new('test-fixture', {}, [])
612
+ proj = Vanagon::Project::DSL.new('test-fixture', platform, [])
610
613
  proj.instance_eval(project_block)
611
614
  expect(proj._project.no_packaging).to eq(true)
612
615
  end
613
616
 
614
617
  it 'sets no_packaging to false when proj.no_packaging false is called' do
615
- proj = Vanagon::Project::DSL.new('test-fixture', {}, [])
618
+ proj = Vanagon::Project::DSL.new('test-fixture', platform, [])
616
619
  proj.instance_eval(project_block_false)
617
620
  expect(proj._project.no_packaging).to eq(false)
618
621
  end
@@ -6,6 +6,12 @@ require 'fakefs/spec_helpers'
6
6
  describe 'Vanagon::Project' do
7
7
  let(:component) { double(Vanagon::Component) }
8
8
  let(:configdir) { '/a/b/c' }
9
+ let(:platform) do
10
+ OpenStruct.new(:settings => {})
11
+ end
12
+ let(:upstream_platform) do
13
+ OpenStruct.new(:settings => {})
14
+ end
9
15
 
10
16
  let(:project_block) {
11
17
  "project 'test-fixture' do |proj|
@@ -46,16 +52,18 @@ describe 'Vanagon::Project' do
46
52
  end"
47
53
  }
48
54
 
49
- let (:dummy_platform_sysv) {
55
+ let (:dummy_platform_settings) {
50
56
  plat = Vanagon::Platform::DSL.new('debian-6-i386')
51
57
  plat.instance_eval("platform 'debian-6-i386' do |plat|
52
58
  plat.servicetype 'sysv'
53
59
  plat.servicedir '/etc/init.d'
54
60
  plat.defaultdir '/etc/default'
61
+ settings[:platform_test] = 'debian'
55
62
  end")
56
63
  plat._platform
57
64
  }
58
65
 
66
+
59
67
  describe '#vendor=' do
60
68
  dummy_platform = Vanagon::Platform.new('el-7-x86_64')
61
69
  good_vendor = 'Puppet Inc. <release@puppet.com>'
@@ -113,7 +121,7 @@ describe 'Vanagon::Project' do
113
121
  it 'returns only the highest level directories' do
114
122
  test_sets.each do |set|
115
123
  expect(component).to receive(:directories).and_return([])
116
- proj = Vanagon::Project::DSL.new('test-fixture', {}, [])
124
+ proj = Vanagon::Project::DSL.new('test-fixture', platform, [])
117
125
  proj.instance_eval(project_block)
118
126
  set[:directories].each {|dir| proj.directory dir }
119
127
  expect(proj._project.get_root_directories.sort).to eq(set[:results].sort)
@@ -130,37 +138,50 @@ describe 'Vanagon::Project' do
130
138
  expect(git_source).to receive(:fetch).and_return(true)
131
139
 
132
140
  # stubs for the upstream project
133
- upstream_proj = Vanagon::Project::DSL.new('upstream-test', {}, [])
141
+ upstream_proj = Vanagon::Project::DSL.new('upstream-test', upstream_platform, [])
134
142
  upstream_proj.instance_eval(upstream_project_block)
135
143
  expect(Vanagon::Project).to receive(:load_project).and_return(upstream_proj._project)
144
+ expect(Vanagon::Platform).to receive(:load_platform).and_return(upstream_platform)
136
145
  end
137
146
 
138
147
  it 'loads upstream settings' do
139
- inheriting_proj = Vanagon::Project::DSL.new('inheritance-test', {}, [])
148
+ inheriting_proj = Vanagon::Project::DSL.new('inheritance-test', platform, [])
140
149
  inheriting_proj.instance_eval(inheriting_project_block)
141
150
  expect(inheriting_proj._project.settings[:test]).to eq('upstream-test')
142
151
  end
143
152
 
144
153
  it 'overrides duplicate settings from before the load' do
145
- inheriting_proj = Vanagon::Project::DSL.new('inheritance-test', {}, [])
154
+ inheriting_proj = Vanagon::Project::DSL.new('inheritance-test', platform, [])
146
155
  inheriting_proj.instance_eval(preset_inheriting_project_block)
147
156
  expect(inheriting_proj._project.settings[:test]).to eq('upstream-test')
148
157
  end
149
158
 
150
159
  it 'lets you override settings after the load' do
151
- inheriting_proj = Vanagon::Project::DSL.new('inheritance-test', {}, [])
160
+ inheriting_proj = Vanagon::Project::DSL.new('inheritance-test', platform, [])
152
161
  inheriting_proj.instance_eval(postset_inheriting_project_block)
153
162
  expect(inheriting_proj._project.settings[:test]).to eq('inheritance-test')
154
163
  end
155
164
 
156
165
  it 'merges settings' do
157
- inheriting_proj = Vanagon::Project::DSL.new('inheritance-test', {}, [])
166
+ inheriting_proj = Vanagon::Project::DSL.new('inheritance-test', platform, [])
158
167
  inheriting_proj.instance_eval(inheriting_project_block_with_settings)
159
168
  expect(inheriting_proj._project.settings[:test]).to eq('upstream-test')
160
169
  expect(inheriting_proj._project.settings[:merged]).to eq('yup')
161
170
  end
162
171
  end
163
172
 
173
+ describe 'platform settings' do
174
+ before do
175
+ allow(Vanagon::Component).to receive(:load_component).with('some-component', any_args).and_return(component)
176
+ end
177
+
178
+ it 'loads settings set in platforms' do
179
+ settings_proj = Vanagon::Project::DSL.new('settings-test', dummy_platform_settings, [])
180
+ settings_proj.instance_eval(project_block)
181
+ expect(settings_proj._project.settings[:platform_test]).to eq('debian')
182
+ end
183
+ end
184
+
164
185
  describe "#load_yaml_settings" do
165
186
  subject(:project) do
166
187
  project = Vanagon::Project.new('yaml-inheritance-test', Vanagon::Platform.new('aix-7.2-ppc'))
@@ -237,7 +258,7 @@ describe 'Vanagon::Project' do
237
258
  # All of the following tests should be run with one project level
238
259
  # component that isn't included in the build_deps of another component
239
260
  before(:each) do
240
- @proj = Vanagon::Project.new('test-fixture-with-comps', {})
261
+ @proj = Vanagon::Project.new('test-fixture-with-comps', platform)
241
262
  @not_included_comp = Vanagon::Component.new('test-fixture-not-included', {}, {})
242
263
  @proj.components << @not_included_comp
243
264
  end
@@ -306,7 +327,7 @@ describe 'Vanagon::Project' do
306
327
 
307
328
  describe '#get_preinstall_actions' do
308
329
  it "Collects the preinstall actions for the specified package state" do
309
- proj = Vanagon::Project.new('action-test', {})
330
+ proj = Vanagon::Project.new('action-test', platform)
310
331
  proj.get_preinstall_actions('upgrade')
311
332
  proj.get_preinstall_actions('install')
312
333
  expect(proj.get_preinstall_actions('install')).to be_instance_of(String)
@@ -315,39 +336,39 @@ describe 'Vanagon::Project' do
315
336
 
316
337
  describe '#get_trigger_scripts' do
317
338
  it "Collects the install triggers for the project for the specified packing state" do
318
- proj = Vanagon::Project.new('action-test', {})
339
+ proj = Vanagon::Project.new('action-test', platform)
319
340
  expect(proj.get_trigger_scripts('install')).to eq({})
320
341
  expect(proj.get_trigger_scripts('upgrade')).to be_instance_of(Hash)
321
342
  end
322
343
  it 'fails with empty install trigger action' do
323
- proj = Vanagon::Project.new('action-test', {})
344
+ proj = Vanagon::Project.new('action-test', platform)
324
345
  expect { proj.get_trigger_scripts([]) }.to raise_error(Vanagon::Error)
325
346
  end
326
347
  it 'fails with incorrect install trigger action' do
327
- proj = Vanagon::Project.new('action-test', {})
348
+ proj = Vanagon::Project.new('action-test', platform)
328
349
  expect { proj.get_trigger_scripts('foo') }.to raise_error(Vanagon::Error)
329
350
  end
330
351
  end
331
352
 
332
353
  describe '#get_interest_triggers' do
333
354
  it "Collects the interest triggers for the project for the specified packaging state" do
334
- proj = Vanagon::Project.new('action-test', {})
355
+ proj = Vanagon::Project.new('action-test', platform)
335
356
  expect(proj.get_interest_triggers('install')).to eq([])
336
357
  expect(proj.get_interest_triggers('upgrade')).to be_instance_of(Array)
337
358
  end
338
359
  it 'fails with empty interest trigger action' do
339
- proj = Vanagon::Project.new('action-test', {})
360
+ proj = Vanagon::Project.new('action-test', platform)
340
361
  expect { proj.get_interest_triggers([]) }.to raise_error(Vanagon::Error)
341
362
  end
342
363
  it 'fails with incorrect interest trigger action' do
343
- proj = Vanagon::Project.new('action-test', {})
364
+ proj = Vanagon::Project.new('action-test', platform)
344
365
  expect { proj.get_interest_triggers('foo') }.to raise_error(Vanagon::Error)
345
366
  end
346
367
  end
347
368
 
348
369
  describe '#get_activate_triggers' do
349
370
  it "Collects the activate triggers for the project for the specified packaging state" do
350
- proj = Vanagon::Project.new('action-test', {})
371
+ proj = Vanagon::Project.new('action-test', platform)
351
372
  expect(proj.get_activate_triggers()).to be_instance_of(Array)
352
373
  expect(proj.get_activate_triggers()).to be_instance_of(Array)
353
374
  end
@@ -355,7 +376,7 @@ describe 'Vanagon::Project' do
355
376
 
356
377
  describe '#generate_dependencies_info' do
357
378
  before(:each) do
358
- @proj = Vanagon::Project.new('test-project', {})
379
+ @proj = Vanagon::Project.new('test-project', platform)
359
380
  end
360
381
 
361
382
  it "returns a hash of components and their versions" do
@@ -386,7 +407,7 @@ describe 'Vanagon::Project' do
386
407
  end
387
408
  end
388
409
 
389
- @proj = Vanagon::Project.new('test-project', {})
410
+ @proj = Vanagon::Project.new('test-project', platform)
390
411
  end
391
412
 
392
413
  it 'should generate a hash with the expected build metadata' do
@@ -546,12 +567,12 @@ describe 'Vanagon::Project' do
546
567
 
547
568
  describe '#get_rpm_ghost_files' do
548
569
  it 'returns an empty array when there are no ghost files' do
549
- proj = Vanagon::Project.new('test-ghost', {})
570
+ proj = Vanagon::Project.new('test-ghost', platform)
550
571
  expect(proj.get_rpm_ghost_files).to eq([])
551
572
  end
552
573
 
553
574
  it 'returns ghost files when some are set' do
554
- proj = Vanagon::Project.new('test-ghosts', {})
575
+ proj = Vanagon::Project.new('test-ghosts', platform)
555
576
  comp = Vanagon::Component.new('ghosts', {}, {})
556
577
  comp.add_rpm_ghost_file('ghost')
557
578
  proj.components << comp
@@ -44,6 +44,29 @@ describe "Vanagon::Utilities" do
44
44
 
45
45
  expect(Vanagon::Utilities.find_program_on_path(command, false)).to be(false)
46
46
  end
47
+
48
+ it 'finds commands with file extensions' do
49
+ # Set PATHEXT so we can test this outside of windows
50
+ orig_pathext = ENV['PATHEXT']
51
+ ENV['PATHEXT'] = '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.CPL'
52
+ extensions = ENV['PATHEXT'].split(';')
53
+
54
+ # take a random element from path for testing
55
+ test_path = ENV['PATH'].split(File::PATH_SEPARATOR).sample
56
+ expect(FileTest).to receive(:executable?).with(File.join(test_path, "#{command}.VBS")).and_return(true)
57
+
58
+ # have an `allow` for the negative cases so rspec doesn't fail with unexpected
59
+ # function calls
60
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path_elem|
61
+ allow(FileTest).to receive(:executable?).with(File.join(path_elem, command))
62
+ extensions.each do |ext|
63
+ allow(FileTest).to receive(:executable?).with(File.join(path_elem, "#{command}#{ext}"))
64
+ end
65
+ end
66
+
67
+ expect(Vanagon::Utilities.find_program_on_path(command)).to eq(File.join(test_path, "#{command}.VBS"))
68
+ ENV['PATHEXT'] = orig_pathext
69
+ end
47
70
  end
48
71
 
49
72
  describe '#local_command' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vanagon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.29
4
+ version: 0.15.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-25 00:00:00.000000000 Z
11
+ date: 2019-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git
@@ -253,7 +253,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
253
253
  requirements:
254
254
  - - "~>"
255
255
  - !ruby/object:Gem::Version
256
- version: '2.1'
256
+ version: '2.3'
257
257
  required_rubygems_version: !ruby/object:Gem::Requirement
258
258
  requirements:
259
259
  - - ">="
@@ -266,40 +266,40 @@ specification_version: 3
266
266
  summary: All of your packages will fit into this van with this one simple trick.
267
267
  test_files:
268
268
  - spec/lib/makefile_spec.rb
269
- - spec/lib/git/rev_list_spec.rb
270
- - spec/lib/vanagon/project_spec.rb
271
- - spec/lib/vanagon/common/pathname_spec.rb
272
- - spec/lib/vanagon/common/user_spec.rb
273
- - spec/lib/vanagon/engine/local_spec.rb
269
+ - spec/lib/vanagon/component/source/rewrite_spec.rb
270
+ - spec/lib/vanagon/component/source/http_spec.rb
271
+ - spec/lib/vanagon/component/source/local_spec.rb
272
+ - spec/lib/vanagon/component/source/git_spec.rb
273
+ - spec/lib/vanagon/component/dsl_spec.rb
274
+ - spec/lib/vanagon/component/rules_spec.rb
275
+ - spec/lib/vanagon/component/source_spec.rb
276
+ - spec/lib/vanagon/engine/hardware_spec.rb
274
277
  - spec/lib/vanagon/engine/base_spec.rb
275
- - spec/lib/vanagon/engine/ec2_spec.rb
276
278
  - spec/lib/vanagon/engine/always_be_scheduling_spec.rb
277
- - spec/lib/vanagon/engine/pooler_spec.rb
279
+ - spec/lib/vanagon/engine/local_spec.rb
278
280
  - spec/lib/vanagon/engine/docker_spec.rb
279
- - spec/lib/vanagon/engine/hardware_spec.rb
280
- - spec/lib/vanagon/utilities/shell_utilities_spec.rb
281
- - spec/lib/vanagon/optparse_spec.rb
282
- - spec/lib/vanagon/environment_spec.rb
281
+ - spec/lib/vanagon/engine/pooler_spec.rb
282
+ - spec/lib/vanagon/engine/ec2_spec.rb
283
283
  - spec/lib/vanagon/driver_spec.rb
284
+ - spec/lib/vanagon/platform_spec.rb
285
+ - spec/lib/vanagon/utilities/shell_utilities_spec.rb
286
+ - spec/lib/vanagon/project_spec.rb
287
+ - spec/lib/vanagon/common/user_spec.rb
288
+ - spec/lib/vanagon/common/pathname_spec.rb
289
+ - spec/lib/vanagon/project/dsl_spec.rb
284
290
  - spec/lib/vanagon/component_spec.rb
291
+ - spec/lib/vanagon/environment_spec.rb
285
292
  - spec/lib/vanagon/utilities_spec.rb
286
- - spec/lib/vanagon/project/dsl_spec.rb
287
- - spec/lib/vanagon/platform_spec.rb
288
- - spec/lib/vanagon/component/source_spec.rb
289
- - spec/lib/vanagon/component/dsl_spec.rb
290
- - spec/lib/vanagon/component/rules_spec.rb
291
- - spec/lib/vanagon/component/source/git_spec.rb
292
- - spec/lib/vanagon/component/source/local_spec.rb
293
- - spec/lib/vanagon/component/source/rewrite_spec.rb
294
- - spec/lib/vanagon/component/source/http_spec.rb
293
+ - spec/lib/vanagon/optparse_spec.rb
294
+ - spec/lib/vanagon/platform/windows_spec.rb
295
295
  - spec/lib/vanagon/platform/solaris_10_spec.rb
296
- - spec/lib/vanagon/platform/solaris_11_spec.rb
297
- - spec/lib/vanagon/platform/rpm/aix_spec.rb
298
296
  - spec/lib/vanagon/platform/dsl_spec.rb
297
+ - spec/lib/vanagon/platform/rpm_spec.rb
299
298
  - spec/lib/vanagon/platform/deb_spec.rb
300
- - spec/lib/vanagon/platform/windows_spec.rb
299
+ - spec/lib/vanagon/platform/rpm/aix_spec.rb
301
300
  - spec/lib/vanagon/platform/osx_spec.rb
302
- - spec/lib/vanagon/platform/rpm_spec.rb
301
+ - spec/lib/vanagon/platform/solaris_11_spec.rb
302
+ - spec/lib/vanagon/extensions/ostruct/json_spec.rb
303
303
  - spec/lib/vanagon/extensions/string_spec.rb
304
304
  - spec/lib/vanagon/extensions/set/json_spec.rb
305
- - spec/lib/vanagon/extensions/ostruct/json_spec.rb
305
+ - spec/lib/git/rev_list_spec.rb