diff --git a/vagrant-libvirt-0.11.2-Allow-a-mock-object-to-receive-synced_folders.patch b/vagrant-libvirt-0.11.2-Allow-a-mock-object-to-receive-synced_folders.patch new file mode 100644 index 0000000..41976a2 --- /dev/null +++ b/vagrant-libvirt-0.11.2-Allow-a-mock-object-to-receive-synced_folders.patch @@ -0,0 +1,28 @@ +From f87d4330953effdea41355d2daedb6b9659f39d3 Mon Sep 17 00:00:00 2001 +From: Jarek Prokop +Date: Fri, 10 Feb 2023 16:24:07 +0100 +Subject: [PATCH] Allow a mock object to receive synced_folders when using qemu + session. + +When using qemu session, there is another code path +regarding 9p and virtiofs that wasn't considered. +--- + spec/unit/config_spec.rb | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/spec/unit/config_spec.rb b/spec/unit/config_spec.rb +index d205214..e606b89 100644 +--- a/spec/unit/config_spec.rb ++++ b/spec/unit/config_spec.rb +@@ -770,6 +770,8 @@ describe VagrantPlugins::ProviderLibvirt::Config do + let (:vm) { double('vm') } + before do + machine.config.instance_variable_get("@keys")[:vm] = vm ++ ++ allow(vm).to receive(:synced_folders).and_return({}) + end + + it 'is valid with valid mac' do +-- +2.39.1 + diff --git a/vagrant-libvirt.spec b/vagrant-libvirt.spec index 6648e1a..bce5657 100644 --- a/vagrant-libvirt.spec +++ b/vagrant-libvirt.spec @@ -19,16 +19,18 @@ Source1: https://github.com/mitchellh/vagrant-spec/archive/%{vagrant_spec_commit # A bit modified: spec/support/libvirt_acceptance_context.rb does not exist # with 0.7.0 yet Patch0: vagrant-libvirt-pr1709-ruby32-File_exists-URL-parse.patch +# Allow a mock object to receive synced_folders in config validation spec. +# We do not care about synced folder check when testing MAC configuration. +# https://github.com/vagrant-libvirt/vagrant-libvirt/pull/1721 +Patch1: vagrant-libvirt-0.11.2-Allow-a-mock-object-to-receive-synced_folders.patch # Enable QEMU Session by default # https://github.com/vagrant-libvirt/vagrant-libvirt/pull/969 -# NOTE: This breaks some tests, which are therefore disabled below. Patch100: vagrant-libvirt-0.0.45-enable-qemu-session-by-default.patch Requires: ruby(release) Requires: ruby(rubygems) Requires: rubygem(diffy) -Requires: rubygem(fog-core) >= 2 Requires: rubygem(fog-libvirt) >= 0.6.0 Requires: rubygem(nokogiri) >= 1.6 Requires: rubygem(rexml) @@ -44,10 +46,7 @@ BuildRequires: rubygem(fog-libvirt) BuildRequires: rubygem(rake) BuildRequires: rubygem(rdoc) BuildRequires: rubygem(rexml) -BuildRequires: rubygem(rspec) >= 3.10 -BuildRequires: rubygem(rspec-core) >= 3.5 -BuildRequires: rubygem(rspec-expectations) >= 3.5 -BuildRequires: rubygem(rspec-mocks) >= 3.5 +BuildRequires: rubygem(rspec) BuildRequires: rubygem(thor) BuildRequires: rubygem(xml-simple) BuildRequires: rubygems-devel @@ -71,6 +70,7 @@ Documentation for %{name}. %setup -q -n %{vagrant_plugin_name}-%{version} -b 1 %patch0 -p1 +%patch1 -p1 %patch100 -p1 %build @@ -83,12 +83,12 @@ cp -a .%{vagrant_plugin_dir}/* \ %{buildroot}%{vagrant_plugin_dir}/ %check -## Edit gemspec of vagrant-spec +# Edit gemspec of vagrant-spec pushd ../vagrant-spec-%{vagrant_spec_commit} # Remove the git reference, which is useless in our case. sed -i '/git / s/^/#/' vagrant-spec.gemspec -## Relax the dependencies, since Fedora ships with newer versions. +# Relax the dependencies, since Fedora ships with newer versions. sed -i '/thor/ s/~>/>=/' vagrant-spec.gemspec sed -i '/rspec/ s/~>/>=/' vagrant-spec.gemspec popd @@ -106,21 +106,18 @@ gem 'vagrant-spec', :path => '%{_builddir}/vagrant-spec-%{vagrant_spec_commit}' gemspec EOG -## We don't care about code coverage, but editing such large chunks of source -## code is error-prone (2nd sed unbalances begin/end blocks), so leave it alone -## and take the build time penalty to save maintainer time. -#sed -i '/require .simplecov./ s/^/#/' spec/spec_helper.rb -#sed -i '/SimpleCov/,/^end/ s/^/#/' spec/spec_helper.rb -#sed -i '/simplecov/ s/^/#/' %{vagrant_plugin_name}.gemspec - -# Relax developement rspec dependency -sed -i '/rspec/ s/~>/>=/' %{vagrant_plugin_name}.gemspec - -# Disable tests that use synced_folders, as they're not supported under qemu:///session -sed -i "s/describe '#validate' do/xdescribe '#validate' do/" spec/unit/config_spec.rb +# Unless rsync binary is present, vagrant-libvirt +# decides to use other methods of folder sync in tests, +# breaking set expectations for the test environment. +# https://github.com/vagrant-libvirt/vagrant-libvirt/issues/1415#issuecomment-985272836 +# Luckily, it just needs `rsync` in $PATH for tests to pass. +tmpdir=$(mktemp -d) +touch "${tmpdir}/rsync" +chmod +x "${tmpdir}/rsync" # Suppress deprecation warnings GEM_PATH=%{vagrant_plugin_dir}:`ruby -e "print Gem.path.join(':')"` \ +PATH="$PATH:${tmpdir}" \ bundle exec rspec spec popd