aruba 0.11.0.pre → 0.11.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/History.md +21 -1
- data/aruba.gemspec +1 -0
- data/features/api/command/find_command.feature +83 -0
- data/features/api/command/last_command_started.feature +50 -0
- data/features/api/command/last_command_stopped.feature +89 -0
- data/features/api/command/run.feature +259 -0
- data/features/api/command/stop.feature +53 -1
- data/features/api/text/replace_variables.feature +1 -1
- data/features/getting_started/run_commands.feature +177 -0
- data/features/matchers/file/be_existing_executable.feature +87 -0
- data/features/{integration/rspec/getting_started.feature → rspec/integration.feature} +31 -0
- data/fixtures/getting-started-app/Gemfile +1 -1
- data/lib/aruba.rb +0 -19
- data/lib/aruba/api.rb +2 -0
- data/lib/aruba/api/command.rb +103 -44
- data/lib/aruba/api/core.rb +13 -8
- data/lib/aruba/api/deprecated.rb +26 -4
- data/lib/aruba/api/environment.rb +21 -13
- data/lib/aruba/api/filesystem.rb +13 -0
- data/lib/aruba/api/rvm.rb +5 -0
- data/lib/aruba/api/text.rb +7 -1
- data/lib/aruba/aruba_path.rb +6 -0
- data/lib/aruba/basic_configuration.rb +35 -3
- data/lib/aruba/basic_configuration/option.rb +7 -0
- data/lib/aruba/cli.rb +4 -0
- data/lib/aruba/command.rb +47 -1
- data/lib/aruba/config.rb +15 -2
- data/lib/aruba/config_wrapper.rb +49 -8
- data/lib/aruba/console.rb +4 -1
- data/lib/aruba/console/help.rb +2 -0
- data/lib/aruba/contracts/absolute_path.rb +7 -0
- data/lib/aruba/contracts/enum.rb +5 -0
- data/lib/aruba/contracts/is_power_of_two.rb +9 -2
- data/lib/aruba/contracts/relative_path.rb +7 -0
- data/lib/aruba/cucumber/command.rb +6 -9
- data/lib/aruba/cucumber/file.rb +1 -1
- data/lib/aruba/cucumber/hooks.rb +36 -29
- data/lib/aruba/errors.rb +16 -1
- data/lib/aruba/events.rb +39 -0
- data/lib/aruba/extensions/string/strip.rb +1 -0
- data/lib/aruba/file_size.rb +11 -0
- data/lib/aruba/hooks.rb +2 -0
- data/lib/aruba/in_config_wrapper.rb +24 -0
- data/lib/aruba/in_process.rb +2 -0
- data/lib/aruba/initializer.rb +37 -0
- data/lib/aruba/matchers/base/base_matcher.rb +2 -0
- data/lib/aruba/matchers/base/object_formatter.rb +4 -0
- data/lib/aruba/matchers/collection/all.rb +2 -0
- data/lib/aruba/matchers/collection/include_an_object.rb +2 -0
- data/lib/aruba/matchers/command/have_exit_status.rb +1 -1
- data/lib/aruba/matchers/command/have_finished_in_time.rb +1 -10
- data/lib/aruba/matchers/command/have_output.rb +1 -10
- data/lib/aruba/matchers/command/have_output_on_stderr.rb +1 -10
- data/lib/aruba/matchers/command/have_output_on_stdout.rb +1 -10
- data/lib/aruba/matchers/file/be_an_existing_executable.rb +37 -0
- data/lib/aruba/platform.rb +4 -0
- data/lib/aruba/platforms/announcer.rb +225 -0
- data/lib/aruba/platforms/aruba_file_creator.rb +4 -0
- data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +4 -0
- data/lib/aruba/{aruba_logger.rb → platforms/aruba_logger.rb} +4 -0
- data/lib/aruba/platforms/command_monitor.rb +229 -0
- data/lib/aruba/platforms/determine_disk_usage.rb +5 -0
- data/lib/aruba/platforms/determine_file_size.rb +9 -0
- data/lib/aruba/platforms/disk_usage_calculator.rb +9 -0
- data/lib/aruba/platforms/local_environment.rb +12 -0
- data/lib/aruba/platforms/simple_table.rb +11 -0
- data/lib/aruba/platforms/unix_command_string.rb +3 -0
- data/lib/aruba/platforms/unix_environment_variables.rb +3 -0
- data/lib/aruba/platforms/unix_platform.rb +20 -2
- data/lib/aruba/platforms/unix_which.rb +6 -2
- data/lib/aruba/platforms/windows_command_string.rb +7 -0
- data/lib/aruba/platforms/windows_environment_variables.rb +2 -0
- data/lib/aruba/platforms/windows_platform.rb +3 -0
- data/lib/aruba/platforms/windows_which.rb +6 -2
- data/lib/aruba/processes/basic_process.rb +20 -5
- data/lib/aruba/processes/debug_process.rb +3 -1
- data/lib/aruba/processes/in_process.rb +18 -2
- data/lib/aruba/processes/spawn_process.rb +14 -13
- data/lib/aruba/rspec.rb +34 -23
- data/lib/aruba/runtime.rb +65 -6
- data/lib/aruba/setup.rb +87 -0
- data/lib/aruba/version.rb +1 -1
- data/spec/aruba/api_spec.rb +13 -36
- data/spec/aruba/{config_wrapper_spec.rb → in_config_wrapper_spec.rb} +1 -1
- data/spec/aruba/spawn_process_spec.rb +9 -14
- data/spec/support/configs/pry.rb +3 -0
- data/spec/support/shared_contexts/aruba.rb +1 -0
- metadata +40 -14
- data/features/getting_started/supported_programming_languages.feature +0 -89
- data/lib/aruba/announcer.rb +0 -219
- data/lib/aruba/matchers/rspec.rb +0 -0
- data/lib/aruba/process_monitor.rb +0 -201
- data/lib/aruba/processes/null_process.rb +0 -26
@@ -1,4 +1,6 @@
|
|
1
|
+
# Aruba
|
1
2
|
module Aruba
|
3
|
+
# Platforms
|
2
4
|
module Platforms
|
3
5
|
# Create files with fixed size
|
4
6
|
#
|
@@ -6,6 +8,8 @@ module Aruba
|
|
6
8
|
#
|
7
9
|
# It uses a single null byte as content and really creates so called sparse
|
8
10
|
# files.
|
11
|
+
#
|
12
|
+
# @private
|
9
13
|
class ArubaFixedSizeFileCreator
|
10
14
|
# Write File
|
11
15
|
#
|
@@ -0,0 +1,229 @@
|
|
1
|
+
require 'aruba/errors'
|
2
|
+
|
3
|
+
# Aruba
|
4
|
+
module Aruba
|
5
|
+
# The command monitor is part of the private API of Aruba.
|
6
|
+
#
|
7
|
+
# @private
|
8
|
+
class CommandMonitor
|
9
|
+
private
|
10
|
+
|
11
|
+
attr_reader :announcer
|
12
|
+
|
13
|
+
public
|
14
|
+
|
15
|
+
attr_reader :registered_commands, :last_command_started
|
16
|
+
|
17
|
+
class DefaultLastCommandStopped
|
18
|
+
def nil?
|
19
|
+
true
|
20
|
+
end
|
21
|
+
|
22
|
+
def method_missing(*)
|
23
|
+
fail NoCommandHasBeenStoppedError, 'No last command stopped available'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class DefaultLastCommandStarted
|
28
|
+
def nil?
|
29
|
+
true
|
30
|
+
end
|
31
|
+
|
32
|
+
def method_missing(*)
|
33
|
+
fail NoCommandHasBeenStartedError, 'No last command started available'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# rubocop:disable Metrics/MethodLength
|
38
|
+
def initialize(opts = {})
|
39
|
+
@registered_commands = []
|
40
|
+
@announcer = opts.fetch(:announcer)
|
41
|
+
|
42
|
+
@last_command_stopped = DefaultLastCommandStopped.new
|
43
|
+
@last_command_started = DefaultLastCommandStarted.new
|
44
|
+
|
45
|
+
rescue KeyError => e
|
46
|
+
raise ArgumentError, e.message
|
47
|
+
end
|
48
|
+
|
49
|
+
if Aruba::VERSION < '1'
|
50
|
+
# Return the last command stopped
|
51
|
+
def last_command_stopped
|
52
|
+
return @last_command_stopped unless @last_command_stopped.nil?
|
53
|
+
|
54
|
+
registered_commands.each(&:stop)
|
55
|
+
|
56
|
+
@last_command_stopped
|
57
|
+
end
|
58
|
+
else
|
59
|
+
attr_reader :last_command_stopped
|
60
|
+
end
|
61
|
+
|
62
|
+
# Set last command started
|
63
|
+
#
|
64
|
+
# @param [String] cmd
|
65
|
+
# The commandline of the command
|
66
|
+
def last_command_started=(cmd)
|
67
|
+
@last_command_started = find(cmd)
|
68
|
+
end
|
69
|
+
|
70
|
+
# Set last command started
|
71
|
+
#
|
72
|
+
# @param [String] cmd
|
73
|
+
# The commandline of the command
|
74
|
+
def last_command_stopped=(cmd)
|
75
|
+
@last_command_stopped = find(cmd)
|
76
|
+
end
|
77
|
+
|
78
|
+
# Find command
|
79
|
+
#
|
80
|
+
# @yield [Command]
|
81
|
+
# This yields the found command
|
82
|
+
def find(cmd)
|
83
|
+
cmd = cmd.commandline if cmd.respond_to? :commandline
|
84
|
+
command = registered_commands.reverse.find { |c| c.commandline == cmd }
|
85
|
+
|
86
|
+
fail CommandNotFoundError, "No command named '#{cmd}' has been started" if command.nil?
|
87
|
+
|
88
|
+
command
|
89
|
+
end
|
90
|
+
|
91
|
+
# Clear list of known commands
|
92
|
+
def clear
|
93
|
+
registered_commands.each(&:terminate)
|
94
|
+
registered_commands.clear
|
95
|
+
|
96
|
+
self
|
97
|
+
end
|
98
|
+
|
99
|
+
# @deprecated
|
100
|
+
# Fetch output (stdout, stderr) from command
|
101
|
+
#
|
102
|
+
# @param [String] cmd
|
103
|
+
# The command
|
104
|
+
def output_from(cmd)
|
105
|
+
cmd = Utils.detect_ruby(cmd)
|
106
|
+
find(cmd).output
|
107
|
+
end
|
108
|
+
|
109
|
+
# @deprecated
|
110
|
+
# Fetch stdout from command
|
111
|
+
#
|
112
|
+
# @param [String] cmd
|
113
|
+
# The command
|
114
|
+
def stdout_from(cmd)
|
115
|
+
cmd = Utils.detect_ruby(cmd)
|
116
|
+
find(cmd).stdout
|
117
|
+
end
|
118
|
+
|
119
|
+
# @deprecated
|
120
|
+
# Fetch stderr from command
|
121
|
+
#
|
122
|
+
# @param [String] cmd
|
123
|
+
# The command
|
124
|
+
def stderr_from(cmd)
|
125
|
+
cmd = Utils.detect_ruby(cmd)
|
126
|
+
find(cmd).stderr
|
127
|
+
end
|
128
|
+
|
129
|
+
# @deprecated
|
130
|
+
# Get stdout of all commands
|
131
|
+
#
|
132
|
+
# @return [String]
|
133
|
+
# The stdout of all command which have run before
|
134
|
+
def all_stdout
|
135
|
+
registered_commands.each(&:stop)
|
136
|
+
|
137
|
+
if RUBY_VERSION < '1.9.3'
|
138
|
+
# rubocop:disable Style/EachWithObject
|
139
|
+
registered_commands.inject("") { |a, e| a << e.stdout; a }
|
140
|
+
# rubocop:enable Style/EachWithObject
|
141
|
+
else
|
142
|
+
registered_commands.each_with_object("") { |e, a| a << e.stdout }
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
# @deprecated
|
147
|
+
# Get stderr of all commands
|
148
|
+
#
|
149
|
+
# @return [String]
|
150
|
+
# The stderr of all command which have run before
|
151
|
+
def all_stderr
|
152
|
+
registered_commands.each(&:stop)
|
153
|
+
|
154
|
+
if RUBY_VERSION < '1.9.3'
|
155
|
+
# rubocop:disable Style/EachWithObject
|
156
|
+
registered_commands.inject("") { |a, e| a << e.stderr; a }
|
157
|
+
# rubocop:enable Style/EachWithObject
|
158
|
+
else
|
159
|
+
registered_commands.each_with_object("") { |e, a| a << e.stderr }
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
# @deprecated
|
164
|
+
# Get stderr and stdout of all commands
|
165
|
+
#
|
166
|
+
# @return [String]
|
167
|
+
# The stderr and stdout of all command which have run before
|
168
|
+
def all_output
|
169
|
+
all_stdout << all_stderr
|
170
|
+
end
|
171
|
+
|
172
|
+
# @deprecated
|
173
|
+
def last_exit_status
|
174
|
+
Aruba.platform.deprecated('The use of "#last_exit_status" is deprecated. Use "last_command_(started|stopped).exit_status" instead')
|
175
|
+
|
176
|
+
return @last_exit_status if @last_exit_status
|
177
|
+
registered_commands.each(&:stop)
|
178
|
+
@last_exit_status
|
179
|
+
end
|
180
|
+
|
181
|
+
# @deprecated
|
182
|
+
def stop_process(process)
|
183
|
+
@last_command_stopped = process
|
184
|
+
@last_exit_status = process.stop(announcer)
|
185
|
+
end
|
186
|
+
|
187
|
+
# @deprecated
|
188
|
+
def terminate_process!(process)
|
189
|
+
process.terminate
|
190
|
+
end
|
191
|
+
|
192
|
+
# @deprecated
|
193
|
+
def stop_processes!
|
194
|
+
Aruba.platform.deprecated('The use of "#stop_processes!" is deprecated.')
|
195
|
+
|
196
|
+
registered_commands.each(&:stop)
|
197
|
+
end
|
198
|
+
|
199
|
+
# @deprecated
|
200
|
+
# Terminate all running processes
|
201
|
+
def terminate_processes
|
202
|
+
Aruba.platform.deprecated('The use of "#terminate_processes" is deprecated.')
|
203
|
+
|
204
|
+
registered_commands.each(&:terminate)
|
205
|
+
end
|
206
|
+
|
207
|
+
# @deprecated
|
208
|
+
def only_processes
|
209
|
+
Aruba.platform.deprecated('The use of "#only_processes" is deprecated.')
|
210
|
+
|
211
|
+
registered_commands
|
212
|
+
end
|
213
|
+
|
214
|
+
# @deprecated
|
215
|
+
def get_process(wanted)
|
216
|
+
command = find(wanted)
|
217
|
+
raise ArgumentError.new("No process named '#{wanted}' has been started") unless command
|
218
|
+
|
219
|
+
command
|
220
|
+
end
|
221
|
+
|
222
|
+
# Register command to monitor
|
223
|
+
def register_command(cmd)
|
224
|
+
registered_commands << cmd
|
225
|
+
|
226
|
+
self
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
@@ -1,5 +1,14 @@
|
|
1
|
+
# Aruba
|
1
2
|
module Aruba
|
3
|
+
# Platforms
|
2
4
|
module Platforms
|
5
|
+
# Determine size of a file
|
6
|
+
#
|
7
|
+
# @param [String] path
|
8
|
+
# The path to file
|
9
|
+
#
|
10
|
+
# @return [Integer]
|
11
|
+
# Returns size if exists. Returns -1 if path does not exist
|
3
12
|
class DetermineFileSize
|
4
13
|
def call(path)
|
5
14
|
return -1 unless File.file? path
|
@@ -1,8 +1,17 @@
|
|
1
1
|
require 'aruba/file_size'
|
2
2
|
|
3
|
+
# Aruba
|
3
4
|
module Aruba
|
5
|
+
# Platforms
|
4
6
|
module Platforms
|
7
|
+
# Calculate disk usage
|
5
8
|
class DiskUsageCalculator
|
9
|
+
# Calc
|
10
|
+
#
|
11
|
+
# @param [Integer] blocks
|
12
|
+
# Count of blocks
|
13
|
+
# @param [Integer] block_size
|
14
|
+
# The size of a single block
|
6
15
|
def call(blocks, block_size)
|
7
16
|
Aruba::FileSize.new(blocks * block_size)
|
8
17
|
end
|
@@ -1,6 +1,18 @@
|
|
1
|
+
# Aruba
|
1
2
|
module Aruba
|
3
|
+
# Platforms
|
2
4
|
module Platforms
|
5
|
+
# Local environemnt
|
6
|
+
#
|
7
|
+
# Wraps logic to make enviroment local and restorable
|
3
8
|
class LocalEnvironment
|
9
|
+
# Run in environment
|
10
|
+
#
|
11
|
+
# @param [Hash] env
|
12
|
+
# The environment
|
13
|
+
#
|
14
|
+
# @yield
|
15
|
+
# The block of code which should with local ENV
|
4
16
|
def call(env, &block)
|
5
17
|
old_env = ENV.to_hash.dup
|
6
18
|
|
@@ -1,5 +1,8 @@
|
|
1
|
+
# Aruba
|
1
2
|
module Aruba
|
3
|
+
# Platforms
|
2
4
|
module Platforms
|
5
|
+
# Generate simple table
|
3
6
|
class SimpleTable
|
4
7
|
private
|
5
8
|
|
@@ -7,10 +10,18 @@ module Aruba
|
|
7
10
|
|
8
11
|
public
|
9
12
|
|
13
|
+
# Create
|
14
|
+
#
|
15
|
+
# @param [Hash] hash
|
16
|
+
# Input
|
10
17
|
def initialize(hash)
|
11
18
|
@hash = hash
|
12
19
|
end
|
13
20
|
|
21
|
+
# Generate table
|
22
|
+
#
|
23
|
+
# @return [String]
|
24
|
+
# The table
|
14
25
|
def to_s
|
15
26
|
longest_key = hash.keys.map(&:to_s).max_by(&:length)
|
16
27
|
return [] if longest_key.nil?
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'delegate'
|
2
2
|
require 'shellwords'
|
3
3
|
|
4
|
+
# Aruba
|
4
5
|
module Aruba
|
6
|
+
# Platforms
|
5
7
|
module Platforms
|
6
8
|
# This is a command which should be run
|
7
9
|
class UnixCommandString < SimpleDelegator
|
@@ -9,6 +11,7 @@ module Aruba
|
|
9
11
|
__setobj__ cmd
|
10
12
|
end
|
11
13
|
|
14
|
+
# Convert to array
|
12
15
|
def to_a
|
13
16
|
Shellwords.split __getobj__
|
14
17
|
end
|
@@ -11,7 +11,11 @@ require 'aruba/platforms/determine_disk_usage'
|
|
11
11
|
require 'aruba/platforms/aruba_file_creator'
|
12
12
|
require 'aruba/platforms/aruba_fixed_size_file_creator'
|
13
13
|
require 'aruba/platforms/local_environment'
|
14
|
+
require 'aruba/platforms/aruba_logger'
|
15
|
+
require 'aruba/platforms/announcer'
|
16
|
+
require 'aruba/platforms/command_monitor'
|
14
17
|
|
18
|
+
# Aruba
|
15
19
|
module Aruba
|
16
20
|
# This abstracts OS-specific things
|
17
21
|
module Platforms
|
@@ -22,6 +26,8 @@ module Aruba
|
|
22
26
|
# any further notice.
|
23
27
|
#
|
24
28
|
# This includes all methods for the UNIX platform
|
29
|
+
#
|
30
|
+
# @private
|
25
31
|
class UnixPlatform
|
26
32
|
def self.match?
|
27
33
|
!FFI::Platform.windows?
|
@@ -35,6 +41,18 @@ module Aruba
|
|
35
41
|
UnixCommandString
|
36
42
|
end
|
37
43
|
|
44
|
+
def announcer
|
45
|
+
Announcer
|
46
|
+
end
|
47
|
+
|
48
|
+
def command_monitor
|
49
|
+
CommandMonitor
|
50
|
+
end
|
51
|
+
|
52
|
+
def logger
|
53
|
+
ArubaLogger
|
54
|
+
end
|
55
|
+
|
38
56
|
def determine_file_size(*args)
|
39
57
|
DetermineFileSize.new.call(*args)
|
40
58
|
end
|
@@ -151,8 +169,8 @@ module Aruba
|
|
151
169
|
end
|
152
170
|
|
153
171
|
# Path is executable
|
154
|
-
def
|
155
|
-
File.
|
172
|
+
def executable?(f)
|
173
|
+
File.executable?(f)
|
156
174
|
end
|
157
175
|
|
158
176
|
# Expand path
|