diff options
author | Serdar Sutay <serdar@opscode.com> | 2013-11-06 09:26:30 -0800 |
---|---|---|
committer | Serdar Sutay <serdar@opscode.com> | 2013-11-06 09:26:30 -0800 |
commit | 8cc3f13dca9d37282c85d9d9800d1d84d9db553f (patch) | |
tree | f462649080e4a87fd3fab40c4da9ed582e3400cc | |
parent | b8f2dc8a2acc9e9978f5f2c30aaa6b31b4e9cd94 (diff) | |
parent | b60b4d5bcf0a4f14a4788ca2b8eff2668e00b7e7 (diff) | |
download | chef-8cc3f13dca9d37282c85d9d9800d1d84d9db553f.tar.gz |
Merge pull request #1109 from opscode/ci-script-fix
Enable integration tests in CI and fix the way tests are launched.
-rw-r--r-- | ci/jenkins_run_tests.bat | 15 | ||||
-rw-r--r-- | lib/chef/knife.rb | 9 | ||||
-rw-r--r-- | spec/integration/client/client_spec.rb | 13 | ||||
-rw-r--r-- | spec/unit/knife_spec.rb | 7 |
4 files changed, 31 insertions, 13 deletions
diff --git a/ci/jenkins_run_tests.bat b/ci/jenkins_run_tests.bat index 4d1b1d1477..ba9cedd5e2 100644 --- a/ci/jenkins_run_tests.bat +++ b/ci/jenkins_run_tests.bat @@ -1,9 +1,14 @@ -set PATH=C:\Ruby192\bin;%PATH% - ruby -v -call bundle install --binstubs --without docgen --path vendor/bundle || ( call rm Gemfile.lock && call bundle install --binstubs --path vendor/bundle ) -ruby bin\rspec -r rspec_junit_formatter -f RspecJunitFormatter -o test.xml -f documentation spec/functional spec/unit spec/stress -set RSPEC_ERRORLVL=%ERRORLEVEL% +call bundle check + +if %ERRORLEVEL% NEQ 0 ( + call rm Gemfile.lock + call bundle install --without docgen --path vendor/bundle +) + +bundle exec rspec -r rspec_junit_formatter -f RspecJunitFormatter -o test.xml -f documentation spec/functional spec/unit spec/stress spec/integration + +set RSPEC_ERRORLVL=%ERRORLEVEL% REM Return the error level from rspec exit /B %RSPEC_ERRORLVL% diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb index 341402242e..d4d1a3c534 100644 --- a/lib/chef/knife.rb +++ b/lib/chef/knife.rb @@ -239,7 +239,14 @@ class Chef end def self.working_directory - ENV['PWD'] || Dir.pwd + a = if Chef::Platform.windows? + ENV['CD'] + else + ENV['PWD'] + end || Dir.pwd + + puts "Working directory: #{a}" + a end def self.reset_config_path! diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb index 839899d059..ffdded10e8 100644 --- a/spec/integration/client/client_spec.rb +++ b/spec/integration/client/client_spec.rb @@ -22,19 +22,19 @@ EOM context 'and no config file' do it 'should complete with success when cwd is just above cookbooks and paths are not specified' do chef_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "bin")) - result = shell_out("#{chef_dir}/chef-client -z -o 'x::default' --config-file-jail \"#{path_to('')}\"", :cwd => path_to('')) + result = shell_out("ruby #{chef_dir}/chef-client -z -o 'x::default' --config-file-jail \"#{path_to('')}\"", :cwd => path_to('')) result.error! end it 'should complete with success when cwd is below cookbooks and paths are not specified' do chef_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "bin")) - result = shell_out("#{chef_dir}/chef-client -z -o 'x::default' --config-file-jail \"#{path_to('')}\"", :cwd => path_to('cookbooks/x')) + result = shell_out("ruby #{chef_dir}/chef-client -z -o 'x::default' --config-file-jail \"#{path_to('')}\"", :cwd => path_to('cookbooks/x')) result.error! end it 'should fail when cwd is below high above and paths are not specified' do chef_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "bin")) - result = shell_out("#{chef_dir}/chef-client -z -o 'x::default' --config-file-jail \"#{path_to('')}\"", :cwd => File.expand_path('..', path_to(''))) + result = shell_out("ruby #{chef_dir}/chef-client -z -o 'x::default' --config-file-jail \"#{path_to('')}\"", :cwd => File.expand_path('..', path_to(''))) result.exitstatus.should == 1 end end @@ -44,13 +44,14 @@ EOM it 'should load .chef/knife.rb when -z is specified' do chef_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "bin")) - result = shell_out("#{chef_dir}/chef-client -z -o 'x::default' --config-file-jail \"#{path_to('')}\"", :cwd => path_to('')) - result.exitstatus.should == 2 + result = shell_out("ruby #{chef_dir}/chef-client -z -o 'x::default' --config-file-jail \"#{path_to('')}\"", :cwd => path_to('')) + # FATAL: Configuration error NoMethodError: undefined method `xxx' for nil:NilClass + result.stdout.should include("xxx") end it 'fails to load .chef/knife.rb when -z is specified and --config-file-jail does not include the .chef/knife.rb' do chef_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "bin")) - result = shell_out("#{chef_dir}/chef-client -z -o 'x::default' --config-file-jail \"#{path_to('roles')}\"", :cwd => path_to('')) + result = shell_out("ruby #{chef_dir}/chef-client -z -o 'x::default' --config-file-jail \"#{path_to('roles')}\"", :cwd => path_to('')) result.error! end end diff --git a/spec/unit/knife_spec.rb b/spec/unit/knife_spec.rb index 3edddec374..c6769b182a 100644 --- a/spec/unit/knife_spec.rb +++ b/spec/unit/knife_spec.rb @@ -46,7 +46,12 @@ describe Chef::Knife do Chef::Knife.reset_config_path! # pwd according to your shell is /home/someuser/prod/chef-repo, but # chef-repo is a symlink to /home/someuser/codes/chef-repo - ENV.stub!(:[]).with("PWD").and_return("/home/someuser/prod/chef-repo") + if Chef::Platform.windows? + ENV.should_receive(:[]).with("CD").and_return("/home/someuser/prod/chef-repo") + else + ENV.should_receive(:[]).with("PWD").and_return("/home/someuser/prod/chef-repo") + end + Dir.stub!(:pwd).and_return("/home/someuser/codes/chef-repo") end |