summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerdar Sutay <serdar@opscode.com>2013-10-21 20:39:10 -0700
committerSerdar Sutay <serdar@opscode.com>2013-10-21 20:39:10 -0700
commit6665df680a4b8cd2067fd312b4f1693a10d719d6 (patch)
treea477ea2f8b469f43f83235f7a7518e1312bcf16f
parent5743710e8c2d1a96bcf20657cf88e8f0c96fccdb (diff)
parent202e837298882e0df52674270f93bfdc059d69d4 (diff)
downloadchef-6665df680a4b8cd2067fd312b4f1693a10d719d6.tar.gz
Merge pull request #1073 from opscode/OC-1019011.8.0.rc.2
OC-10190: Write a regression test to catch any unexpected messages while running chef-client -v
-rw-r--r--spec/functional/version_spec.rb35
-rw-r--r--spec/integration/solo/solo_spec.rb10
-rw-r--r--spec/unit/util/diff_spec.rb52
3 files changed, 77 insertions, 20 deletions
diff --git a/spec/functional/version_spec.rb b/spec/functional/version_spec.rb
new file mode 100644
index 0000000000..a342206161
--- /dev/null
+++ b/spec/functional/version_spec.rb
@@ -0,0 +1,35 @@
+#
+# Author:: Serdar Sutay (<dan@opscode.com>)
+# Copyright:: Copyright (c) 2013 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require File.expand_path('../../spec_helper', __FILE__)
+require 'chef/mixin/shell_out'
+require 'chef/version'
+require 'ohai/version'
+
+describe "Chef Versions" do
+ include Chef::Mixin::ShellOut
+ let(:chef_dir) { File.join(File.dirname(__FILE__), "..", "..") }
+
+ binaries = [ "chef-client", "chef-shell", "chef-apply", "knife", "chef-solo" ]
+
+ binaries.each do |binary|
+ it "#{binary} version should be sane" do
+ shell_out!("ruby #{File.join("bin", binary)} -v", :cwd => chef_dir).stdout.chomp.should == "Chef: #{Chef::VERSION}"
+ end
+ end
+
+end
diff --git a/spec/integration/solo/solo_spec.rb b/spec/integration/solo/solo_spec.rb
index 215c110d3e..90b8273f46 100644
--- a/spec/integration/solo/solo_spec.rb
+++ b/spec/integration/solo/solo_spec.rb
@@ -18,8 +18,8 @@ describe "chef-solo" do
cookbook_path "#{path_to('cookbooks')}"
file_cache_path "#{path_to('config/cache')}"
EOM
- chef_dir = File.join(File.dirname(__FILE__), "..", "..", "..", "bin")
- result = shell_out("chef-solo -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug", :cwd => chef_dir)
+ chef_dir = File.join(File.dirname(__FILE__), "..", "..", "..")
+ result = shell_out("ruby bin/chef-solo -c \"#{path_to('config/solo.rb')}\" -o 'x::default' -l debug", :cwd => chef_dir)
result.error!
end
end
@@ -45,17 +45,17 @@ EOM
# run_lock gets stuck we can discover it.
lambda {
Timeout.timeout(120) do
- chef_dir = File.join(File.dirname(__FILE__), "..", "..", "..", "bin")
+ chef_dir = File.join(File.dirname(__FILE__), "..", "..", "..")
# Instantiate the first chef-solo run
- s1 = Process.spawn("chef-solo -c \"#{path_to('config/solo.rb')}\" -o 'x::default' \
+ s1 = Process.spawn("ruby bin/chef-solo -c \"#{path_to('config/solo.rb')}\" -o 'x::default' \
-l debug -L #{path_to('logs/runs.log')}", :chdir => chef_dir)
# Give it some time to progress
sleep 1
# Instantiate the second chef-solo run
- s2 = Process.spawn("chef-solo -c \"#{path_to('config/solo.rb')}\" -o 'x::default' \
+ s2 = Process.spawn("ruby bin/chef-solo -c \"#{path_to('config/solo.rb')}\" -o 'x::default' \
-l debug -L #{path_to('logs/runs.log')}", :chdir => chef_dir)
Process.waitpid(s1)
diff --git a/spec/unit/util/diff_spec.rb b/spec/unit/util/diff_spec.rb
index 0e3bc0a0d7..947ce1d5aa 100644
--- a/spec/unit/util/diff_spec.rb
+++ b/spec/unit/util/diff_spec.rb
@@ -20,24 +20,17 @@
require 'spec_helper'
require 'tmpdir'
-describe Chef::Util::Diff, :uses_diff => true do
+shared_context "using file paths with spaces" do
+ let!(:old_tempfile) { Tempfile.new("chef-util diff-spec") }
+ let!(:new_tempfile) { Tempfile.new("chef-util diff-spec") }
+end
+
+shared_context "using file paths without spaces" do
let!(:old_tempfile) { Tempfile.new("chef-util-diff-spec") }
let!(:new_tempfile) { Tempfile.new("chef-util-diff-spec") }
- let!(:old_file) { old_tempfile.path }
- let!(:new_file) { new_tempfile.path }
-
- let(:plain_ascii) { "This is a text file.\nWith more than one line.\nAnd a \tTab.\nAnd lets make sure that other printable chars work too: ~!@\#$%^&*()`:\"<>?{}|_+,./;'[]\\-=\n" }
- # these are all byte sequences that are illegal in the other encodings... (but they may legally transcode)
- let(:utf_8) { "testing utf-8 unicode...\n\n\non a new line: \xE2\x80\x93\n" } # unicode em-dash
- let(:latin_1) { "It is more metal.\nif you have an \xFDmlaut.\n" } # NB: changed to y-with-diaresis, but i'm American so I don't know the difference
- let(:shift_jis) { "I have no idea what this character is:\n \x83\x80.\n" } # seriously, no clue, but \x80 is nice and illegal in other encodings
-
- let(:differ) do # subject
- differ = Chef::Util::Diff.new
- differ.diff(old_file, new_file)
- differ
- end
+end
+shared_examples_for "a diff util" do
it "should return a Chef::Util::Diff" do
expect(differ).to be_a_kind_of(Chef::Util::Diff)
end
@@ -554,4 +547,33 @@ describe Chef::Util::Diff, :uses_diff => true do
end
+describe Chef::Util::Diff, :uses_diff => true do
+ let!(:old_file) { old_tempfile.path }
+ let!(:new_file) { new_tempfile.path }
+
+ let(:plain_ascii) { "This is a text file.\nWith more than one line.\nAnd a \tTab.\nAnd lets make sure that other printable chars work too: ~!@\#$%^&*()`:\"<>?{}|_+,./;'[]\\-=\n" }
+ # these are all byte sequences that are illegal in the other encodings... (but they may legally transcode)
+ let(:utf_8) { "testing utf-8 unicode...\n\n\non a new line: \xE2\x80\x93\n" } # unicode em-dash
+ let(:latin_1) { "It is more metal.\nif you have an \xFDmlaut.\n" } # NB: changed to y-with-diaresis, but i'm American so I don't know the difference
+ let(:shift_jis) { "I have no idea what this character is:\n \x83\x80.\n" } # seriously, no clue, but \x80 is nice and illegal in other encodings
+
+ let(:differ) do # subject
+ differ = Chef::Util::Diff.new
+ differ.diff(old_file, new_file)
+ differ
+ end
+
+ describe "when file path has spaces" do
+ include_context "using file paths with spaces"
+
+ it_behaves_like "a diff util"
+ end
+
+
+ describe "when file path doesn't have spaces" do
+ include_context "using file paths without spaces"
+
+ it_behaves_like "a diff util"
+ end
+end