aruba 0.9.0.pre → 0.9.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +8 -3
  3. data/History.md +61 -19
  4. data/README.md +10 -6
  5. data/TODO.md +6 -1
  6. data/cucumber.yml +10 -6
  7. data/features/.nav +72 -0
  8. data/features/announce.feature +203 -0
  9. data/features/api/command/extract_text.feature +10 -0
  10. data/features/api/command/run.feature +6 -6
  11. data/features/api/command/stop_all_commands.feature +53 -0
  12. data/features/api/command/terminate_all_commands.feature +53 -0
  13. data/features/api/command/unescape_text.feature +12 -0
  14. data/features/api/command/which.feature +3 -3
  15. data/features/api/core/expand_path.feature +4 -4
  16. data/features/api/environment/append_environment_variable.feature +18 -8
  17. data/features/api/environment/prepend_environment_variable.feature +18 -8
  18. data/features/api/environment/set_environment_variable.feature +33 -16
  19. data/features/api/filesystem/cd.feature +23 -13
  20. data/features/api/filesystem/create_directory.feature +2 -2
  21. data/features/api/filesystem/disk_usage.feature +7 -6
  22. data/features/api/filesystem/does_exist.feature +2 -2
  23. data/features/api/filesystem/is_absolute.feature +2 -2
  24. data/features/api/filesystem/is_directory.feature +2 -2
  25. data/features/api/filesystem/is_file.feature +2 -2
  26. data/features/api/filesystem/is_relative.feature +2 -2
  27. data/features/api/filesystem/move.feature +119 -0
  28. data/features/cli/console.feature +3 -3
  29. data/features/commands/debug_command.feature +93 -0
  30. data/features/commands/environment_variables.feature +64 -0
  31. data/features/commands/flushing.feature +74 -0
  32. data/features/commands/interactive.feature +90 -0
  33. data/features/commands/output/all_output.feature +445 -0
  34. data/features/commands/output/stdout.feature +66 -0
  35. data/features/configuration/exit_timeout.feature +5 -5
  36. data/features/configuration/fixtures_directories.feature +3 -3
  37. data/features/configuration/fixtures_path_prefix.feature +1 -1
  38. data/features/configuration/home_directory.feature +4 -4
  39. data/features/configuration/io_timeout.feature +2 -2
  40. data/features/configuration/keep_ansi.feature +2 -2
  41. data/features/configuration/log_level.feature +3 -3
  42. data/features/configuration/physical_block_size.feature +3 -3
  43. data/features/configuration/usage.feature +159 -0
  44. data/features/core/cleanup_aruba_directory.feature +52 -0
  45. data/features/development/build.feature +16 -0
  46. data/features/development/test.feature +24 -0
  47. data/features/file_system_commands.feature +12 -12
  48. data/features/getting_started/supported_programming_languages.feature +89 -0
  49. data/features/hooks/after/command.feature +1 -1
  50. data/features/hooks/before/command.feature +2 -2
  51. data/features/matchers/collection/include_an_object.feature +72 -0
  52. data/features/matchers/timeouts.feature +2 -2
  53. data/features/output.feature +60 -181
  54. data/features/step_definitions/aruba_dev_steps.rb +17 -10
  55. data/features/step_definitions/hooks.rb +11 -0
  56. data/features/steps/commands/exit_statuses.feature +3 -3
  57. data/features/steps/commands/run.feature +0 -15
  58. data/features/steps/filesystem/copy.feature +45 -0
  59. data/features/steps/filesystem/create_directory.feature +47 -0
  60. data/features/steps/filesystem/create_file.feature +53 -0
  61. data/features/steps/filesystem/file_content.feature +1 -1
  62. data/features/steps/filesystem/move.feature +45 -0
  63. data/features/steps/filesystem/overwrite_file.feature +72 -0
  64. data/features/steps/filesystem/use_fixture.feature +77 -0
  65. data/features/usage/install.feature +8 -0
  66. data/{features/fixtures → fixtures}/cli-app/.gitignore +0 -0
  67. data/{features/fixtures → fixtures}/cli-app/.rspec +0 -0
  68. data/{features/fixtures → fixtures}/cli-app/README.md +0 -0
  69. data/{features/fixtures → fixtures}/cli-app/Rakefile +0 -0
  70. data/{features/fixtures → fixtures}/cli-app/bin/cli +0 -0
  71. data/{features/fixtures → fixtures}/cli-app/cli-app.gemspec +0 -0
  72. data/{features/fixtures → fixtures}/cli-app/features/support/env.rb +0 -0
  73. data/{features/fixtures → fixtures}/cli-app/lib/cli/app.rb +0 -0
  74. data/fixtures/cli-app/lib/cli/app/suppress_simple_cov_output.rb +15 -0
  75. data/{features/fixtures → fixtures}/cli-app/lib/cli/app/version.rb +0 -0
  76. data/{features/fixtures/empty-app → fixtures/cli-app}/script/console +3 -3
  77. data/{features/fixtures → fixtures}/cli-app/spec/spec_helper.rb +0 -0
  78. data/{features/fixtures → fixtures}/cli-app/spec/support/aruba.rb +0 -0
  79. data/{features/fixtures → fixtures}/copy/file.txt +0 -0
  80. data/{features/fixtures → fixtures}/empty-app/.gitignore +0 -0
  81. data/{features/fixtures → fixtures}/empty-app/.rspec +0 -0
  82. data/{features/fixtures → fixtures}/empty-app/README.md +0 -0
  83. data/{features/fixtures → fixtures}/empty-app/Rakefile +0 -0
  84. data/{features/fixtures → fixtures}/empty-app/bin/cli +0 -0
  85. data/{features/fixtures → fixtures}/empty-app/cli-app.gemspec +0 -0
  86. data/{features/fixtures → fixtures}/empty-app/lib/cli/app.rb +0 -0
  87. data/{features/fixtures → fixtures}/empty-app/lib/cli/app/version.rb +0 -0
  88. data/{features/fixtures/cli-app → fixtures/empty-app}/script/console +3 -3
  89. data/{features/fixtures → fixtures}/empty-app/spec/spec_helper.rb +0 -0
  90. data/{features/fixtures → fixtures}/fixtures-app/test.txt +0 -0
  91. data/fixtures/getting-started-app/.gitignore +4 -0
  92. data/fixtures/getting-started-app/Gemfile +4 -0
  93. data/fixtures/getting-started-app/README.md +3 -0
  94. data/fixtures/getting-started-app/features/support/env.rb +1 -0
  95. data/{features/fixtures → fixtures}/spawn_process/stderr.sh +0 -0
  96. data/lib/aruba/announcer.rb +6 -2
  97. data/lib/aruba/api.rb +0 -16
  98. data/lib/aruba/api/command.rb +64 -266
  99. data/lib/aruba/api/core.rb +24 -26
  100. data/lib/aruba/api/deprecated.rb +370 -12
  101. data/lib/aruba/api/filesystem.rb +64 -15
  102. data/lib/aruba/aruba_path.rb +4 -0
  103. data/lib/aruba/config.rb +1 -1
  104. data/lib/aruba/cucumber.rb +5 -449
  105. data/lib/aruba/cucumber/command.rb +378 -0
  106. data/lib/aruba/cucumber/core.rb +29 -0
  107. data/lib/aruba/cucumber/environment.rb +30 -0
  108. data/lib/aruba/cucumber/file.rb +210 -0
  109. data/lib/aruba/cucumber/hooks.rb +11 -14
  110. data/lib/aruba/cucumber/rvm.rb +3 -0
  111. data/lib/aruba/matchers/base/base_matcher.rb +94 -0
  112. data/lib/aruba/matchers/collection.rb +1 -0
  113. data/lib/aruba/matchers/collection/all_objects.rb +2 -0
  114. data/lib/aruba/matchers/collection/include_an_object.rb +120 -0
  115. data/lib/aruba/matchers/command/be_successfully_executed.rb +3 -3
  116. data/lib/aruba/matchers/command/have_exit_status.rb +2 -11
  117. data/lib/aruba/matchers/command/have_finished_in_time.rb +5 -5
  118. data/lib/aruba/matchers/command/have_output.rb +46 -0
  119. data/lib/aruba/matchers/command/have_output_on_stderr.rb +42 -0
  120. data/lib/aruba/matchers/command/have_output_on_stdout.rb +42 -0
  121. data/lib/aruba/matchers/command/have_output_size.rb +28 -0
  122. data/lib/aruba/matchers/directory/be_an_existing_directory.rb +1 -1
  123. data/lib/aruba/matchers/file/be_an_existing_file.rb +1 -1
  124. data/lib/aruba/matchers/file/have_file_content.rb +1 -1
  125. data/lib/aruba/matchers/file/have_file_size.rb +2 -2
  126. data/lib/aruba/matchers/file/have_same_file_content.rb +1 -1
  127. data/lib/aruba/matchers/path/have_permissions.rb +1 -1
  128. data/lib/aruba/platforms/aruba_file_creator.rb +2 -3
  129. data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +2 -3
  130. data/lib/aruba/platforms/determine_disk_usage.rb +23 -0
  131. data/lib/aruba/platforms/determine_file_size.rb +13 -0
  132. data/lib/aruba/platforms/disk_usage_calculator.rb +11 -0
  133. data/lib/aruba/platforms/local_environment.rb +15 -0
  134. data/lib/aruba/platforms/unix_environment_variables.rb +1 -1
  135. data/lib/aruba/platforms/unix_platform.rb +35 -14
  136. data/lib/aruba/process_monitor.rb +53 -7
  137. data/lib/aruba/processes/basic_process.rb +25 -5
  138. data/lib/aruba/processes/debug_process.rb +27 -25
  139. data/lib/aruba/processes/in_process.rb +7 -22
  140. data/lib/aruba/processes/spawn_process.rb +74 -31
  141. data/lib/aruba/rspec.rb +1 -6
  142. data/lib/aruba/version.rb +1 -1
  143. data/script/console +0 -1
  144. data/spec/aruba/api/environment/restore_env_spec.rb +65 -0
  145. data/spec/aruba/api/environment/set_env_spec.rb +42 -0
  146. data/spec/aruba/api/filesystem/file_size_spec.rb +28 -0
  147. data/spec/aruba/api_spec.rb +10 -7
  148. data/spec/aruba/matchers/command/have_output_size_spec.rb +25 -0
  149. data/spec/aruba/matchers/command_spec.rb +135 -4
  150. data/spec/aruba/spawn_process_spec.rb +1 -1
  151. metadata +107 -65
  152. data/.nav +0 -12
  153. data/features/debug.feature +0 -15
  154. data/features/fixtures/cli-app/spec/cli/app_spec.rb +0 -7
  155. data/features/flushing.feature +0 -26
  156. data/features/interactive.feature +0 -66
  157. data/features/no_clobber.feature +0 -25
  158. data/lib/aruba/disk_usage_calculator.rb +0 -7
@@ -0,0 +1,28 @@
1
+ # @!method have_output_size(output)
2
+ # This matchers checks if output has size.
3
+ #
4
+ # @param [String] output
5
+ # The content which should be checked
6
+ #
7
+ # @return [TrueClass, FalseClass] The result
8
+ #
9
+ # false:
10
+ # * if output does not have size
11
+ # true:
12
+ # * if output has size
13
+ #
14
+ # @example Use matcher
15
+ #
16
+ # RSpec.describe do
17
+ # it { expect(file1).to have_output_size(256) }
18
+ # end
19
+ RSpec::Matchers.define :have_output_size do |expected|
20
+ match do |actual|
21
+ next false unless actual.respond_to? :size
22
+
23
+ @actual = actual.size
24
+ values_match? expected, @actual
25
+ end
26
+
27
+ description { "output has size #{description_of expected}" }
28
+ end
@@ -17,7 +17,7 @@ require 'rspec/expectations/version'
17
17
  # end
18
18
  RSpec::Matchers.define :be_an_existing_directory do |_|
19
19
  match do |actual|
20
- stop_processes!
20
+ stop_all_commands
21
21
 
22
22
  next false unless actual.is_a? String
23
23
 
@@ -17,7 +17,7 @@ require 'rspec/expectations/version'
17
17
  # end
18
18
  RSpec::Matchers.define :be_an_existing_file do |_|
19
19
  match do |actual|
20
- stop_processes!
20
+ stop_all_commands
21
21
 
22
22
  next false unless actual.is_a? String
23
23
 
@@ -40,7 +40,7 @@ require 'rspec/expectations/version'
40
40
  # end
41
41
  RSpec::Matchers.define :have_file_content do |expected|
42
42
  match do |actual|
43
- stop_processes!
43
+ stop_all_commands
44
44
 
45
45
  next false unless file? actual
46
46
 
@@ -22,12 +22,12 @@ require 'rspec/expectations/version'
22
22
  # end
23
23
  RSpec::Matchers.define :have_file_size do |expected|
24
24
  match do |actual|
25
- stop_processes!
25
+ stop_all_commands
26
26
 
27
27
  next false unless file?(actual)
28
28
 
29
29
  @old_actual = actual
30
- @actual = File.size(expand_path(actual))
30
+ @actual = file_size(actual)
31
31
  @expected = expected.to_i
32
32
 
33
33
  values_match?(@expected, @actual)
@@ -24,7 +24,7 @@ require 'fileutils'
24
24
  # end
25
25
  RSpec::Matchers.define :have_same_file_content_like do |expected|
26
26
  match do |actual|
27
- stop_processes!
27
+ stop_all_commands
28
28
 
29
29
  next false unless file?(actual) && file?(expected)
30
30
 
@@ -34,7 +34,7 @@ RSpec::Matchers.define :have_permissions do |expected|
34
34
  end
35
35
 
36
36
  match do |actual|
37
- stop_processes!
37
+ stop_all_commands
38
38
 
39
39
  @old_actual = actual
40
40
  @actual = permissions(expand_path(@old_actual))
@@ -1,6 +1,5 @@
1
1
  module Aruba
2
- # Create things to make aruba work
3
- module Creators
2
+ module Platforms
4
3
  # Normal File Creator
5
4
  # This class is not meant to be used directly by users.
6
5
  class ArubaFileCreator
@@ -14,7 +13,7 @@ module Aruba
14
13
  #
15
14
  # @param [TrueClass, FalseClass] check_presence (false)
16
15
  # Check if file exist
17
- def write(path, content, check_presence = false)
16
+ def call(path, content, check_presence = false)
18
17
  fail "Expected #{path} to be present" if check_presence && !Aruba.platform.file?(path)
19
18
 
20
19
  Aruba.platform.mkdir(File.dirname(path))
@@ -1,6 +1,5 @@
1
1
  module Aruba
2
- # Create things to make aruba work
3
- module Creators
2
+ module Platforms
4
3
  # Create files with fixed size
5
4
  #
6
5
  # This class is not meant to be used directly by users.
@@ -18,7 +17,7 @@ module Aruba
18
17
  #
19
18
  # @param [TrueClass, FalseClass] check_presence (false)
20
19
  # Check if file exist
21
- def write(path, size, check_presence)
20
+ def call(path, size, check_presence)
22
21
  fail "Expected #{path} to be present" if check_presence && !Aruba.platform.file?(path)
23
22
 
24
23
  Aruba.platform.mkdir(File.dirname(path))
@@ -0,0 +1,23 @@
1
+ require 'aruba/platforms/disk_usage_calculator'
2
+
3
+ module Aruba
4
+ module Platforms
5
+ class DetermineDiskUsage
6
+ def call(*args)
7
+ args = args.flatten
8
+
9
+ physical_block_size = args.pop
10
+ paths = args
11
+
12
+ size = paths.flatten.map do |p|
13
+ DiskUsageCalculator.new.call(
14
+ p.blocks,
15
+ physical_block_size
16
+ )
17
+ end.inject(0, &:+)
18
+
19
+ FileSize.new(size)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,13 @@
1
+ module Aruba
2
+ module Platforms
3
+ class DetermineFileSize
4
+ def call(path)
5
+ return -1 unless File.file? path
6
+
7
+ FileSize.new(
8
+ File.size(path)
9
+ )
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ require 'aruba/file_size'
2
+
3
+ module Aruba
4
+ module Platforms
5
+ class DiskUsageCalculator
6
+ def call(blocks, block_size)
7
+ Aruba::FileSize.new(blocks * block_size)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ module Aruba
2
+ module Platforms
3
+ class LocalEnvironment
4
+ def call(env, &block)
5
+ old_env = ENV.to_hash.dup
6
+ ENV.update env
7
+
8
+ block.call if block_given?
9
+ ensure
10
+ ENV.clear
11
+ ENV.update old_env
12
+ end
13
+ end
14
+ end
15
+ end
@@ -2,7 +2,7 @@ module Aruba
2
2
  module Platforms
3
3
  class UnixEnvironmentVariables
4
4
  # We need to use this, because `nil` is a valid value as default
5
- UNDEFINED = Object.new
5
+ UNDEFINED = Object.new.freeze
6
6
 
7
7
  private
8
8
 
@@ -1,9 +1,16 @@
1
1
  require 'rbconfig'
2
2
  require 'pathname'
3
3
 
4
+ require 'aruba/aruba_path'
5
+
4
6
  require 'aruba/platforms/simple_table'
5
7
  require 'aruba/platforms/unix_command_string'
6
8
  require 'aruba/platforms/unix_which'
9
+ require 'aruba/platforms/determine_file_size'
10
+ require 'aruba/platforms/determine_disk_usage'
11
+ require 'aruba/platforms/aruba_file_creator'
12
+ require 'aruba/platforms/aruba_fixed_size_file_creator'
13
+ require 'aruba/platforms/local_environment'
7
14
 
8
15
  module Aruba
9
16
  # This abstracts OS-specific things
@@ -28,6 +35,26 @@ module Aruba
28
35
  UnixCommandString
29
36
  end
30
37
 
38
+ def determine_file_size(*args)
39
+ DetermineFileSize.new.call(*args)
40
+ end
41
+
42
+ def determine_disk_usage(*args)
43
+ DetermineDiskUsage.new.call(*args)
44
+ end
45
+
46
+ def create_file(*args)
47
+ ArubaFileCreator.new.call(*args)
48
+ end
49
+
50
+ def create_fixed_size_file(*args)
51
+ ArubaFixedSizeFileCreator.new.call(*args)
52
+ end
53
+
54
+ def with_environment(env = {}, &block)
55
+ LocalEnvironment.new.call(env, &block)
56
+ end
57
+
31
58
  def detect_ruby(cmd)
32
59
  if cmd =~ /^ruby\s/
33
60
  cmd.gsub(/^ruby\s/, "#{current_ruby} ")
@@ -83,19 +110,8 @@ module Aruba
83
110
  def chdir(dir_name, &block)
84
111
  dir_name = ::File.expand_path(dir_name.to_s)
85
112
 
86
- begin
87
- if RUBY_VERSION <= '1.9.3'
88
- old_env = ENV.to_hash.dup
89
- else
90
- old_env = ENV.to_h.dup
91
- end
92
-
93
- ENV['OLDPWD'] = getwd
94
- ENV['PWD'] = dir_name
113
+ with_environment 'OLDPWD' => getwd, 'PWD' => dir_name do
95
114
  ::Dir.chdir(dir_name, &block)
96
- ensure
97
- ENV.clear
98
- ENV.update old_env
99
115
  end
100
116
  end
101
117
 
@@ -109,6 +125,11 @@ module Aruba
109
125
  FileUtils.cp_r(args, options)
110
126
  end
111
127
 
128
+ # Move file/directory
129
+ def mv(args, options)
130
+ FileUtils.mv(args, options)
131
+ end
132
+
112
133
  # Change mode of file/directory
113
134
  def chmod(mode, args, options)
114
135
  FileUtils.chmod_R(mode, args, options)
@@ -159,8 +180,8 @@ module Aruba
159
180
  # * /bin/command.sh
160
181
  # * command.sh
161
182
  def relative_command?(path)
162
- p = Pathname.new(path)
163
- p.relative? && p.basename != p
183
+ p = ArubaPath.new(path)
184
+ p.relative? && p.depth > 1
164
185
  end
165
186
 
166
187
  # Check if command is relative
@@ -12,13 +12,28 @@ module Aruba
12
12
  end
13
13
 
14
14
  def last_exit_status
15
+ Aruba.platform.deprecated('The use of "#last_exit_status" is deprecated. Use "last_command_(started|stopped).exit_status" instead')
16
+
15
17
  return @last_exit_status if @last_exit_status
16
- stop_processes!
18
+ all_commands.each { |c| stop_process(c) }
17
19
  @last_exit_status
18
20
  end
19
21
 
22
+ def last_command_stopped
23
+ return @last_command_stopped if @last_command_stopped
24
+
25
+ all_commands.each { |c| stop_process(c) }
26
+
27
+ @last_command_stopped
28
+ end
29
+
30
+ def last_command_started
31
+ processes.last[1]
32
+ end
33
+
20
34
  def stop_process(process)
21
- @last_exit_status = process.stop(announcer)
35
+ @last_command_stopped = process
36
+ @last_exit_status = process.stop(announcer)
22
37
  end
23
38
 
24
39
  def terminate_process!(process)
@@ -26,13 +41,19 @@ module Aruba
26
41
  end
27
42
 
28
43
  def stop_processes!
29
- processes.each do |_, process|
30
- @last_exit_status = stop_process(process)
31
- end
44
+ Aruba.platform.deprecated('The use of "#stop_processes!" is deprecated. Use "#stop_all_commands" instead')
45
+
46
+ stop_all_commands
47
+ end
48
+
49
+ def stop_all_commands
50
+ all_commands.each { |c| c.stop(announcer) }
32
51
  end
33
52
 
34
53
  # Terminate all running processes
35
54
  def terminate_processes
55
+ Aruba.platform.deprecated('The use of "#terminate_processes" is deprecated. Use "#all_commands.each(&:terminate)" instead')
56
+
36
57
  processes.each do |_, process|
37
58
  terminate_process(process)
38
59
  stop_process(process)
@@ -52,6 +73,8 @@ module Aruba
52
73
  end
53
74
 
54
75
  def only_processes
76
+ Aruba.platform.deprecated('The use of "#only_processes" is deprecated. Use "#all_commands" instead')
77
+
55
78
  processes.collect{ |_, process| process }
56
79
  end
57
80
 
@@ -87,7 +110,11 @@ module Aruba
87
110
  # @return [String]
88
111
  # The stdout of all process which have run before
89
112
  def all_stdout
90
- stop_processes!
113
+ # rubocop:disable Metrics/LineLength
114
+ Aruba.platform.deprecated('The use of "#all_stdout" is deprecated. Use `all_commands.map { |c| c.stdout }.join("\n") instead. If you need to check for some output use "expect(all_commands).to have_output_on_stdout /output/" instead')
115
+ # rubocop:enable Metrics/LineLength
116
+
117
+ stop_all_commands
91
118
 
92
119
  if RUBY_VERSION < '1.9'
93
120
  out = ''
@@ -104,7 +131,11 @@ module Aruba
104
131
  # @return [String]
105
132
  # The stderr of all process which have run before
106
133
  def all_stderr
107
- stop_processes!
134
+ # rubocop:disable Metrics/LineLength
135
+ Aruba.platform.deprecated('The use of "#all_stderr" is deprecated. Use `all_commands.map { |c| c.stderr }.join("\n") instead. If you need to check for some output use "expect(all_commands).to have_output_on_stderr /output/" instead')
136
+ # rubocop:enable Metrics/LineLength
137
+
138
+ stop_all_commands
108
139
 
109
140
  if RUBY_VERSION < '1.9'
110
141
  out = ''
@@ -121,11 +152,26 @@ module Aruba
121
152
  # @return [String]
122
153
  # The stderr and stdout of all process which have run before
123
154
  def all_output
155
+ # rubocop:disable Metrics/LineLength
156
+ Aruba.platform.deprecated('The use of "#all_output" is deprecated. Use `all_commands.map { |c| c.output }.join("\n") instead. If you need to check for some output use "expect(all_commands).to have_output /output/" instead')
157
+ # rubocop:enable Metrics/LineLength
158
+
124
159
  all_stdout << all_stderr
125
160
  end
126
161
 
162
+ # Return all commands
163
+ #
164
+ # @return [Array]
165
+ # A list of all commands
166
+ def all_commands
167
+ processes.collect { |_, process| process }
168
+ end
169
+
170
+ # Clear list of processes
127
171
  def clear
128
172
  processes.clear
173
+
174
+ self
129
175
  end
130
176
  end
131
177
  end
@@ -12,6 +12,9 @@ module Aruba
12
12
  @environment = environment
13
13
  @main_class = main_class
14
14
  @exit_status = nil
15
+
16
+ @exit_timeout = exit_timeout
17
+ @io_wait = io_wait
15
18
  end
16
19
 
17
20
  # Return command line
@@ -20,8 +23,8 @@ module Aruba
20
23
  end
21
24
 
22
25
  # Output stderr and stdout
23
- def output
24
- stdout + stderr
26
+ def output(opts = {})
27
+ stdout(opts) + stderr(opts)
25
28
  end
26
29
 
27
30
  def write(*)
@@ -54,17 +57,34 @@ module Aruba
54
57
  @timed_out == true
55
58
  end
56
59
 
60
+ # @deprecated
61
+ # @private
62
+ def run!
63
+ Aruba.platform.deprecated('The use of "command#run!" is deprecated. You can simply use "command#start" instead.')
64
+
65
+ start
66
+ end
67
+
57
68
  # Hook which is run before command is run
58
69
  def before_run; end
59
70
 
60
71
  # Hook which is run after command is run
61
72
  def after_run; end
62
73
 
63
- private
74
+ def inspect
75
+ out = stdout(:wait_for_io => 0) + stderr(:wait_for_io => 0)
76
+
77
+ out = if out.length > 76
78
+ out[0, 75] + ' ...'
79
+ else
80
+ out
81
+ end
64
82
 
65
- def which(program)
66
- Aruba.platform.which(program, environment['PATH'])
83
+ format '#<%s:%s commandline="%s": output="%s">', self.class, self.object_id, commandline, out
67
84
  end
85
+ alias_method :to_s, :inspect
86
+
87
+ private
68
88
 
69
89
  def command
70
90
  Shellwords.split(commandline).first