summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2020-07-24 20:26:54 -0700
committerGitHub <noreply@github.com>2020-07-24 20:26:54 -0700
commita663df7cfe59fed39fda207dacb8695fe86d5b8a (patch)
tree14fe23c2af8e286fc58641925bb1fa1215cfd9a6 /spec
parentda50219650ae19a13434354e3d49e2da17f343ab (diff)
parente2777777bbf42fd9f8c69d365d95b5b35dbe361f (diff)
downloadchef-a663df7cfe59fed39fda207dacb8695fe86d5b8a.tar.gz
Merge pull request #10205 from chef/remove-some-test-cruft
Remove some test cruft around diffing
Diffstat (limited to 'spec')
-rw-r--r--spec/spec_helper.rb1
-rw-r--r--spec/support/chef_helpers.rb13
-rw-r--r--spec/support/platform_helpers.rb2
-rw-r--r--spec/unit/util/diff_spec.rb16
4 files changed, 2 insertions, 30 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 6c04291e89..91e0d31680 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -175,7 +175,6 @@ RSpec.configure do |config|
config.filter_run_excluding requires_root: true unless root?
config.filter_run_excluding requires_root_or_running_windows: true unless root? || windows?
config.filter_run_excluding requires_unprivileged_user: true if root?
- config.filter_run_excluding uses_diff: true unless has_diff?
config.filter_run_excluding openssl_gte_101: true unless openssl_gte_101?
config.filter_run_excluding openssl_lt_101: true unless openssl_lt_101?
config.filter_run_excluding aes_256_gcm_only: true unless aes_256_gcm?
diff --git a/spec/support/chef_helpers.rb b/spec/support/chef_helpers.rb
index 1fdd24c033..810ebe56d7 100644
--- a/spec/support/chef_helpers.rb
+++ b/spec/support/chef_helpers.rb
@@ -40,22 +40,11 @@ def make_tmpname(prefix_suffix, n = nil)
path << suffix
end
-# NOTE:
-# This is a temporary fix to get tests passing on systems that have no `diff`
-# until we can replace shelling out to `diff` with ruby diff-lcs
-def has_diff?
- diff_cmd = Mixlib::ShellOut.new("diff -v")
- diff_cmd.run_command
- true
-rescue Errno::ENOENT
- false
-end
-
# This is a helper to determine if the ruby in the PATH contains
# win32/service gem. windows_service_manager tests create a windows
# service that starts with the system ruby and requires this gem.
def system_windows_service_gem?
- windows_service_gem_check_command = %{ruby -r "win32/daemon" -e ":noop" > #{DEV_NULL} 2>&1}
+ windows_service_gem_check_command = %{ruby -r "win32/daemon" -e ":noop" > #{File::NULL} 2>&1}
if defined?(Bundler)
Bundler.with_unbundled_env do
# This returns true if the gem can be loaded
diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb
index 709e137f24..7e17b75206 100644
--- a/spec/support/platform_helpers.rb
+++ b/spec/support/platform_helpers.rb
@@ -193,8 +193,6 @@ def supports_cloexec?
Fcntl.const_defined?("F_SETFD") && Fcntl.const_defined?("FD_CLOEXEC")
end
-DEV_NULL = windows? ? "NUL" : "/dev/null"
-
def selinux_enabled?
# This code is currently copied from lib/chef/util/selinux to make
# specs independent of product.
diff --git a/spec/unit/util/diff_spec.rb b/spec/unit/util/diff_spec.rb
index 4d112a7884..d1440dbaaa 100644
--- a/spec/unit/util/diff_spec.rb
+++ b/spec/unit/util/diff_spec.rb
@@ -61,10 +61,6 @@ shared_examples_for "a diff util" do
Chef::Config[:diff_disabled] = true
end
- after do
- Chef::Config[:diff_disabled] = false
- end
-
it "calling for_output should return the error message" do
expect(differ.for_output).to eql( [ "(diff output suppressed by config)" ] )
end
@@ -300,14 +296,9 @@ shared_examples_for "a diff util" do
describe "when testing the diff_filesize_threshold" do
before do
- @diff_filesize_threshold_saved = Chef::Config[:diff_filesize_threshold]
Chef::Config[:diff_filesize_threshold] = 10
end
- after do
- Chef::Config[:diff_filesize_threshold] = @diff_filesize_threshold_saved
- end
-
describe "when the old_file goes over the threshold" do
before do
old_tempfile.write("But thats what you get when Wu-Tang raised you")
@@ -359,14 +350,9 @@ shared_examples_for "a diff util" do
describe "when the diff output is too long" do
before do
- @diff_output_threshold_saved = Chef::Config[:diff_output_threshold]
Chef::Config[:diff_output_threshold] = 10
end
- after do
- Chef::Config[:diff_output_threshold] = @diff_output_threshold_saved
- end
-
it "calling for_output should return the error message" do
expect(differ.for_output).to eql(["(long diff of over 10 characters, diff output suppressed)"])
end
@@ -546,7 +532,7 @@ shared_examples_for "a diff util" do
end
-describe Chef::Util::Diff, uses_diff: true do
+describe Chef::Util::Diff do
let!(:old_file) { old_tempfile.path }
let!(:new_file) { new_tempfile.path }