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,21 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
|
5
|
-
require
|
6
|
-
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rbconfig'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'pathname'
|
6
|
+
|
7
|
+
require 'aruba/aruba_logger'
|
8
|
+
require 'aruba/aruba_path'
|
9
|
+
require 'aruba/command_monitor'
|
10
|
+
|
11
|
+
require 'aruba/platforms/simple_table'
|
12
|
+
require 'aruba/platforms/unix_command_string'
|
13
|
+
require 'aruba/platforms/unix_which'
|
14
|
+
require 'aruba/platforms/determine_file_size'
|
15
|
+
require 'aruba/platforms/determine_disk_usage'
|
16
|
+
require 'aruba/platforms/aruba_file_creator'
|
17
|
+
require 'aruba/platforms/aruba_fixed_size_file_creator'
|
18
|
+
require 'aruba/platforms/local_environment'
|
19
|
+
require 'aruba/platforms/announcer'
|
20
|
+
require 'aruba/platforms/filesystem_status'
|
19
21
|
|
20
22
|
# Aruba
|
21
23
|
module Aruba
|
@@ -75,12 +77,12 @@ module Aruba
|
|
75
77
|
ArubaFixedSizeFileCreator.new.call(*args)
|
76
78
|
end
|
77
79
|
|
78
|
-
def
|
79
|
-
LocalEnvironment.new.call(env, &block)
|
80
|
+
def with_replaced_environment(env = {}, &block)
|
81
|
+
LocalEnvironment.new(self).call(env, &block)
|
80
82
|
end
|
81
83
|
|
82
84
|
def default_shell
|
83
|
-
|
85
|
+
'bash'
|
84
86
|
end
|
85
87
|
|
86
88
|
def detect_ruby(cmd)
|
@@ -92,15 +94,15 @@ module Aruba
|
|
92
94
|
end
|
93
95
|
|
94
96
|
def deprecated(msg)
|
95
|
-
warn(format(
|
97
|
+
warn(format('%s. Called by %s', msg, caller[1]))
|
96
98
|
end
|
97
99
|
|
98
100
|
def current_ruby
|
99
|
-
::File.join(RbConfig::CONFIG[
|
101
|
+
::File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
|
100
102
|
end
|
101
103
|
|
102
104
|
def require_matching_files(pattern, base)
|
103
|
-
::Dir.glob(::File.expand_path(pattern, base)).
|
105
|
+
::Dir.glob(::File.expand_path(pattern, base)).each { |f| require_relative f }
|
104
106
|
end
|
105
107
|
|
106
108
|
# Create directory and subdirectories
|
@@ -126,7 +128,7 @@ module Aruba
|
|
126
128
|
def chdir(dir_name, &block)
|
127
129
|
dir_name = ::File.expand_path(dir_name.to_s)
|
128
130
|
|
129
|
-
|
131
|
+
with_replaced_environment 'OLDPWD' => getwd, 'PWD' => dir_name do
|
130
132
|
::Dir.chdir(dir_name, &block)
|
131
133
|
end
|
132
134
|
end
|
@@ -234,13 +236,17 @@ module Aruba
|
|
234
236
|
# @param [String] path
|
235
237
|
# The PATH, a string concatenated with ":", e.g. /usr/bin/:/bin on a
|
236
238
|
# UNIX-system
|
237
|
-
def which(program, path = ENV[
|
239
|
+
def which(program, path = ENV['PATH'])
|
238
240
|
UnixWhich.new.call(program, path)
|
239
241
|
end
|
240
242
|
|
241
243
|
def builtin_shell_commands
|
242
244
|
[]
|
243
245
|
end
|
246
|
+
|
247
|
+
def term_signal_supported?
|
248
|
+
true
|
249
|
+
end
|
244
250
|
end
|
245
251
|
end
|
246
252
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Aruba
|
2
4
|
module Aruba
|
3
5
|
# Platforms
|
@@ -70,7 +72,7 @@ module Aruba
|
|
70
72
|
#
|
71
73
|
# @param [String] path
|
72
74
|
# ENV['PATH']
|
73
|
-
def call(program, path = ENV[
|
75
|
+
def call(program, path = ENV['PATH'])
|
74
76
|
raise ArgumentError, "ENV['PATH'] cannot be empty" if path.nil? || path.empty?
|
75
77
|
|
76
78
|
program = program.to_s
|
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Aruba
|
2
4
|
module Aruba
|
3
5
|
# Platforms
|
4
6
|
module Platforms
|
5
7
|
# This is a command which should be run
|
6
8
|
#
|
7
|
-
# This adds `cmd.exec` in front of commmand
|
8
|
-
#
|
9
9
|
# @private
|
10
10
|
class WindowsCommandString
|
11
11
|
def initialize(command, *arguments)
|
@@ -15,22 +15,7 @@ module Aruba
|
|
15
15
|
|
16
16
|
# Convert to array
|
17
17
|
def to_a
|
18
|
-
[
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def escaped_arguments
|
24
|
-
@arguments.map { |arg| arg.gsub(/"/, '"""') }
|
25
|
-
.map { |arg| / /.match?(arg) ? "\"#{arg}\"" : arg }
|
26
|
-
end
|
27
|
-
|
28
|
-
def escaped_command
|
29
|
-
@command.gsub(/ /, '""" """')
|
30
|
-
end
|
31
|
-
|
32
|
-
def cmd_path
|
33
|
-
Aruba.platform.which("cmd.exe")
|
18
|
+
[@command, *@arguments]
|
34
19
|
end
|
35
20
|
end
|
36
21
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aruba/platforms/unix_platform'
|
4
|
+
require 'aruba/platforms/windows_command_string'
|
5
|
+
require 'aruba/platforms/windows_environment_variables'
|
6
|
+
require 'aruba/platforms/windows_which'
|
5
7
|
|
6
8
|
# Aruba
|
7
9
|
module Aruba
|
@@ -32,12 +34,16 @@ module Aruba
|
|
32
34
|
end
|
33
35
|
|
34
36
|
# @see UnixPlatform#which
|
35
|
-
def which(program, path = ENV[
|
37
|
+
def which(program, path = ENV['PATH'])
|
36
38
|
WindowsWhich.new.call(program, path)
|
37
39
|
end
|
38
40
|
|
39
41
|
def builtin_shell_commands
|
40
|
-
%w
|
42
|
+
%w[cd dir echo exit set type]
|
43
|
+
end
|
44
|
+
|
45
|
+
def term_signal_supported?
|
46
|
+
false
|
41
47
|
end
|
42
48
|
end
|
43
49
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Aruba
|
2
4
|
module Aruba
|
3
5
|
# Platforms
|
@@ -49,7 +51,7 @@ module Aruba
|
|
49
51
|
file = File.join(dir, program)
|
50
52
|
# Dir[] doesn't handle backslashes properly, so convert them. Also, if
|
51
53
|
# the program name doesn't have an extension, try them all.
|
52
|
-
file = file.tr(
|
54
|
+
file = file.tr('\\', '/')
|
53
55
|
|
54
56
|
found = Dir[file].first
|
55
57
|
|
@@ -84,7 +86,7 @@ module Aruba
|
|
84
86
|
#
|
85
87
|
# @param [String] path
|
86
88
|
# ENV['PATH']
|
87
|
-
def call(program, path = ENV[
|
89
|
+
def call(program, path = ENV['PATH'])
|
88
90
|
raise ArgumentError, "ENV['PATH'] cannot be empty" if path.nil? || path.empty?
|
89
91
|
|
90
92
|
program = program.to_s
|
@@ -96,10 +98,10 @@ module Aruba
|
|
96
98
|
private
|
97
99
|
|
98
100
|
def windows_executable_extentions
|
99
|
-
if ENV[
|
100
|
-
format(
|
101
|
+
if ENV['PATHEXT']
|
102
|
+
format('.{%s}', ENV['PATHEXT'].tr(';', ',').tr('.', '')).downcase
|
101
103
|
else
|
102
|
-
|
104
|
+
'.{exe,com,bat}'
|
103
105
|
end
|
104
106
|
end
|
105
107
|
end
|
@@ -1,5 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aruba/platform'
|
4
|
+
require 'shellwords'
|
3
5
|
|
4
6
|
# Aruba
|
5
7
|
module Aruba
|
@@ -125,7 +127,7 @@ module Aruba
|
|
125
127
|
end
|
126
128
|
|
127
129
|
def arguments
|
128
|
-
return Shellwords.split(commandline)[1
|
130
|
+
return Shellwords.split(commandline)[1..] if Shellwords.split(commandline).size > 1
|
129
131
|
|
130
132
|
[]
|
131
133
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aruba/processes/spawn_process'
|
2
4
|
|
3
5
|
# Aruba
|
4
6
|
module Aruba
|
@@ -24,7 +26,7 @@ module Aruba
|
|
24
26
|
def start
|
25
27
|
@started = true
|
26
28
|
Dir.chdir @working_directory do
|
27
|
-
Aruba.platform.
|
29
|
+
Aruba.platform.with_replaced_environment(environment) do
|
28
30
|
@exit_status = system(command, *arguments) ? 0 : 1
|
29
31
|
end
|
30
32
|
end
|
@@ -41,8 +43,8 @@ module Aruba
|
|
41
43
|
# @return [String]
|
42
44
|
# A predefined string to make users aware they are using the DebugProcess
|
43
45
|
def stdout(*)
|
44
|
-
|
45
|
-
|
46
|
+
'This is the debug launcher on STDOUT. ' \
|
47
|
+
'If this output is unexpected, please check your setup.'
|
46
48
|
end
|
47
49
|
|
48
50
|
# Return stderr
|
@@ -50,8 +52,8 @@ module Aruba
|
|
50
52
|
# @return [String]
|
51
53
|
# A predefined string to make users aware they are using the DebugProcess
|
52
54
|
def stderr(*)
|
53
|
-
|
54
|
-
|
55
|
+
'This is the debug launcher on STDERR. ' \
|
56
|
+
'If this output is unexpected, please check your setup.'
|
55
57
|
end
|
56
58
|
|
57
59
|
# Write to nothing
|
@@ -1,7 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'shellwords'
|
4
|
+
require 'stringio'
|
5
|
+
require 'aruba/processes/basic_process'
|
6
|
+
require 'aruba/platform'
|
5
7
|
|
6
8
|
# Aruba
|
7
9
|
module Aruba
|
@@ -61,14 +63,15 @@ module Aruba
|
|
61
63
|
|
62
64
|
# Start command
|
63
65
|
def start
|
64
|
-
raise
|
66
|
+
raise 'You need to call aruba.config.main_class = YourMainClass' unless main_class
|
65
67
|
|
66
68
|
@started = true
|
67
69
|
|
68
70
|
Dir.chdir @working_directory do
|
69
71
|
before_run
|
70
72
|
|
71
|
-
|
73
|
+
new_env = environment.merge('PWD' => @working_directory)
|
74
|
+
Aruba.platform.with_replaced_environment new_env do
|
72
75
|
main_class.new(@argv, @stdin, @stdout, @stderr, @kernel).execute!
|
73
76
|
end
|
74
77
|
|
@@ -109,8 +112,8 @@ module Aruba
|
|
109
112
|
|
110
113
|
# Close io
|
111
114
|
def close_io(name)
|
112
|
-
unless [
|
113
|
-
raise ArgumentError,
|
115
|
+
unless %i[stdin stdout stderr].include? name
|
116
|
+
raise ArgumentError, 'Only stdin stdout and stderr are allowed to close'
|
114
117
|
end
|
115
118
|
|
116
119
|
get_instance_variable(name.to_sym).close
|
@@ -1,15 +1,95 @@
|
|
1
|
-
|
2
|
-
require "tempfile"
|
3
|
-
require "shellwords"
|
1
|
+
# frozen_string_literal: true
|
4
2
|
|
5
|
-
require
|
6
|
-
require
|
7
|
-
|
3
|
+
require 'tempfile'
|
4
|
+
require 'shellwords'
|
5
|
+
|
6
|
+
require 'aruba/errors'
|
7
|
+
require 'aruba/processes/basic_process'
|
8
|
+
require 'aruba/platform'
|
8
9
|
|
9
10
|
# Aruba
|
10
11
|
module Aruba
|
11
12
|
# Platforms
|
12
13
|
module Processes
|
14
|
+
# Wrapper around Process.spawn that broadly follows the ChildProcess interface
|
15
|
+
# @private
|
16
|
+
class ProcessRunner
|
17
|
+
def initialize(command_array)
|
18
|
+
@command_array = command_array
|
19
|
+
@exit_status = nil
|
20
|
+
end
|
21
|
+
|
22
|
+
attr_accessor :stdout, :stderr, :cwd, :environment
|
23
|
+
attr_reader :command_array, :pid
|
24
|
+
|
25
|
+
def start
|
26
|
+
@stdin_r, @stdin_w = IO.pipe
|
27
|
+
@pid = Process.spawn(environment, *command_array,
|
28
|
+
unsetenv_others: true,
|
29
|
+
in: @stdin_r,
|
30
|
+
out: stdout.fileno,
|
31
|
+
err: stderr.fileno,
|
32
|
+
close_others: true,
|
33
|
+
chdir: cwd)
|
34
|
+
end
|
35
|
+
|
36
|
+
def stdin
|
37
|
+
@stdin_w
|
38
|
+
end
|
39
|
+
|
40
|
+
def stop
|
41
|
+
return if @exit_status
|
42
|
+
|
43
|
+
if Aruba.platform.term_signal_supported?
|
44
|
+
send_signal 'TERM'
|
45
|
+
return if poll_for_exit(3)
|
46
|
+
end
|
47
|
+
|
48
|
+
send_signal 'KILL'
|
49
|
+
wait
|
50
|
+
end
|
51
|
+
|
52
|
+
def wait
|
53
|
+
_, status = Process.waitpid2 @pid
|
54
|
+
@exit_status = status
|
55
|
+
end
|
56
|
+
|
57
|
+
def exited?
|
58
|
+
return true if @exit_status
|
59
|
+
|
60
|
+
pid, status = Process.waitpid2 @pid, Process::WNOHANG | Process::WUNTRACED
|
61
|
+
|
62
|
+
if pid
|
63
|
+
@exit_status = status
|
64
|
+
return true
|
65
|
+
end
|
66
|
+
|
67
|
+
false
|
68
|
+
end
|
69
|
+
|
70
|
+
def poll_for_exit(exit_timeout)
|
71
|
+
start = Time.now
|
72
|
+
wait_until = start + exit_timeout
|
73
|
+
loop do
|
74
|
+
return true if exited?
|
75
|
+
break if Time.now >= wait_until
|
76
|
+
|
77
|
+
sleep 0.1
|
78
|
+
end
|
79
|
+
false
|
80
|
+
end
|
81
|
+
|
82
|
+
def exit_code
|
83
|
+
@exit_status&.exitstatus
|
84
|
+
end
|
85
|
+
|
86
|
+
private
|
87
|
+
|
88
|
+
def send_signal(signal)
|
89
|
+
Process.kill signal, @pid
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
13
93
|
# Spawn a process for command
|
14
94
|
#
|
15
95
|
# `SpawnProcess` is not meant for direct use - `SpawnProcess.new` - by
|
@@ -66,42 +146,39 @@ module Aruba
|
|
66
146
|
def start
|
67
147
|
if started?
|
68
148
|
error_message =
|
69
|
-
"Command \"#{commandline}\" has already been started." \
|
70
|
-
|
71
|
-
|
149
|
+
"Command \"#{commandline}\" has already been started. " \
|
150
|
+
'Please `#stop` the command first and `#start` it again. ' \
|
151
|
+
'Alternatively use `#restart`.'
|
72
152
|
raise CommandAlreadyStartedError, error_message
|
73
153
|
end
|
74
154
|
|
75
155
|
@started = true
|
76
156
|
|
77
|
-
@process =
|
78
|
-
|
79
|
-
@
|
157
|
+
@process = ProcessRunner.new(command_string.to_a)
|
158
|
+
|
159
|
+
@stdout_file = Tempfile.new('aruba-stdout-')
|
160
|
+
@stderr_file = Tempfile.new('aruba-stderr-')
|
80
161
|
|
81
162
|
@stdout_file.sync = true
|
82
163
|
@stderr_file.sync = true
|
83
164
|
|
84
|
-
@stdout_file.set_encoding(
|
85
|
-
@stderr_file.set_encoding(
|
165
|
+
@stdout_file.set_encoding('ASCII-8BIT')
|
166
|
+
@stderr_file.set_encoding('ASCII-8BIT')
|
86
167
|
|
87
168
|
@exit_status = nil
|
88
|
-
@duplex = true
|
89
169
|
|
90
170
|
before_run
|
91
171
|
|
92
|
-
@process.
|
93
|
-
@process.
|
94
|
-
@process.
|
95
|
-
@process.cwd = @working_directory
|
172
|
+
@process.stdout = @stdout_file
|
173
|
+
@process.stderr = @stderr_file
|
174
|
+
@process.cwd = @working_directory
|
96
175
|
|
97
|
-
@process.environment
|
176
|
+
@process.environment = environment
|
98
177
|
|
99
178
|
begin
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
end
|
104
|
-
rescue ChildProcess::LaunchError => e
|
179
|
+
@process.start
|
180
|
+
sleep startup_wait_time
|
181
|
+
rescue SystemCallError => e
|
105
182
|
raise LaunchError, "It tried to start #{commandline}. " + e.message
|
106
183
|
end
|
107
184
|
|
@@ -131,7 +208,7 @@ module Aruba
|
|
131
208
|
return @stdout_cache if stopped?
|
132
209
|
|
133
210
|
wait_for_io opts.fetch(:wait_for_io, io_wait_timeout) do
|
134
|
-
@process.
|
211
|
+
@process.stdout.flush
|
135
212
|
open(@stdout_file.path).read
|
136
213
|
end
|
137
214
|
end
|
@@ -150,7 +227,7 @@ module Aruba
|
|
150
227
|
return @stderr_cache if stopped?
|
151
228
|
|
152
229
|
wait_for_io opts.fetch(:wait_for_io, io_wait_timeout) do
|
153
|
-
@process.
|
230
|
+
@process.stderr.flush
|
154
231
|
open(@stderr_file.path).read
|
155
232
|
end
|
156
233
|
end
|
@@ -158,8 +235,8 @@ module Aruba
|
|
158
235
|
def write(input)
|
159
236
|
return if stopped?
|
160
237
|
|
161
|
-
@process.
|
162
|
-
@process.
|
238
|
+
@process.stdin.write(input)
|
239
|
+
@process.stdin.flush
|
163
240
|
|
164
241
|
self
|
165
242
|
end
|
@@ -168,18 +245,14 @@ module Aruba
|
|
168
245
|
def close_io(name)
|
169
246
|
return if stopped?
|
170
247
|
|
171
|
-
@process.
|
248
|
+
@process.public_send(name.to_sym).close
|
172
249
|
end
|
173
250
|
|
174
251
|
# Stop command
|
175
252
|
def stop(*)
|
176
253
|
return @exit_status if stopped?
|
177
254
|
|
178
|
-
|
179
|
-
@process.poll_for_exit(@exit_timeout)
|
180
|
-
rescue ChildProcess::TimeoutError
|
181
|
-
@timed_out = true
|
182
|
-
end
|
255
|
+
@process.poll_for_exit(@exit_timeout) or @timed_out = true
|
183
256
|
|
184
257
|
terminate
|
185
258
|
end
|
@@ -275,7 +348,7 @@ module Aruba
|
|
275
348
|
if Aruba.platform.builtin_shell_commands.include?(command)
|
276
349
|
command
|
277
350
|
else
|
278
|
-
Aruba.platform.which(command, environment[
|
351
|
+
Aruba.platform.which(command, environment['PATH'])
|
279
352
|
end
|
280
353
|
end
|
281
354
|
|
@@ -290,7 +363,7 @@ module Aruba
|
|
290
363
|
data = file.read
|
291
364
|
file.close
|
292
365
|
|
293
|
-
data.force_encoding(
|
366
|
+
data.force_encoding('UTF-8')
|
294
367
|
end
|
295
368
|
end
|
296
369
|
end
|
data/lib/aruba/rspec.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
|
5
|
-
require
|
3
|
+
require 'rspec/core'
|
4
|
+
|
5
|
+
require 'aruba'
|
6
|
+
require 'aruba/api'
|
7
|
+
require 'aruba/version'
|
6
8
|
|
7
9
|
RSpec.configure do |config|
|
8
10
|
config.include Aruba::Api, type: :aruba
|
@@ -14,12 +16,12 @@ RSpec.configure do |config|
|
|
14
16
|
|
15
17
|
# Modify PATH to include project/bin
|
16
18
|
prepend_environment_variable(
|
17
|
-
|
19
|
+
'PATH',
|
18
20
|
aruba.config.command_search_paths.join(File::PATH_SEPARATOR) + File::PATH_SEPARATOR
|
19
21
|
)
|
20
22
|
|
21
23
|
# Use configured home directory as HOME
|
22
|
-
set_environment_variable
|
24
|
+
set_environment_variable 'HOME', aruba.config.home_directory
|
23
25
|
end
|
24
26
|
|
25
27
|
example.run
|
data/lib/aruba/runtime.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aruba/configuration'
|
4
|
+
require 'aruba/aruba_path'
|
5
|
+
require 'aruba/config_wrapper'
|
6
|
+
require 'aruba/events'
|
7
|
+
require 'aruba/event_bus'
|
6
8
|
|
7
9
|
module Aruba
|
8
10
|
# Runtime of aruba
|
@@ -40,7 +42,7 @@ module Aruba
|
|
40
42
|
attr_accessor :config, :environment, :logger, :command_monitor, :announcer, :event_bus
|
41
43
|
|
42
44
|
def initialize(opts = {})
|
43
|
-
@event_bus = EventBus.new(
|
45
|
+
@event_bus = EventBus.new(Aruba::Events.registry)
|
44
46
|
@announcer = opts.fetch(:announcer, Aruba.platform.announcer.new)
|
45
47
|
@config = opts.fetch(:config,
|
46
48
|
ConfigWrapper.new(Aruba.config.make_copy, @event_bus))
|
@@ -84,7 +86,7 @@ module Aruba
|
|
84
86
|
directory = candidates.find { |d| Aruba.platform.directory? d }
|
85
87
|
|
86
88
|
unless directory
|
87
|
-
canditates_display = candidates.map { |d| format('"%s"', d) }.join(
|
89
|
+
canditates_display = candidates.map { |d| format('"%s"', d) }.join(', ')
|
88
90
|
raise "No existing fixtures directory found in #{canditates_display}."
|
89
91
|
end
|
90
92
|
|
data/lib/aruba/setup.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Aruba
|
2
4
|
class Setup
|
3
5
|
private
|
@@ -39,10 +41,10 @@ module Aruba
|
|
39
41
|
:command_started,
|
40
42
|
proc do |event|
|
41
43
|
runtime.announcer.announce(:command) { event.entity.commandline }
|
42
|
-
runtime.announcer.announce(:timeout,
|
43
|
-
runtime.announcer.announce(:timeout,
|
44
|
+
runtime.announcer.announce(:timeout, 'exit') { event.entity.exit_timeout }
|
45
|
+
runtime.announcer.announce(:timeout, 'io wait') { event.entity.io_wait_timeout }
|
44
46
|
runtime.announcer
|
45
|
-
.announce(:wait_time,
|
47
|
+
.announce(:wait_time, 'startup wait time') { event.entity.startup_wait_time }
|
46
48
|
runtime.announcer.announce(:full_environment) { event.entity.environment }
|
47
49
|
end
|
48
50
|
)
|
@@ -74,9 +76,9 @@ module Aruba
|
|
74
76
|
)
|
75
77
|
|
76
78
|
runtime.event_bus.register(
|
77
|
-
[
|
78
|
-
|
79
|
-
|
79
|
+
%i[changed_environment_variable
|
80
|
+
added_environment_variable
|
81
|
+
deleted_environment_variable],
|
80
82
|
proc do |event|
|
81
83
|
runtime.announcer.announce :changed_environment,
|
82
84
|
event.entity[:changed][:name],
|
data/lib/aruba/version.rb
CHANGED
data/lib/aruba.rb
CHANGED