Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable audio in virtualbox by default #392

Merged
merged 2 commits into from
Jan 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions spec/kitchen/driver/vagrant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1272,10 +1272,27 @@ def run_command(_cmd, options = {})
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :virtualbox do |p|
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
p.customize ["modifyvm", :id, "--audio", "none"]
end
RUBY
end

it "disables audio by default" do
cmd

expect(vagrantfile).to include(%{p.customize ["modifyvm", :id, "--audio", "none"]})
end

it "allows audio to be enabled with :customize" do
config[:customize] = {
audio: "pulse",
}
cmd

expect(vagrantfile).to include(%{p.customize ["modifyvm", :id, "--audio", "pulse"]})
expect(vagrantfile).not_to include(%{p.customize ["modifyvm", :id, "--audio", "none"]})
end

it "adds a line for each element in :customize" do
config[:customize] = {
a_key: "some value",
Expand All @@ -1286,6 +1303,7 @@ def run_command(_cmd, options = {})
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :virtualbox do |p|
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
p.customize ["modifyvm", :id, "--audio", "none"]
p.customize ["modifyvm", :id, "--a_key", "some value"]
p.customize ["modifyvm", :id, "--something", "else"]
end
Expand All @@ -1307,6 +1325,7 @@ def run_command(_cmd, options = {})
c.vm.provider :virtualbox do |p|
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
p.gui = false
p.customize ["modifyvm", :id, "--audio", "none"]
end
RUBY
end
Expand All @@ -1319,6 +1338,7 @@ def run_command(_cmd, options = {})
c.vm.provider :virtualbox do |p|
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
p.gui = true
p.customize ["modifyvm", :id, "--audio", "none"]
end
RUBY
end
Expand All @@ -1339,6 +1359,7 @@ def run_command(_cmd, options = {})
c.vm.provider :virtualbox do |p|
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
p.linked_clone = false
p.customize ["modifyvm", :id, "--audio", "none"]
end
RUBY
end
Expand All @@ -1351,6 +1372,7 @@ def run_command(_cmd, options = {})
c.vm.provider :virtualbox do |p|
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
p.linked_clone = true
p.customize ["modifyvm", :id, "--audio", "none"]
end
RUBY
end
Expand All @@ -1367,6 +1389,7 @@ def run_command(_cmd, options = {})
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :virtualbox do |p|
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
p.customize ["modifyvm", :id, "--audio", "none"]
p.customize ["createhd", "--filename", "./d1.vmdk", "--size", 10240]
end
RUBY
Expand All @@ -1390,6 +1413,7 @@ def run_command(_cmd, options = {})
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :virtualbox do |p|
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
p.customize ["modifyvm", :id, "--audio", "none"]
p.customize ["createhd", "--filename", "./d1.vmdk", "--size", 10240]
p.customize ["createhd", "--filename", "./d2.vmdk", "--size", 20480]
end
Expand All @@ -1410,6 +1434,7 @@ def run_command(_cmd, options = {})
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :virtualbox do |p|
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
p.customize ["modifyvm", :id, "--audio", "none"]
p.customize ["storagectl", :id, "--name", "Custom SATA Controller", "--add", "sata", "--controller", "IntelAHCI", "--portcount", 4]
end
RUBY
Expand All @@ -1434,6 +1459,7 @@ def run_command(_cmd, options = {})
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :virtualbox do |p|
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
p.customize ["modifyvm", :id, "--audio", "none"]
p.customize ["storagectl", :id, "--name", "Custom SATA Controller", "--add", "sata", "--controller", "IntelAHCI"]
p.customize ["storagectl", :id, "--name", "Custom SATA Controller", "--portcount", 4]
end
Expand All @@ -1452,6 +1478,7 @@ def run_command(_cmd, options = {})
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :virtualbox do |p|
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
p.customize ["modifyvm", :id, "--audio", "none"]
p.customize ["storageattach", :id, "--type", "hdd", "--port", 1]
end
RUBY
Expand Down Expand Up @@ -1481,6 +1508,7 @@ def run_command(_cmd, options = {})
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :virtualbox do |p|
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
p.customize ["modifyvm", :id, "--audio", "none"]
p.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", 1, "--device", 0, "--type", "hdd", "--medium", "./d1.vmdk"]
p.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", 1, "--device", 1, "--type", "hdd", "--medium", "./d2.vmdk"]
end
Expand All @@ -1496,6 +1524,7 @@ def run_command(_cmd, options = {})
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
c.vm.provider :virtualbox do |p|
p.name = "kitchen-#{File.basename(config[:kitchen_root])}-suitey-fooos-99"
p.customize ["modifyvm", :id, "--audio", "none"]
p.customize ["modifyvm", :id, "--cpuidset", "00000001", "00000002"]
end
RUBY
Expand Down
9 changes: 7 additions & 2 deletions templates/Vagrantfile.erb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Vagrant.configure("2") do |c|
when "virtualbox" %>
p.name = "kitchen-<%= File.basename(config[:kitchen_root]) %>-<%= instance.name %>"
<% end %>

<% case config[:provider]
when "virtualbox", /^vmware_/
if config[:gui] == true || config[:gui] == false %>
Expand All @@ -114,6 +114,11 @@ Vagrant.configure("2") do |c|
<% end
end %>

<% if config[:provider] == "virtualbox" &&
!config[:customize].has_key?(:audio) %>
p.customize ["modifyvm", :id, "--audio", "none"]
<% end %>

<% config[:customize].each do |key, value| %>
<% case config[:provider]
when "libvirt" %>
Expand Down Expand Up @@ -176,7 +181,7 @@ Vagrant.configure("2") do |c|
<% options = [] %>
<% item.each do |storage_option_key, storage_option_value|
options << "\"--#{storage_option_key}\""
if storage_option_value.instance_of? Fixnum
if storage_option_value.kind_of? Integer
options << storage_option_value
else
options << "\"#{storage_option_value}\""
Expand Down