aruba 2.1.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +90 -39
- data/CONTRIBUTING.md +0 -1
- data/LICENSE +19 -17
- data/README.md +5 -6
- data/exe/aruba +3 -2
- data/lib/aruba/api/bundler.rb +4 -2
- data/lib/aruba/api/commands.rb +10 -8
- data/lib/aruba/api/core.rb +34 -32
- data/lib/aruba/api/environment.rb +4 -2
- data/lib/aruba/api/filesystem.rb +17 -19
- data/lib/aruba/api/text.rb +5 -3
- data/lib/aruba/api.rb +13 -11
- data/lib/aruba/{platforms/aruba_logger.rb → aruba_logger.rb} +4 -2
- data/lib/aruba/aruba_path.rb +4 -2
- data/lib/aruba/basic_configuration/option.rb +2 -0
- data/lib/aruba/basic_configuration.rb +15 -13
- data/lib/aruba/cli.rb +10 -8
- data/lib/aruba/colorizer.rb +2 -0
- data/lib/aruba/command.rb +10 -6
- data/lib/aruba/{platforms/command_monitor.rb → command_monitor.rb} +7 -5
- data/lib/aruba/config/jruby.rb +11 -9
- data/lib/aruba/config_wrapper.rb +4 -2
- data/lib/aruba/configuration.rb +17 -15
- data/lib/aruba/console/help.rb +7 -5
- data/lib/aruba/console.rb +12 -11
- data/lib/aruba/contracts/absolute_path.rb +3 -1
- data/lib/aruba/contracts/enum.rb +3 -1
- data/lib/aruba/contracts/is_power_of_two.rb +4 -2
- data/lib/aruba/contracts/relative_path.rb +3 -1
- data/lib/aruba/cucumber/command.rb +108 -99
- data/lib/aruba/cucumber/environment.rb +9 -7
- data/lib/aruba/cucumber/file.rb +4 -2
- data/lib/aruba/cucumber/hooks.rb +31 -29
- data/lib/aruba/cucumber/parameter_types.rb +4 -1
- data/lib/aruba/cucumber/testing_frameworks.rb +20 -18
- data/lib/aruba/cucumber.rb +10 -8
- data/lib/aruba/errors.rb +2 -6
- data/lib/aruba/event_bus.rb +8 -47
- data/lib/aruba/events.rb +15 -7
- data/lib/aruba/file_size.rb +3 -1
- data/lib/aruba/generators/script_file.rb +4 -2
- data/lib/aruba/hooks.rb +2 -0
- data/lib/aruba/in_config_wrapper.rb +3 -1
- data/lib/aruba/initializer.rb +25 -42
- data/lib/aruba/matchers/base/message_indenter.rb +3 -1
- data/lib/aruba/matchers/command/be_successfully_executed.rb +6 -4
- data/lib/aruba/matchers/command/have_exit_status.rb +2 -0
- data/lib/aruba/matchers/command/have_finished_in_time.rb +2 -0
- data/lib/aruba/matchers/command/have_output.rb +3 -1
- data/lib/aruba/matchers/command/have_output_on_stderr.rb +2 -0
- data/lib/aruba/matchers/command/have_output_on_stdout.rb +2 -0
- data/lib/aruba/matchers/command/have_output_size.rb +21 -5
- data/lib/aruba/matchers/command.rb +3 -1
- data/lib/aruba/matchers/directory/be_an_existing_directory.rb +3 -1
- data/lib/aruba/matchers/directory/have_sub_directory.rb +4 -2
- data/lib/aruba/matchers/directory.rb +3 -1
- data/lib/aruba/matchers/environment.rb +3 -1
- data/lib/aruba/matchers/file/be_a_command_found_in_path.rb +7 -5
- data/lib/aruba/matchers/file/be_an_existing_executable.rb +3 -1
- data/lib/aruba/matchers/file/be_an_existing_file.rb +3 -1
- data/lib/aruba/matchers/file/have_file_content.rb +2 -0
- data/lib/aruba/matchers/file/have_file_size.rb +2 -0
- data/lib/aruba/matchers/file/have_same_file_content.rb +3 -1
- data/lib/aruba/matchers/file.rb +3 -1
- data/lib/aruba/matchers/path/a_path_matching_pattern.rb +2 -0
- data/lib/aruba/matchers/path/be_an_absolute_path.rb +2 -0
- data/lib/aruba/matchers/path/be_an_existing_path.rb +2 -0
- data/lib/aruba/matchers/path/have_permissions.rb +3 -1
- data/lib/aruba/matchers/path.rb +3 -1
- data/lib/aruba/matchers/string/include_output_string.rb +3 -1
- data/lib/aruba/matchers/string/match_output_string.rb +3 -1
- data/lib/aruba/matchers/string/output_string_eq.rb +3 -1
- data/lib/aruba/matchers/string.rb +3 -1
- data/lib/aruba/platform.rb +4 -2
- data/lib/aruba/platforms/announcer.rb +16 -14
- data/lib/aruba/platforms/aruba_file_creator.rb +2 -0
- data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +3 -1
- data/lib/aruba/platforms/determine_disk_usage.rb +3 -1
- data/lib/aruba/platforms/determine_file_size.rb +2 -0
- data/lib/aruba/platforms/filesystem_status.rb +3 -1
- data/lib/aruba/platforms/local_environment.rb +9 -1
- data/lib/aruba/platforms/simple_table.rb +4 -2
- data/lib/aruba/platforms/unix_command_string.rb +4 -2
- data/lib/aruba/platforms/unix_environment_variables.rb +4 -2
- data/lib/aruba/platforms/unix_platform.rb +32 -26
- data/lib/aruba/platforms/unix_which.rb +3 -1
- data/lib/aruba/platforms/windows_command_string.rb +3 -18
- data/lib/aruba/platforms/windows_environment_variables.rb +3 -1
- data/lib/aruba/platforms/windows_platform.rb +12 -6
- data/lib/aruba/platforms/windows_which.rb +7 -5
- data/lib/aruba/processes/basic_process.rb +5 -3
- data/lib/aruba/processes/debug_process.rb +8 -6
- data/lib/aruba/processes/in_process.rb +11 -8
- data/lib/aruba/processes/spawn_process.rb +110 -37
- data/lib/aruba/rspec.rb +8 -6
- data/lib/aruba/runtime.rb +9 -7
- data/lib/aruba/setup.rb +8 -6
- data/lib/aruba/version.rb +3 -1
- data/lib/aruba.rb +3 -1
- metadata +24 -99
- data/lib/aruba/event_bus/name_resolver.rb +0 -158
@@ -1,5 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aruba/matchers/command/have_exit_status'
|
4
|
+
require 'aruba/matchers/command/have_finished_in_time'
|
3
5
|
|
4
6
|
# @!method be_successfuly_executed
|
5
7
|
# This matchers checks if execution of <command> was successful
|
@@ -27,8 +29,8 @@ RSpec::Matchers.define :be_successfully_executed do
|
|
27
29
|
end
|
28
30
|
|
29
31
|
failure_message do |_actual|
|
30
|
-
"Expected `#{@actual}` to succeed" \
|
31
|
-
|
32
|
+
"Expected `#{@actual}` to succeed " \
|
33
|
+
'but got non-zero exit status and the following output:' \
|
32
34
|
"\n\n#{@old_actual.output}\n"
|
33
35
|
end
|
34
36
|
end
|
@@ -1,8 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# @!method have_output_size(output)
|
2
4
|
# This matchers checks if output has size.
|
3
5
|
#
|
4
|
-
# @param [String] output
|
5
|
-
# The content which should be checked
|
6
|
+
# @param [String,Aruba::Process:BasicProcess] output or process
|
7
|
+
# The content which should be checked, or the process whose output should be checked
|
8
|
+
#
|
9
|
+
# Use of this matcher with a string is deprecated.
|
6
10
|
#
|
7
11
|
# @return [Boolean] The result
|
8
12
|
#
|
@@ -16,12 +20,24 @@
|
|
16
20
|
# RSpec.describe do
|
17
21
|
# it { expect(file1).to have_output_size(256) }
|
18
22
|
# end
|
23
|
+
#
|
24
|
+
# RSpec.describe do
|
25
|
+
# it { expect(last_command_started).to have_output_size(256) }
|
26
|
+
# end
|
19
27
|
RSpec::Matchers.define :have_output_size do |expected|
|
20
28
|
match do |actual|
|
21
|
-
|
29
|
+
if actual.respond_to? :size
|
30
|
+
Aruba.platform.deprecated \
|
31
|
+
'Application of the have_output_size matcher to a string is deprecated. ' \
|
32
|
+
'Apply the matcher directly to the process object instead'
|
33
|
+
actual_size = actual.size
|
34
|
+
elsif actual.respond_to? :output
|
35
|
+
actual_size = actual.output.size
|
36
|
+
else
|
37
|
+
raise "Expected #{actual} to respond to #size or #output"
|
38
|
+
end
|
22
39
|
|
23
|
-
|
24
|
-
values_match? expected, @actual
|
40
|
+
values_match? expected, actual_size
|
25
41
|
end
|
26
42
|
|
27
43
|
description { "output has size #{description_of expected}" }
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# @!method be_an_existing_directory
|
2
4
|
# This matchers checks if <directory> exists in filesystem
|
3
5
|
#
|
@@ -17,7 +19,7 @@ RSpec::Matchers.define :be_an_existing_directory do |_|
|
|
17
19
|
match do |actual|
|
18
20
|
stop_all_commands
|
19
21
|
|
20
|
-
raise
|
22
|
+
raise 'String expected' unless actual.is_a? String
|
21
23
|
|
22
24
|
directory?(actual)
|
23
25
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# @!method have_sub_directory(sub_directory)
|
2
4
|
# This matchers checks if <directory> has given sub-directory
|
3
5
|
#
|
@@ -40,13 +42,13 @@ RSpec::Matchers.define :have_sub_directory do |expected|
|
|
40
42
|
|
41
43
|
failure_message do |actual|
|
42
44
|
format('expected that directory "%s" has the following sub-directories: %s.',
|
43
|
-
actual.join(
|
45
|
+
actual.join(', '),
|
44
46
|
expected)
|
45
47
|
end
|
46
48
|
|
47
49
|
failure_message_when_negated do |actual|
|
48
50
|
format('expected that directory "%s" does not have the following sub-directories: %s.',
|
49
|
-
actual.join(
|
51
|
+
actual.join(', '),
|
50
52
|
expected)
|
51
53
|
end
|
52
54
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# @!method be_a_command_found_in_path
|
2
4
|
# This matchers checks if <command> can be found in path
|
3
5
|
#
|
@@ -15,17 +17,17 @@
|
|
15
17
|
# end
|
16
18
|
RSpec::Matchers.define :be_a_command_found_in_path do
|
17
19
|
match do |actual|
|
18
|
-
|
19
|
-
|
20
|
-
!which(@actual).nil?
|
20
|
+
!which(actual).nil?
|
21
21
|
end
|
22
22
|
|
23
23
|
failure_message do |actual|
|
24
|
-
format(%(expected that command "%s" can be found in PATH "
|
24
|
+
format(%(expected that command "%s" can be found in PATH "%s".),
|
25
|
+
actual, aruba.environment['PATH'])
|
25
26
|
end
|
26
27
|
|
27
28
|
failure_message_when_negated do |actual|
|
28
|
-
format(%(expected that command "%s" cannot be found in PATH "
|
29
|
+
format(%(expected that command "%s" cannot be found in PATH "%s".),
|
30
|
+
actual, aruba.environment['PATH'])
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# @!method be_an_existing_file
|
2
4
|
# This matchers checks if <file> exists in filesystem
|
3
5
|
#
|
@@ -17,7 +19,7 @@ RSpec::Matchers.define :be_an_existing_file do |_|
|
|
17
19
|
match do |actual|
|
18
20
|
stop_all_commands
|
19
21
|
|
20
|
-
raise
|
22
|
+
raise 'String expected' unless actual.is_a? String
|
21
23
|
|
22
24
|
file?(actual)
|
23
25
|
end
|
data/lib/aruba/matchers/file.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# @!method have_permissions(permissions)
|
2
4
|
# This matchers checks if <file> or <directory> has <perm> permissions
|
3
5
|
#
|
@@ -41,7 +43,7 @@ RSpec::Matchers.define :have_permissions do |expected|
|
|
41
43
|
when Integer
|
42
44
|
expected.to_s(8)
|
43
45
|
when String
|
44
|
-
expected.gsub(/^0*/,
|
46
|
+
expected.gsub(/^0*/, '')
|
45
47
|
else
|
46
48
|
expected
|
47
49
|
end
|
data/lib/aruba/matchers/path.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# @!method include_output_string(string)
|
2
4
|
# This matchers checks if the output string of a command includes string.
|
3
5
|
#
|
@@ -18,7 +20,7 @@
|
|
18
20
|
# end
|
19
21
|
RSpec::Matchers.define :include_output_string do |expected|
|
20
22
|
match do |actual|
|
21
|
-
actual.force_encoding(
|
23
|
+
actual.force_encoding('UTF-8')
|
22
24
|
@expected = Regexp.new(Regexp.escape(sanitize_text(expected.to_s)), Regexp::MULTILINE)
|
23
25
|
@actual = sanitize_text(actual)
|
24
26
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# @!method match_output_string(string)
|
2
4
|
# This matchers checks if the output string of a command matches regular expression.
|
3
5
|
#
|
@@ -18,7 +20,7 @@
|
|
18
20
|
# end
|
19
21
|
RSpec::Matchers.define :match_output_string do |expected|
|
20
22
|
match do |actual|
|
21
|
-
actual.force_encoding(
|
23
|
+
actual.force_encoding('UTF-8')
|
22
24
|
@expected = Regexp.new(unescape_text(expected), Regexp::MULTILINE)
|
23
25
|
@actual = sanitize_text(actual)
|
24
26
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# @!method output_string_eq(string)
|
2
4
|
# This matchers checks if the output string of a command includes string.
|
3
5
|
#
|
@@ -18,7 +20,7 @@
|
|
18
20
|
# end
|
19
21
|
RSpec::Matchers.define :output_string_eq do |expected|
|
20
22
|
match do |actual|
|
21
|
-
actual.force_encoding(
|
23
|
+
actual.force_encoding('UTF-8')
|
22
24
|
@expected = sanitize_text(expected.to_s)
|
23
25
|
@actual = sanitize_text(actual.to_s)
|
24
26
|
|
data/lib/aruba/platform.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
|
2
|
-
require "aruba/colorizer"
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
3
|
+
require 'shellwords'
|
4
|
+
require 'aruba/colorizer'
|
5
|
+
|
6
|
+
Aruba::Colorizer.coloring = false if !$stdout.tty? && !ENV.key?('AUTOTEST')
|
5
7
|
|
6
8
|
# Aruba
|
7
9
|
module Aruba
|
@@ -81,29 +83,29 @@ module Aruba
|
|
81
83
|
private
|
82
84
|
|
83
85
|
def after_init
|
84
|
-
output_format :changed_configuration, proc { |n, v| format(
|
86
|
+
output_format :changed_configuration, proc { |n, v| format('# %s = %s', n, v) }
|
85
87
|
output_format :changed_environment,
|
86
|
-
proc { |n, v| format(
|
87
|
-
output_format :command,
|
88
|
-
output_format :directory,
|
88
|
+
proc { |n, v| format('$ export %s=%s', n, Shellwords.escape(v)) }
|
89
|
+
output_format :command, '$ %s'
|
90
|
+
output_format :directory, '$ cd %s'
|
89
91
|
output_format :environment,
|
90
|
-
proc { |n, v| format(
|
92
|
+
proc { |n, v| format('$ export %s=%s', n, Shellwords.escape(v)) }
|
91
93
|
output_format :full_environment,
|
92
94
|
proc { |h|
|
93
95
|
format("<<-ENVIRONMENT\n%s\nENVIRONMENT",
|
94
96
|
Aruba.platform.simple_table(h))
|
95
97
|
}
|
96
98
|
output_format :modified_environment,
|
97
|
-
proc { |n, v| format(
|
99
|
+
proc { |n, v| format('$ export %s=%s', n, Shellwords.escape(v)) }
|
98
100
|
output_format :stderr, "<<-STDERR\n%s\nSTDERR"
|
99
101
|
output_format :stdout, "<<-STDOUT\n%s\nSTDOUT"
|
100
102
|
output_format :command_content, "<<-COMMAND\n%s\nCOMMAND"
|
101
103
|
output_format :stop_signal,
|
102
104
|
proc { |p, s|
|
103
|
-
format(
|
105
|
+
format('Command will be stopped with `kill -%s %s`', s, p)
|
104
106
|
}
|
105
|
-
output_format :timeout,
|
106
|
-
output_format :wait_time,
|
107
|
+
output_format :timeout, '# %s-timeout: %s seconds'
|
108
|
+
output_format :wait_time, '# %s: %s seconds'
|
107
109
|
output_format :command_filesystem_status,
|
108
110
|
proc { |status|
|
109
111
|
format("<<-COMMAND FILESYSTEM STATUS\n%s\nCOMMAND FILESYSTEM STATUS",
|
@@ -111,7 +113,7 @@ module Aruba
|
|
111
113
|
}
|
112
114
|
end
|
113
115
|
|
114
|
-
def output_format(channel, string =
|
116
|
+
def output_format(channel, string = '%s', &block)
|
115
117
|
output_formats[channel.to_sym] = if block
|
116
118
|
block
|
117
119
|
elsif string.is_a?(Proc)
|
@@ -178,7 +180,7 @@ module Aruba
|
|
178
180
|
the_output_format = if output_formats.key? channel
|
179
181
|
output_formats[channel]
|
180
182
|
else
|
181
|
-
proc { |v| format(
|
183
|
+
proc { |v| format('%s', v) }
|
182
184
|
end
|
183
185
|
|
184
186
|
return unless activated?(channel)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Aruba
|
2
4
|
module Aruba
|
3
5
|
# Platforms
|
@@ -28,7 +30,7 @@ module Aruba
|
|
28
30
|
|
29
31
|
Aruba.platform.mkdir(File.dirname(path))
|
30
32
|
|
31
|
-
File.open(path,
|
33
|
+
File.open(path, 'wb') do |f|
|
32
34
|
f.seek(size - 1)
|
33
35
|
f.write("\0")
|
34
36
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Aruba
|
2
4
|
module Platforms
|
3
5
|
# File System Status object
|
@@ -36,7 +38,7 @@ module Aruba
|
|
36
38
|
|
37
39
|
# Return permissions
|
38
40
|
def mode
|
39
|
-
format(
|
41
|
+
format('%o', status.mode)[-4, 4].gsub(/^0*/, '')
|
40
42
|
end
|
41
43
|
|
42
44
|
# Return owner
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Aruba
|
2
4
|
module Aruba
|
3
5
|
# Platforms
|
@@ -6,6 +8,12 @@ module Aruba
|
|
6
8
|
#
|
7
9
|
# Wraps logic to make enviroment local and restorable
|
8
10
|
class LocalEnvironment
|
11
|
+
def initialize(platform)
|
12
|
+
@platform = platform
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader :platform
|
16
|
+
|
9
17
|
# Run in environment
|
10
18
|
#
|
11
19
|
# @param [Hash] env
|
@@ -14,7 +22,7 @@ module Aruba
|
|
14
22
|
# @yield
|
15
23
|
# The block of code which should with local ENV
|
16
24
|
def call(env)
|
17
|
-
old_env =
|
25
|
+
old_env = platform.environment_variables.hash_from_env
|
18
26
|
|
19
27
|
ENV.clear
|
20
28
|
ENV.update env
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Aruba
|
2
4
|
module Aruba
|
3
5
|
# Platforms
|
@@ -27,12 +29,12 @@ module Aruba
|
|
27
29
|
# The table
|
28
30
|
def to_s
|
29
31
|
longest_key = hash.keys.map(&:to_s).max_by(&:length)
|
30
|
-
return
|
32
|
+
return '' if longest_key.nil?
|
31
33
|
|
32
34
|
name_size = longest_key.length
|
33
35
|
|
34
36
|
rows = hash.map do |k, v|
|
35
|
-
format(
|
37
|
+
format('# %-*s => %s', name_size, k, v)
|
36
38
|
end
|
37
39
|
|
38
40
|
if opts[:sort] == true
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Aruba
|
2
4
|
module Aruba
|
3
5
|
# Platforms
|
@@ -156,10 +158,10 @@ module Aruba
|
|
156
158
|
end
|
157
159
|
|
158
160
|
# Pass on checks
|
159
|
-
def method_missing(name,
|
161
|
+
def method_missing(name, ...)
|
160
162
|
super unless to_h.respond_to? name
|
161
163
|
|
162
|
-
to_h.send
|
164
|
+
to_h.send(name, ...)
|
163
165
|
end
|
164
166
|
|
165
167
|
# Check for respond_to
|