test-kitchen 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/.cane +1 -1
  3. data/.rubocop.yml +3 -0
  4. data/.travis.yml +20 -9
  5. data/CHANGELOG.md +219 -108
  6. data/Gemfile +10 -6
  7. data/Guardfile +38 -9
  8. data/README.md +11 -1
  9. data/Rakefile +21 -37
  10. data/bin/kitchen +4 -4
  11. data/features/kitchen_action_commands.feature +161 -0
  12. data/features/kitchen_console_command.feature +34 -0
  13. data/features/kitchen_diagnose_command.feature +64 -0
  14. data/features/kitchen_init_command.feature +29 -17
  15. data/features/kitchen_list_command.feature +2 -2
  16. data/features/kitchen_login_command.feature +56 -0
  17. data/features/{sink_command.feature → kitchen_sink_command.feature} +0 -0
  18. data/features/kitchen_test_command.feature +88 -0
  19. data/features/step_definitions/gem_steps.rb +8 -6
  20. data/features/step_definitions/git_steps.rb +4 -2
  21. data/features/step_definitions/output_steps.rb +5 -0
  22. data/features/support/env.rb +12 -9
  23. data/lib/kitchen.rb +60 -38
  24. data/lib/kitchen/base64_stream.rb +55 -0
  25. data/lib/kitchen/busser.rb +124 -58
  26. data/lib/kitchen/cli.rb +121 -38
  27. data/lib/kitchen/collection.rb +3 -3
  28. data/lib/kitchen/color.rb +4 -4
  29. data/lib/kitchen/command.rb +78 -11
  30. data/lib/kitchen/command/action.rb +3 -2
  31. data/lib/kitchen/command/console.rb +12 -5
  32. data/lib/kitchen/command/diagnose.rb +17 -3
  33. data/lib/kitchen/command/driver_discover.rb +26 -7
  34. data/lib/kitchen/command/exec.rb +41 -0
  35. data/lib/kitchen/command/list.rb +44 -14
  36. data/lib/kitchen/command/login.rb +2 -1
  37. data/lib/kitchen/command/sink.rb +2 -1
  38. data/lib/kitchen/command/test.rb +5 -4
  39. data/lib/kitchen/config.rb +146 -14
  40. data/lib/kitchen/configurable.rb +314 -0
  41. data/lib/kitchen/data_munger.rb +522 -18
  42. data/lib/kitchen/diagnostic.rb +43 -4
  43. data/lib/kitchen/driver.rb +4 -4
  44. data/lib/kitchen/driver/base.rb +80 -115
  45. data/lib/kitchen/driver/dummy.rb +34 -6
  46. data/lib/kitchen/driver/proxy.rb +14 -3
  47. data/lib/kitchen/driver/ssh_base.rb +61 -7
  48. data/lib/kitchen/errors.rb +109 -9
  49. data/lib/kitchen/generator/driver_create.rb +39 -5
  50. data/lib/kitchen/generator/init.rb +130 -45
  51. data/lib/kitchen/instance.rb +162 -28
  52. data/lib/kitchen/lazy_hash.rb +79 -7
  53. data/lib/kitchen/loader/yaml.rb +159 -27
  54. data/lib/kitchen/logger.rb +267 -21
  55. data/lib/kitchen/logging.rb +30 -3
  56. data/lib/kitchen/login_command.rb +11 -2
  57. data/lib/kitchen/metadata_chopper.rb +2 -2
  58. data/lib/kitchen/provisioner.rb +4 -4
  59. data/lib/kitchen/provisioner/base.rb +107 -103
  60. data/lib/kitchen/provisioner/chef/berkshelf.rb +36 -8
  61. data/lib/kitchen/provisioner/chef/librarian.rb +40 -11
  62. data/lib/kitchen/provisioner/chef_base.rb +206 -167
  63. data/lib/kitchen/provisioner/chef_solo.rb +25 -7
  64. data/lib/kitchen/provisioner/chef_zero.rb +105 -29
  65. data/lib/kitchen/provisioner/dummy.rb +1 -1
  66. data/lib/kitchen/provisioner/shell.rb +21 -6
  67. data/lib/kitchen/rake_tasks.rb +8 -3
  68. data/lib/kitchen/shell_out.rb +15 -18
  69. data/lib/kitchen/ssh.rb +122 -27
  70. data/lib/kitchen/state_file.rb +24 -7
  71. data/lib/kitchen/thor_tasks.rb +9 -4
  72. data/lib/kitchen/util.rb +43 -118
  73. data/lib/kitchen/version.rb +1 -1
  74. data/lib/vendor/hash_recursive_merge.rb +10 -2
  75. data/spec/kitchen/base64_stream_spec.rb +77 -0
  76. data/spec/kitchen/busser_spec.rb +490 -0
  77. data/spec/kitchen/collection_spec.rb +10 -10
  78. data/spec/kitchen/color_spec.rb +2 -2
  79. data/spec/kitchen/config_spec.rb +234 -62
  80. data/spec/kitchen/configurable_spec.rb +490 -0
  81. data/spec/kitchen/data_munger_spec.rb +1070 -862
  82. data/spec/kitchen/diagnostic_spec.rb +79 -0
  83. data/spec/kitchen/driver/base_spec.rb +80 -85
  84. data/spec/kitchen/driver/dummy_spec.rb +43 -14
  85. data/spec/kitchen/driver/proxy_spec.rb +134 -0
  86. data/spec/kitchen/driver/ssh_base_spec.rb +644 -0
  87. data/spec/kitchen/driver_spec.rb +15 -15
  88. data/spec/kitchen/errors_spec.rb +309 -0
  89. data/spec/kitchen/instance_spec.rb +143 -46
  90. data/spec/kitchen/lazy_hash_spec.rb +36 -9
  91. data/spec/kitchen/loader/yaml_spec.rb +237 -226
  92. data/spec/kitchen/logger_spec.rb +419 -0
  93. data/spec/kitchen/logging_spec.rb +59 -0
  94. data/spec/kitchen/login_command_spec.rb +49 -0
  95. data/spec/kitchen/metadata_chopper_spec.rb +82 -0
  96. data/spec/kitchen/platform_spec.rb +4 -4
  97. data/spec/kitchen/provisioner/base_spec.rb +65 -125
  98. data/spec/kitchen/provisioner/chef_base_spec.rb +798 -0
  99. data/spec/kitchen/provisioner/chef_solo_spec.rb +316 -0
  100. data/spec/kitchen/provisioner/chef_zero_spec.rb +624 -0
  101. data/spec/kitchen/provisioner/shell_spec.rb +269 -0
  102. data/spec/kitchen/provisioner_spec.rb +6 -6
  103. data/spec/kitchen/shell_out_spec.rb +143 -0
  104. data/spec/kitchen/ssh_spec.rb +683 -0
  105. data/spec/kitchen/state_file_spec.rb +28 -21
  106. data/spec/kitchen/suite_spec.rb +7 -7
  107. data/spec/kitchen/util_spec.rb +68 -10
  108. data/spec/kitchen_spec.rb +107 -0
  109. data/spec/spec_helper.rb +18 -13
  110. data/support/chef-client-zero.rb +10 -9
  111. data/support/chef_helpers.sh +16 -0
  112. data/support/download_helpers.sh +109 -0
  113. data/test-kitchen.gemspec +42 -33
  114. metadata +107 -33
@@ -36,8 +36,14 @@ Feature: Add Test Kitchen support to an existing project
36
36
  Scenario: Running init that creates a Gemfile
37
37
  When I successfully run `kitchen init --create-gemfile`
38
38
  Then the file "Gemfile" should contain "https://rubygems.org"
39
- And the file "Gemfile" should contain "gem 'test-kitchen'"
40
- And the file "Gemfile" should contain "gem 'kitchen-vagrant'"
39
+ And the file "Gemfile" should contain:
40
+ """
41
+ gem "test-kitchen"
42
+ """
43
+ And the file "Gemfile" should contain:
44
+ """
45
+ gem "kitchen-vagrant"
46
+ """
41
47
  And the output should contain "You must run `bundle install'"
42
48
 
43
49
  Scenario: Running init with an existing Gemfile appends to the Gemfile
@@ -52,8 +58,8 @@ Feature: Add Test Kitchen support to an existing project
52
58
  """
53
59
  source "https://rubygems.org"
54
60
 
55
- gem 'test-kitchen'
56
- gem 'kitchen-vagrant'
61
+ gem "test-kitchen"
62
+ gem "kitchen-vagrant"
57
63
 
58
64
  """
59
65
  And the output should contain "You must run `bundle install'"
@@ -64,7 +70,7 @@ Feature: Add Test Kitchen support to an existing project
64
70
  """
65
71
  source "https://rubygems.org"
66
72
 
67
- gem "test-kitchen"
73
+ gem 'test-kitchen'
68
74
 
69
75
  """
70
76
  When I successfully run `kitchen init`
@@ -72,8 +78,8 @@ Feature: Add Test Kitchen support to an existing project
72
78
  """
73
79
  source "https://rubygems.org"
74
80
 
75
- gem "test-kitchen"
76
- gem 'kitchen-vagrant'
81
+ gem 'test-kitchen'
82
+ gem "kitchen-vagrant"
77
83
 
78
84
  """
79
85
  And the output should contain "You must run `bundle install'"
@@ -84,8 +90,8 @@ Feature: Add Test Kitchen support to an existing project
84
90
  """
85
91
  source "https://rubygems.org"
86
92
 
87
- gem "test-kitchen"
88
- gem "kitchen-ec2"
93
+ gem 'test-kitchen'
94
+ gem 'kitchen-ec2'
89
95
 
90
96
  """
91
97
  When I successfully run `kitchen init --driver=kitchen-ec2`
@@ -93,8 +99,8 @@ Feature: Add Test Kitchen support to an existing project
93
99
  """
94
100
  source "https://rubygems.org"
95
101
 
96
- gem "test-kitchen"
97
- gem "kitchen-ec2"
102
+ gem 'test-kitchen'
103
+ gem 'kitchen-ec2'
98
104
 
99
105
  """
100
106
  And the output should not contain "You must run `bundle install'"
@@ -102,8 +108,14 @@ Feature: Add Test Kitchen support to an existing project
102
108
  Scenario: Running init with multiple drivers appends to the Gemfile
103
109
  Given an empty file named "Gemfile"
104
110
  When I successfully run `kitchen init --driver=kitchen-bluebox kitchen-wakka`
105
- Then the file "Gemfile" should contain "gem 'kitchen-bluebox'"
106
- And the file "Gemfile" should contain "gem 'kitchen-wakka'"
111
+ Then the file "Gemfile" should contain:
112
+ """
113
+ gem "kitchen-bluebox"
114
+ """
115
+ And the file "Gemfile" should contain:
116
+ """
117
+ gem "kitchen-wakka"
118
+ """
107
119
  And the output should contain "You must run `bundle install'"
108
120
 
109
121
  Scenario: Running init with multiple driver sets the plugin_driver to the
@@ -152,10 +164,10 @@ Feature: Add Test Kitchen support to an existing project
152
164
  Then the file "Rakefile" should contain:
153
165
  """
154
166
  begin
155
- require 'kitchen/rake_tasks'
167
+ require "kitchen/rake_tasks"
156
168
  Kitchen::RakeTasks.new
157
169
  rescue LoadError
158
- puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV['CI']
170
+ puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV["CI"]
159
171
  end
160
172
  """
161
173
 
@@ -171,10 +183,10 @@ Feature: Add Test Kitchen support to an existing project
171
183
  Then the file "Thorfile" should contain:
172
184
  """
173
185
  begin
174
- require 'kitchen/thor_tasks'
186
+ require "kitchen/thor_tasks"
175
187
  Kitchen::ThorTasks.new
176
188
  rescue LoadError
177
- puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV['CI']
189
+ puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV["CI"]
178
190
  end
179
191
  """
180
192
 
@@ -22,8 +22,8 @@ Feature: Listing Test Kitchen instances
22
22
  Scenario: Listing instances
23
23
  When I run `kitchen list`
24
24
  Then the exit status should be 0
25
- And the output should contain "foobar-ubuntu-1304"
26
- And the output should contain "foobar-centos-64"
25
+ And the output should match /^foobar-ubuntu-1304\s+Dummy\s+ChefSolo\s+\<Not Created\>$/
26
+ And the output should match /^foobar-centos-64\s+Dummy\s+ChefSolo\s+\<Not Created\>$/
27
27
 
28
28
  Scenario: Listing instances with the --bare option
29
29
  When I run `kitchen list --bare`
@@ -0,0 +1,56 @@
1
+ Feature: Logging into a Kitchen instance
2
+ In order to iterate, explore, and debug
3
+ As a crafty developer
4
+ I want to run a command that will give me a terminal session
5
+
6
+ Background:
7
+ Given a file named ".kitchen.yml" with:
8
+ """
9
+ ---
10
+ driver:
11
+ name: dummy
12
+
13
+ provisioner:
14
+ name: dummy
15
+
16
+ platforms:
17
+ - name: flebian
18
+
19
+ suites:
20
+ - name: default
21
+ - name: full
22
+ """
23
+ And I successfully run `kitchen create default-flebian`
24
+
25
+ @spawn
26
+ Scenario: Logging in to an instance
27
+ When I run `kitchen login default-flebian`
28
+ Then the output should contain "Remote login is not supported in this driver."
29
+ And the exit status should not be 0
30
+
31
+ @spawn
32
+ Scenario: Attempting to log into a non-created instance
33
+ When I run `kitchen login full-flebian`
34
+ Then the output should contain:
35
+ """
36
+ Instance <full-flebian> has not yet been created
37
+ """
38
+ And the exit status should not be 0
39
+
40
+ @spawn
41
+ Scenario: Attempting to log into a non-existent instance
42
+ When I run `kitchen login nope`
43
+ Then the output should contain "No instances for regex `nope'"
44
+ And the exit status should not be 0
45
+
46
+ @spawn
47
+ Scenario: Attempting to log into an instance with an overly fuzzy match
48
+ When I run `kitchen login flebian`
49
+ Then the output should contain:
50
+ """
51
+ Argument `flebian' returned multiple results:
52
+ * default-flebian
53
+ * full-flebian
54
+ """
55
+ And the exit status should not be 0
56
+
@@ -0,0 +1,88 @@
1
+ Feature: Running a full test instance test
2
+ In order to "fire-and-forget" or run help setup a CI job
3
+ As an operator or CI script
4
+ I want to run a command that will fully test one or more instances
5
+
6
+ Background:
7
+ Given a file named ".kitchen.yml" with:
8
+ """
9
+ ---
10
+ driver:
11
+ name: dummy
12
+
13
+ provisioner:
14
+ name: dummy
15
+
16
+ platforms:
17
+ - name: cool
18
+ - name: beans
19
+
20
+ suites:
21
+ - name: client
22
+ - name: server
23
+ """
24
+
25
+ @spawn
26
+ Scenario: Running a single instance
27
+ When I run `kitchen test client-beans`
28
+ Then the output should contain "Starting Kitchen"
29
+ Then the output should contain "Cleaning up any prior instances of <client-beans>"
30
+ Then the output should contain "Testing <client-beans>"
31
+ Then the output should contain "Finished testing <client-beans>"
32
+ Then the output should contain "Kitchen is finished."
33
+ And the exit status should be 0
34
+
35
+ @spawn
36
+ Scenario: Running a single instance never destroying an instance
37
+ When I successfully run `kitchen test client-beans --destroy=never`
38
+ And I successfully run `kitchen list client-beans`
39
+ Then the output should match /^client-beans\s+.+\s+Verified$/
40
+
41
+ @spawn
42
+ Scenario: Running a single instance always destroying an instance
43
+ Given a file named ".kitchen.local.yml" with:
44
+ """
45
+ ---
46
+ driver:
47
+ fail_converge: true
48
+ """
49
+ When I run `kitchen test client-beans --destroy=always`
50
+ Then the exit status should not be 0
51
+ When I successfully run `kitchen list client-beans`
52
+ Then the output should match /^client-beans\s+.+\s+\<Not Created\>$/
53
+
54
+ @spawn
55
+ Scenario: Running a single instance not destroying an instance on failure
56
+ Given a file named ".kitchen.local.yml" with:
57
+ """
58
+ ---
59
+ driver:
60
+ fail_converge: true
61
+ """
62
+ When I run `kitchen test client-beans --destroy=passing`
63
+ Then the exit status should not be 0
64
+ When I successfully run `kitchen list client-beans`
65
+ Then the output should match /^client-beans\s+.+\s+Created$/
66
+
67
+ @spawn
68
+ Scenario: Running a single instance destroying an instance on success
69
+ When I run `kitchen test client-beans --destroy=passing`
70
+ Then the exit status should be 0
71
+ When I successfully run `kitchen list client-beans`
72
+ Then the output should match /^client-beans\s+.+\s+\<Not Created\>$/
73
+
74
+ @spawn
75
+ Scenario: Running all instances
76
+ When I run `kitchen test`
77
+ Then the output should contain "Starting Kitchen"
78
+ Then the output should contain "Finished testing <client-cool>"
79
+ Then the output should contain "Finished testing <client-beans>"
80
+ Then the output should contain "Finished testing <server-cool>"
81
+ Then the output should contain "Finished testing <server-beans>"
82
+ Then the output should contain "Kitchen is finished."
83
+ And the exit status should be 0
84
+ When I successfully run `kitchen list`
85
+ Then the output should match /^client-cool\s+.+\s+\<Not Created\>$/
86
+ Then the output should match /^client-beans\s+.+\s+\<Not Created\>$/
87
+ Then the output should match /^server-cool\s+.+\s+\<Not Created\>$/
88
+ Then the output should match /^server-beans\s+.+\s+\<Not Created\>$/
@@ -1,15 +1,17 @@
1
- require 'tmpdir'
2
- require 'pathname'
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require "tmpdir"
4
+ require "pathname"
3
5
 
4
6
  Given(/^a sandboxed GEM_HOME directory named "(.*?)"$/) do |name|
5
- backup_envvar('GEM_HOME')
6
- backup_envvar('GEM_PATH')
7
+ backup_envvar("GEM_HOME")
8
+ backup_envvar("GEM_PATH")
7
9
 
8
10
  @aruba_timeout_seconds = 30
9
11
 
10
12
  gem_home = Pathname.new(Dir.mktmpdir(name))
11
- ENV['GEM_HOME'] = gem_home.to_s
12
- ENV['GEM_PATH'] = [gem_home.to_s, ENV['GEM_PATH']].join(':')
13
+ ENV["GEM_HOME"] = gem_home.to_s
14
+ ENV["GEM_PATH"] = [gem_home.to_s, ENV["GEM_PATH"]].join(":")
13
15
  @cleanup_dirs << gem_home
14
16
  end
15
17
 
@@ -1,3 +1,5 @@
1
- Given /I have a git repository/ do
2
- create_dir('.git')
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Given(/I have a git repository/) do
4
+ create_dir(".git")
3
5
  end
@@ -0,0 +1,5 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Then(/^the stdout should match \/([^\/]*)\/$/) do |expected|
4
+ assert_matching_output(expected, all_stdout)
5
+ end
@@ -1,12 +1,15 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  # Set up the environment for testing
2
- require 'aruba/cucumber'
3
- require 'aruba/in_process'
4
- require 'aruba/spawn_process'
5
- require 'kitchen'
6
- require 'kitchen/cli'
4
+ require "aruba/cucumber"
5
+ require "aruba/in_process"
6
+ require "aruba/spawn_process"
7
+ require "kitchen"
8
+ require "kitchen/cli"
7
9
 
8
10
  class ArubaHelper
9
- def initialize(argv, stdin=STDIN, stdout=STDOUT, stderr=STDERR, kernel=Kernel)
11
+
12
+ def initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel)
10
13
  @argv, @stdin, @stdout, @stderr, @kernel = argv, stdin, stdout, stderr, kernel
11
14
  end
12
15
 
@@ -28,7 +31,7 @@ Before do
28
31
  Aruba.process = Aruba::InProcess
29
32
  end
30
33
 
31
- Before('@spawn') do
34
+ Before("@spawn") do
32
35
  Aruba.process = Aruba::SpawnProcess
33
36
  end
34
37
 
@@ -41,7 +44,7 @@ After do |s|
41
44
  # Restore environment variables to their original settings, if they have
42
45
  # been saved off
43
46
  ENV.keys.select { |key| key =~ /^_CUKE_/ }.each do |backup_key|
44
- ENV[backup_key.sub(/^_CUKE_/, '')] = ENV.delete(backup_key)
47
+ ENV[backup_key.sub(/^_CUKE_/, "")] = ENV.delete(backup_key)
45
48
  end
46
49
 
47
50
  @cleanup_dirs.each { |dir| FileUtils.rm_rf(dir) }
@@ -58,7 +61,7 @@ end
58
61
  def unbundlerize
59
62
  keys = %w[BUNDLER_EDITOR BUNDLE_BIN_PATH BUNDLE_GEMFILE RUBYOPT]
60
63
 
61
- keys.each { |key| backup_envvar(key) ; ENV.delete(key) }
64
+ keys.each { |key| backup_envvar(key); ENV.delete(key) }
62
65
  yield
63
66
  keys.each { |key| restore_envvar(key) }
64
67
  end
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
4
  #
5
- # Copyright (C) 2012, Fletcher Nichol
5
+ # Copyright (C) 2012, 2013, 2014 Fletcher Nichol
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
8
8
  # you may not use this file except in compliance with the License.
@@ -16,34 +16,35 @@
16
16
  # See the License for the specific language governing permissions and
17
17
  # limitations under the License.
18
18
 
19
- require 'pathname'
20
- require 'thread'
21
-
22
- require 'kitchen/errors'
23
- require 'kitchen/logger'
24
- require 'kitchen/logging'
25
- require 'kitchen/shell_out'
26
- require 'kitchen/util'
27
-
28
- require 'kitchen/provisioner'
29
- require 'kitchen/provisioner/base'
30
- require 'kitchen/busser'
31
- require 'kitchen/color'
32
- require 'kitchen/collection'
33
- require 'kitchen/config'
34
- require 'kitchen/data_munger'
35
- require 'kitchen/driver'
36
- require 'kitchen/driver/base'
37
- require 'kitchen/driver/proxy'
38
- require 'kitchen/driver/ssh_base'
39
- require 'kitchen/instance'
40
- require 'kitchen/loader/yaml'
41
- require 'kitchen/metadata_chopper'
42
- require 'kitchen/platform'
43
- require 'kitchen/state_file'
44
- require 'kitchen/ssh'
45
- require 'kitchen/suite'
46
- require 'kitchen/version'
19
+ require "pathname"
20
+ require "thread"
21
+
22
+ require "kitchen/errors"
23
+ require "kitchen/logger"
24
+ require "kitchen/logging"
25
+ require "kitchen/shell_out"
26
+ require "kitchen/configurable"
27
+ require "kitchen/util"
28
+
29
+ require "kitchen/provisioner"
30
+ require "kitchen/provisioner/base"
31
+ require "kitchen/busser"
32
+ require "kitchen/color"
33
+ require "kitchen/collection"
34
+ require "kitchen/config"
35
+ require "kitchen/data_munger"
36
+ require "kitchen/driver"
37
+ require "kitchen/driver/base"
38
+ require "kitchen/driver/ssh_base"
39
+ require "kitchen/driver/proxy"
40
+ require "kitchen/instance"
41
+ require "kitchen/loader/yaml"
42
+ require "kitchen/metadata_chopper"
43
+ require "kitchen/platform"
44
+ require "kitchen/state_file"
45
+ require "kitchen/ssh"
46
+ require "kitchen/suite"
47
+ require "kitchen/version"
47
48
 
48
49
  # Test Kitchen base module.
49
50
  #
@@ -52,43 +53,64 @@ module Kitchen
52
53
 
53
54
  class << self
54
55
 
56
+ # @return [Logger] the common Kitchen logger
55
57
  attr_accessor :logger
56
- attr_accessor :crashes
58
+
59
+ # @return [Mutex] a common mutex for global coordination
57
60
  attr_accessor :mutex
58
61
 
59
62
  # Returns the root path of the Kitchen gem source code.
60
63
  #
61
64
  # @return [Pathname] root path of gem
62
65
  def source_root
63
- @source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
64
- end
65
-
66
- def crashes?
67
- ! crashes.empty?
66
+ @source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
68
67
  end
69
68
 
69
+ # Returns a default logger which emits on standard output.
70
+ #
71
+ # @return [Logger] a logger
70
72
  def default_logger
71
- Logger.new(:stdout => STDOUT, :level => env_log)
73
+ Logger.new(:stdout => $stdout, :level => env_log)
72
74
  end
73
75
 
76
+ # Returns a default file logger which emits on standard output and to a
77
+ # log file.
78
+ #
79
+ # @return [Logger] a logger
74
80
  def default_file_logger
75
81
  logfile = File.expand_path(File.join(".kitchen", "logs", "kitchen.log"))
76
- Logger.new(:stdout => STDOUT, :logdev => logfile, :level => env_log)
82
+ Logger.new(:stdout => $stdout, :logdev => logfile, :level => env_log)
83
+ end
84
+
85
+ # Returns whether or not standard output is associated with a terminal
86
+ # device (tty).
87
+ #
88
+ # @return [true,false] is there a tty?
89
+ def tty?
90
+ $stdout.tty?
77
91
  end
78
92
 
79
93
  private
80
94
 
95
+ # Determine the default log level from an environment variable, if it is
96
+ # set.
97
+ #
98
+ # @return [Integer,nil] a log level or nil if not set
99
+ # @api private
81
100
  def env_log
82
- level = ENV['KITCHEN_LOG'] && ENV['KITCHEN_LOG'].downcase.to_sym
101
+ level = ENV["KITCHEN_LOG"] && ENV["KITCHEN_LOG"].downcase.to_sym
83
102
  level = Util.to_logger_level(level) unless level.nil?
103
+ level
84
104
  end
85
105
  end
86
106
 
87
107
  # Default log level verbosity
88
108
  DEFAULT_LOG_LEVEL = :info
89
109
 
110
+ # Default base directory for integration tests, fixtures, etc.
90
111
  DEFAULT_TEST_DIR = "test/integration".freeze
91
112
 
113
+ # Default base directory for instance and common log files
92
114
  DEFAULT_LOG_DIR = ".kitchen/logs".freeze
93
115
  end
94
116