vanagon 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- SHELL = $(PWD)/profiling_shell.sh
1
+ SHELL = <%= @platform.shell %>
2
2
 
3
3
  <%- merged_environment.to_a(" := ").each do |var| -%>
4
4
  export <%= var %>
@@ -9,7 +9,6 @@ workdir := $(PWD)
9
9
 
10
10
  all: file-list-before-build <%= package_name %>
11
11
 
12
- <%= package_name %>: export VANAGON_TARGET := create-package
13
12
  <%= package_name %>: <%= @name %>-<%= @version %>.tar.gz
14
13
  <%= generate_package.join("\n\t") %>
15
14
 
@@ -17,14 +16,14 @@ file-list-before-build:
17
16
  <%- if dirnames.empty? -%>
18
17
  touch file-list-before-build
19
18
  <%- else -%>
20
- (<%= @platform.find %> -L "<%= dirnames.join('" "') %>" 2>/dev/null || <%= @platform.find %> "<%= dirnames.join('" "') %>" -follow 2>/dev/null) | <%= "xargs -I[] cygpath --mixed --long-name --absolute [] |" if @platform.is_windows? %> <%= @platform.sort %> | uniq > file-list-before-build
19
+ (<%= @platform.find %> -H "<%= dirnames.join('" "') %>" 2>/dev/null || <%= @platform.find %> "<%= dirnames.join('" "') %>" 2>/dev/null) | <%= "xargs -I[] cygpath --mixed --long-name --absolute [] |" if @platform.is_windows? %> <%= @platform.sort %> | uniq > file-list-before-build
21
20
  <%- end -%>
22
21
 
23
22
  file-list-after-build: <%= @components.map {|comp| comp.name }.join(" ") %>
24
23
  <%- if dirnames.empty? -%>
25
24
  touch file-list-after-build
26
25
  <%- else -%>
27
- (<%= @platform.find %> -L "<%= dirnames.join('" "') %>" 2>/dev/null || <%= @platform.find %> "<%= dirnames.join('" "') %>" -follow 2>/dev/null) | <%= "xargs -I[] cygpath --mixed --long-name --absolute [] |" if @platform.is_windows? %> <%= @platform.sort %> | uniq > file-list-after-build
26
+ (<%= @platform.find %> -H "<%= dirnames.join('" "') %>" 2>/dev/null || <%= @platform.find %> "<%= dirnames.join('" "') %>" 2>/dev/null) | <%= "xargs -I[] cygpath --mixed --long-name --absolute [] |" if @platform.is_windows? %> <%= @platform.sort %> | uniq > file-list-after-build
28
27
  <%- end -%>
29
28
 
30
29
  <%= @name %>-<%= @version %>.tar.gz: file-list <%= @cleanup ? 'cleanup-components' : '' %>
@@ -2,6 +2,10 @@
2
2
  # Uncomment this to turn on verbose mode.
3
3
  #export DH_VERBOSE=1
4
4
 
5
+ <% @package_overrides.each do |var| %>
6
+ <%= var %>
7
+ <% end -%>
8
+
5
9
  override_dh_auto_install:
6
10
  install -d debian/tmp
7
11
  # Copy each directory into place
@@ -25,6 +25,10 @@
25
25
  %global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-strip-static-archive[[:space:]].*$!!g')
26
26
  <% end -%>
27
27
 
28
+ <% @package_overrides.each do |var| %>
29
+ <%= var %>
30
+ <% end -%>
31
+
28
32
  Name: <%= @name %>
29
33
  Version: <%= @version %>
30
34
  Release: <%= @release %>%{?dist}
@@ -48,15 +52,22 @@ Autoreq: 0
48
52
  <%- get_requires.each do |requires| -%>
49
53
  Requires: <%= requires %>
50
54
  <%- end -%>
55
+
51
56
  # All rpm packages built by vanagon have the pre-/post-install script
52
57
  # boilerplates (defined below). These require `mkdir` and `touch` but previously
53
58
  # did not specify a dependency on these.
54
59
  # In the future, we will supress pre/post scripts completely if there's nothing
55
60
  # specified by the project or the components.
61
+ <%- if @platform.is_aix? -%>
62
+ Requires: /bin/mkdir
63
+ Requires: /bin/touch
64
+ <%- else -%>
56
65
  Requires(pre): /bin/mkdir
57
66
  Requires(pre): /bin/touch
58
67
  Requires(post): /bin/mkdir
59
68
  Requires(post): /bin/touch
69
+ <%- end -%>
70
+
60
71
  <%- if has_services? -%>
61
72
  <%- if @platform.servicetype == "systemd" -%>
62
73
  <%- if @platform.is_sles? -%>
@@ -142,7 +153,7 @@ install -d %{buildroot}
142
153
 
143
154
  # Here we turn all dirs in the file-list into %dir entries to avoid duplicate files
144
155
  for entry in `cat %{SOURCE1}`; do
145
- if [ -n "$entry" -a -d "$entry" ]; then
156
+ if [ -n "$entry" -a -d "$entry" -a ! -L "$entry" ]; then
146
157
  PATH=/opt/freeware/bin:$PATH sed -i "s|^\($entry\)\$|%dir \1|g" %{SOURCE1}
147
158
  fi
148
159
  done
@@ -7,8 +7,8 @@
7
7
  <authors><%= @vendor.match(/^(.*) <.*>$/)[1] %></authors>
8
8
  <owners><%= @vendor.match(/^(.*) <.*>$/)[1] %></owners>
9
9
  <projectUrl><%= @homepage %></projectUrl>
10
- <packageSourceUrl><%= "https://github.com/puppetlabs/#{project}-vanagon" %></packageSourceUrl>
11
- <projectSourceUrl><%= "https://github.com/puppetlabs/#{project}" %></projectSourceUrl>
10
+ <packageSourceUrl><%= @homepage %></packageSourceUrl>
11
+ <projectSourceUrl><%= @homepage %></projectSourceUrl>
12
12
  <docsUrl><%= @homepage %></docsUrl>
13
13
  <mailingListUrl><%= @homepage %></mailingListUrl>
14
14
  <bugTrackerUrl><%= @homepage %></bugTrackerUrl>
@@ -5,7 +5,7 @@ describe Makefile::Rule do
5
5
  subject { described_class.new("empty") }
6
6
 
7
7
  it "creates an empty rule" do
8
- expect(subject.format).to eq "empty: export VANAGON_TARGET := empty\nempty:\n"
8
+ expect(subject.format).to eq "empty:\n"
9
9
  end
10
10
  end
11
11
 
@@ -13,7 +13,7 @@ describe Makefile::Rule do
13
13
  subject { described_class.new("simple", recipe: ["touch simple"]) }
14
14
 
15
15
  it "creates the rule with the recipe" do
16
- expect(subject.format).to eq "simple: export VANAGON_TARGET := simple\nsimple:\n\ttouch simple\n"
16
+ expect(subject.format).to eq "simple:\n\ttouch simple\n"
17
17
  end
18
18
  end
19
19
 
@@ -21,7 +21,7 @@ describe Makefile::Rule do
21
21
  subject { described_class.new("depends", dependencies: ["mydeps"]) }
22
22
 
23
23
  it "creates the rule with the recipe" do
24
- expect(subject.format).to eq "depends: export VANAGON_TARGET := depends\ndepends: mydeps\n"
24
+ expect(subject.format).to eq "depends: mydeps\n"
25
25
  end
26
26
  end
27
27
 
@@ -29,7 +29,7 @@ describe Makefile::Rule do
29
29
  subject { described_class.new("deluxe", recipe: ["touch deluxe"], dependencies: ["mydeps"]) }
30
30
 
31
31
  it "creates the rule with the recipe" do
32
- expect(subject.format).to eq "deluxe: export VANAGON_TARGET := deluxe\ndeluxe: mydeps\n\ttouch deluxe\n"
32
+ expect(subject.format).to eq "deluxe: mydeps\n\ttouch deluxe\n"
33
33
  end
34
34
  end
35
35
 
@@ -44,7 +44,7 @@ describe Makefile::Rule do
44
44
  end
45
45
 
46
46
  it "inserts tabs after each newline in the recipe" do
47
- expect(subject.format).to eq "multiline: export VANAGON_TARGET := multiline\nmultiline:\n\t[ -d build ] || mkdir -p build\n\tcd build &&\n\tcmake .. &&\n\tmake &&\n\tmake install\n"
47
+ expect(subject.format).to eq "multiline:\n\t[ -d build ] || mkdir -p build\n\tcd build &&\n\tcmake .. &&\n\tmake &&\n\tmake install\n"
48
48
  end
49
49
  end
50
50
  end
@@ -587,7 +587,14 @@ end" }
587
587
  it 'adds the file to the configfiles list' do
588
588
  comp = Vanagon::Component::DSL.new('install-config-file-test', {}, platform)
589
589
  comp.install_configfile('thing1', 'place/to/put/thing1')
590
- expect(comp._component.configfiles).to include(Vanagon::Common::Pathname.configfile('place/to/put/thing1'))
590
+ expect(comp._component.configfiles).to include(Vanagon::Common::Pathname.configfile('place/to/put/thing1', mode: '0644'))
591
+ expect(comp._component.files).not_to include(Vanagon::Common::Pathname.file('place/to/put/thing1'))
592
+ end
593
+
594
+ it 'sets owner, group, and mode for the configfiles' do
595
+ comp = Vanagon::Component::DSL.new('install-config-file-test', {}, platform)
596
+ comp.install_configfile('thing1', 'place/to/put/thing1', owner: 'bob', group: 'timmy', mode: '0022')
597
+ expect(comp._component.configfiles).to include(Vanagon::Common::Pathname.configfile('place/to/put/thing1', mode: '0022', group: 'timmy', owner: 'bob'))
591
598
  expect(comp._component.files).not_to include(Vanagon::Common::Pathname.file('place/to/put/thing1'))
592
599
  end
593
600
  end
@@ -617,7 +624,7 @@ end" }
617
624
  it 'adds the file to the configfiles list' do
618
625
  comp = Vanagon::Component::DSL.new('install-config-file-test', {}, platform)
619
626
  comp.install_configfile('thing1', 'place/to/put/thing1')
620
- expect(comp._component.configfiles).to include(Vanagon::Common::Pathname.configfile('place/to/put/thing1.pristine'))
627
+ expect(comp._component.configfiles).to include(Vanagon::Common::Pathname.configfile('place/to/put/thing1.pristine', mode: '0644'))
621
628
  expect(comp._component.configfiles).not_to include(Vanagon::Common::Pathname.file('place/to/put/thing1'))
622
629
  end
623
630
  end
@@ -48,10 +48,10 @@ describe Vanagon::Component::Rules do
48
48
 
49
49
  it "sets environment variables before running the unpack steps" do
50
50
  component.extract_with = "/usr/bin/tar"
51
- component.environment = {"PATH" => "/opt/pl-build-tools/bin:$$PATH"}
52
- expect(rule.recipe.first).to eq(
53
- [ "/usr/bin/tar" ].join(" && ")
54
- )
51
+ component.environment.merge({"PATH" => "/opt/pl-build-tools/bin:$(PATH)"})
52
+
53
+ expect(rule.recipe.first)
54
+ .to eq %(export PATH="/opt/pl-build-tools/bin:$(PATH)" && \\\n/usr/bin/tar)
55
55
  end
56
56
 
57
57
  it_behaves_like "a rule that touches the target file"
@@ -113,9 +113,10 @@ describe Vanagon::Component::Rules do
113
113
 
114
114
  it "sets environment variables before running the configure steps" do
115
115
  component.configure = ["./configure", "cmake .."]
116
- component.environment = {"PATH" => "/opt/pl-build-tools/bin:$$PATH"}
116
+ component.environment.merge({"PATH" => "/opt/pl-build-tools/bin:$(PATH)"})
117
117
  expect(rule.recipe[1]).to eq(
118
118
  [
119
+ 'export PATH="/opt/pl-build-tools/bin:$(PATH)"',
119
120
  "cd /foo/bar",
120
121
  "./configure",
121
122
  "cmake .."
@@ -148,9 +149,10 @@ describe Vanagon::Component::Rules do
148
149
 
149
150
  it "sets environment variables before running the build steps" do
150
151
  component.build = ["make", "make test"]
151
- component.environment = {"PATH" => "/opt/pl-build-tools/bin:$$PATH"}
152
+ component.environment.merge({"PATH" => "/opt/pl-build-tools/bin:$(PATH)"})
152
153
  expect(rule.recipe.first).to eq(
153
154
  [
155
+ 'export PATH="/opt/pl-build-tools/bin:$(PATH)"',
154
156
  "cd /foo/bar",
155
157
  "make",
156
158
  "make test"
@@ -189,9 +191,10 @@ describe Vanagon::Component::Rules do
189
191
 
190
192
  it "sets environment variables before running the check steps" do
191
193
  component.check = ["make cpplint", "make test"]
192
- component.environment = {"PATH" => "/opt/pl-build-tools/bin:$$PATH"}
194
+ component.environment.merge({"PATH" => "/opt/pl-build-tools/bin:$(PATH)"})
193
195
  expect(rule.recipe.first).to eq(
194
196
  [
197
+ 'export PATH="/opt/pl-build-tools/bin:$(PATH)"',
195
198
  "cd /foo/bar",
196
199
  "make cpplint",
197
200
  "make test"
@@ -224,9 +227,10 @@ describe Vanagon::Component::Rules do
224
227
 
225
228
  it "sets environment variables before running the install steps" do
226
229
  component.install = ["make install", "make reallyinstall"]
227
- component.environment = {"PATH" => "/opt/pl-build-tools/bin:$$PATH"}
230
+ component.environment.merge({"PATH" => "/opt/pl-build-tools/bin:$(PATH)"})
228
231
  expect(rule.recipe.first).to eq(
229
232
  [
233
+ 'export PATH="/opt/pl-build-tools/bin:$(PATH)"',
230
234
  "cd /foo/bar",
231
235
  "make install",
232
236
  "make reallyinstall"
@@ -5,7 +5,7 @@ describe "Vanagon::Component::Source::Git" do
5
5
  let(:url) { 'git://github.com/puppetlabs/facter' }
6
6
  let(:ref_tag) { 'refs/tags/2.2.0' }
7
7
  let(:bad_sha) { 'FEEDBEEF' }
8
- let(:workdir) { ENV["TMPDIR"] || "/tmp" }
8
+ let(:workdir) { ENV["TMPDIR"] || '/tmp' }
9
9
 
10
10
  after(:each) { %x(rm -rf #{workdir}/facter) }
11
11
 
@@ -1,25 +1,29 @@
1
1
  require 'vanagon/component'
2
+ require 'vanagon/platform'
2
3
 
3
4
  describe "Vanagon::Component" do
4
5
  describe "#get_environment" do
5
6
  subject { Vanagon::Component.new('env-test', {}, {}) }
6
7
 
7
- it "prints a deprecation warning to STDERR" do
8
+ it "prints a deprecation warning to STDERR" do
8
9
  expect { subject.get_environment }.to output(/deprecated/).to_stderr
9
10
  end
10
11
 
11
12
  it "returns a makefile compatible environment" do
12
- subject.environment = {'PATH' => '/usr/local/bin'}
13
- expect(subject.get_environment).to eq %(export PATH="/usr/local/bin")
13
+ subject.environment = {'PATH' => '/usr/local/bin', 'CFLAGS' => '-O3'}
14
+ expect(subject.get_environment)
15
+ .to eq [%(export PATH="/usr/local/bin"), %(export CFLAGS="-O3")]
14
16
  end
15
17
 
16
18
  it 'merges against the existing environment' do
17
19
  subject.environment = {'PATH' => '/usr/bin', 'CFLAGS' => '-I /usr/local/bin'}
18
- expect(subject.get_environment).to eq %(export PATH="/usr/bin" CFLAGS="-I /usr/local/bin")
20
+ expect(subject.get_environment)
21
+ .to eq [%(export PATH="/usr/bin"), %(export CFLAGS="-I /usr/local/bin")]
19
22
  end
20
23
 
21
24
  it 'returns : for an empty environment' do
22
- expect(subject.get_environment).to eq %(: no environment variables defined)
25
+ expect(subject.get_environment)
26
+ .to eq %(: no environment variables defined)
23
27
  end
24
28
  end
25
29
 
@@ -45,20 +49,44 @@ describe "Vanagon::Component" do
45
49
  @workdir = Dir.mktmpdir
46
50
  @file_name = 'fake_file.txt'
47
51
  @fake_file = "file://spec/fixtures/files/#{@file_name}"
52
+ @fake_dir = 'fake_dir'
53
+ @fake_tar = "file://spec/fixtures/files/#{@fake_dir}.tar.gz"
48
54
  end
49
55
 
50
56
  subject do
51
57
  # Initialize a new instance of Vanagon::Component and define a
52
- # new secondary source. We can now reason about this instance and
53
- # test behavior for retrieving secondary sources.
58
+ # new secondary source that's *uncompressed*. We can now reason about
59
+ # this instance and test behavior for retrieving secondary sources.
54
60
  Vanagon::Component.new('build-dir-test', {}, {}).tap do |comp|
55
61
  comp.sources << OpenStruct.new(url: @fake_file)
56
62
  end
63
+ end
64
+
65
+ it "copies uncompressed secondary sources into the workdir" do
66
+ subject.get_sources(@workdir)
67
+ expect(File.exist?(File.join(@workdir, @file_name))).to be true
68
+ end
69
+
70
+ subject do
71
+ # Initialize a new instance of Vanagon::Component and define a
72
+ # new secondary source that's *compressed*. We can now reason about
73
+ # this instance and test behavior for retrieving secondary sources.
74
+ plat = Vanagon::Platform::DSL.new('el-5-x86_64')
75
+ plat.instance_eval("platform 'el-5-x86_64' do |plat| end")
76
+ @platform = plat._platform
77
+
78
+ comp = Vanagon::Component::DSL.new('build-dir-test', {}, @platform)
79
+ comp.add_source @fake_file
80
+ comp.add_source @fake_tar
81
+ comp._component
57
82
  end
58
83
 
59
- it "copies secondary sources into the workdir" do
84
+ it "copies compressed secondary sources into the workdir" do
60
85
  subject.get_sources(@workdir)
61
86
  expect(File.exist?(File.join(@workdir, @file_name))).to be true
87
+ # make sure that our secondary source(s) made it into the workdir
88
+ expect(File.exist?(File.join(@workdir, "#{@fake_dir}.tar.gz"))).to be true
89
+ expect(subject.extract_with.join(" && ")).to match "#{@fake_dir}.tar.gz"
62
90
  end
63
91
  end
64
92
  end
@@ -30,7 +30,7 @@ describe 'Vanagon::Driver' do
30
30
  end
31
31
 
32
32
  describe 'when resolving build host info' do
33
- it 'uses an expicitly specified workdir if provided' do
33
+ it 'uses an explicitly specified workdir if provided' do
34
34
  derived = create_driver(redhat)
35
35
  explicit = create_driver(redhat, workdir: explicit_workdir)
36
36
 
@@ -38,9 +38,9 @@ describe 'Vanagon::Driver' do
38
38
  expect(explicit.workdir).not_to eq(derived.workdir)
39
39
  end
40
40
 
41
- it 'uses an expicitly specified remote workdir if provided' do
41
+ it 'uses an explicitly specified remote workdir if provided' do
42
42
  derived = create_driver(redhat)
43
- explicit = create_driver(redhat, remote_workdir: explicit_remote_workdir)
43
+ explicit = create_driver(redhat, :"remote-workdir" => explicit_remote_workdir)
44
44
 
45
45
  expect(explicit.remote_workdir).to eq(explicit_remote_workdir)
46
46
  expect(explicit.remote_workdir).not_to eq(derived.remote_workdir)
@@ -4,26 +4,20 @@ describe "Vanagon::Environment" do
4
4
  before :all do
5
5
  @good_names = %w(name _name NAME _NAME NAME123 _123NAME)
6
6
  @bad_names = ['no-name', '!name', '.name', '123name_', 1, '-name']
7
+
8
+ # All environment variables will be cast to Strings, regardless
9
+ # of whether or not they were Integers or Strings on the way in.
10
+
7
11
  @good_values =[
8
12
  'valuable',
9
13
  'most\ valuable',
10
14
  'extremely-valuable',
11
15
  'VALUE_BEYOND_MEASURE',
12
- 2004,
13
- 2007,
14
- ]
15
- @bad_values = [
16
- %w(an array of strings),
17
- 19.81,
18
- Object.new,
19
- Tempfile.new('captain_planet'),
20
- lambda { |x| "#{x}" }
16
+ '2004',
17
+ '2007',
21
18
  ]
22
19
 
23
- @good_hash = @good_names.zip(@good_values.shuffle).to_h
24
- @bad_hash = @bad_names.zip(@bad_values.shuffle).to_h
25
-
26
- @good_names_bad_values = @good_names.zip(@bad_values.shuffle).to_h
20
+ @good_names_good_values = @good_names.zip(@good_values.shuffle).to_h
27
21
  @bad_names_good_values = @bad_names.zip(@good_values.shuffle).to_h
28
22
  end
29
23
 
@@ -46,7 +40,7 @@ describe "Vanagon::Environment" do
46
40
 
47
41
  describe "#[]=" do
48
42
  it "accepts and assigns valid keys and values" do
49
- @good_hash.each_pair do |key, value|
43
+ @good_names_good_values.each_pair do |key, value|
50
44
  expect { @local_env[key] = value }
51
45
  .to_not raise_error
52
46
  end
@@ -58,18 +52,11 @@ describe "Vanagon::Environment" do
58
52
  .to raise_error(ArgumentError)
59
53
  end
60
54
  end
61
-
62
- it "raises an ArgumentError for invalid values" do
63
- @good_names_bad_values.each_pair do |key, value|
64
- expect { @local_env[key] = value }
65
- .to raise_error(ArgumentError)
66
- end
67
- end
68
55
  end
69
56
 
70
57
  describe "#keys" do
71
58
  before do
72
- @good_hash.each_pair do |key, value|
59
+ @good_names_good_values.each_pair do |key, value|
73
60
  @local_env[key] = value
74
61
  end
75
62
  end
@@ -89,7 +76,7 @@ describe "Vanagon::Environment" do
89
76
 
90
77
  describe "#values" do
91
78
  before do
92
- @good_hash.each_pair do |key, value|
79
+ @good_names_good_values.each_pair do |key, value|
93
80
  @local_env[key] = value
94
81
  end
95
82
  end
@@ -1,6 +1,7 @@
1
1
  require 'vanagon/project/dsl'
2
2
  require 'vanagon/driver'
3
3
  require 'vanagon/common'
4
+ require 'vanagon/platform'
4
5
 
5
6
  describe 'Vanagon::Project::DSL' do
6
7
  let (:project_block) {
@@ -52,6 +53,59 @@ end" }
52
53
  end
53
54
  end
54
55
 
56
+ describe '#version_from_branch' do
57
+ it 'parses out versions from branch names' do
58
+ branches = {
59
+ 'maint/3.8.x/fix-bugs' => '3.8',
60
+ '2017.1.2.3-prep' => '2017.1.2.3',
61
+ '3.8' => '3.8',
62
+ }
63
+
64
+ expect(Vanagon::Driver).to receive(:configdir).exactly(branches.length).times.and_return(configdir)
65
+ proj = Vanagon::Project::DSL.new('test-fixture', {})
66
+ proj.instance_eval(project_block)
67
+
68
+ branches.each do |branch, version|
69
+ repo = double("repo")
70
+ expect(::Git)
71
+ .to receive(:open)
72
+ .and_return(repo)
73
+
74
+ allow(repo)
75
+ .to receive(:current_branch)
76
+ .and_return(branch)
77
+
78
+ expect(proj.version_from_branch).to eq(version)
79
+ end
80
+ end
81
+
82
+ it 'fails if there is none' do
83
+ branches = [
84
+ 'PUP-12345',
85
+ '200',
86
+ 'just-a-branch-name'
87
+ ]
88
+
89
+ expect(Vanagon::Driver).to receive(:configdir).exactly(branches.length).times.and_return(configdir)
90
+ proj = Vanagon::Project::DSL.new('test-fixture', {})
91
+ proj.instance_eval(project_block)
92
+
93
+ branches.each do |branch|
94
+ repo = double("repo")
95
+ expect(::Git)
96
+ .to receive(:open)
97
+ .and_return(repo)
98
+
99
+ allow(repo)
100
+ .to receive(:current_branch)
101
+ .and_return(branch)
102
+
103
+ expect(proj).to receive(:fail)
104
+ proj.version_from_branch
105
+ end
106
+ end
107
+ end
108
+
55
109
  describe '#directory' do
56
110
  it 'adds a directory to the list of directories' do
57
111
  proj = Vanagon::Project::DSL.new('test-fixture', {})
@@ -231,6 +285,35 @@ end" }
231
285
  end
232
286
  end
233
287
 
288
+ describe "#package_override" do
289
+ let(:project_block) {
290
+ "project 'test-fixture' do |proj|
291
+ proj.package_override \"TEST_VAR='foo'\"
292
+ end"
293
+ }
294
+
295
+ before do
296
+ allow_any_instance_of(Vanagon::Project::DSL).to receive(:puts)
297
+ allow(Vanagon::Driver).to receive(:configdir).and_return(configdir)
298
+ @el_plat = Vanagon::Platform::DSL.new('el-5-x86_64')
299
+ @el_plat.instance_eval("platform 'el-5-x86_64' do |plat| end")
300
+ @osx_plat = Vanagon::Platform::DSL.new('osx-10.10-x86_64')
301
+ @osx_plat.instance_eval("platform 'osx-10.10-x86_64' do |plat| end")
302
+
303
+ end
304
+
305
+ it 'adds package_overrides on supported platforms' do
306
+ proj = Vanagon::Project::DSL.new('test-fixture', @el_plat._platform, [])
307
+ proj.instance_eval(project_block)
308
+ expect(proj._project.package_overrides).to include("TEST_VAR='foo'")
309
+ end
310
+
311
+ it 'fails on usupported platforms' do
312
+ proj = Vanagon::Project::DSL.new('test-fixture', @osx_plat._platform, [])
313
+ expect{ proj.instance_eval(project_block) }.to raise_error(RuntimeError)
314
+ end
315
+ end
316
+
234
317
  describe "#component" do
235
318
  let(:project_block) {
236
319
  "project 'test-fixture' do |proj|