aruba 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +72 -1
- data/CONTRIBUTING.md +11 -31
- data/README.md +1 -2
- data/exe/aruba +2 -2
- data/lib/aruba.rb +1 -1
- data/lib/aruba/api.rb +11 -12
- data/lib/aruba/api/bundler.rb +18 -3
- data/lib/aruba/api/commands.rb +19 -22
- data/lib/aruba/api/core.rb +65 -48
- data/lib/aruba/api/environment.rb +13 -5
- data/lib/aruba/api/filesystem.rb +69 -39
- data/lib/aruba/api/text.rb +15 -3
- data/lib/aruba/aruba_path.rb +3 -4
- data/lib/aruba/basic_configuration.rb +52 -71
- data/lib/aruba/basic_configuration/option.rb +2 -2
- data/lib/aruba/cli.rb +9 -6
- data/lib/aruba/command.rb +4 -4
- data/lib/aruba/config/jruby.rb +9 -9
- data/lib/aruba/config_wrapper.rb +17 -2
- data/lib/aruba/configuration.rb +37 -32
- data/lib/aruba/console.rb +11 -13
- data/lib/aruba/console/help.rb +9 -6
- data/lib/aruba/contracts/absolute_path.rb +2 -2
- data/lib/aruba/contracts/enum.rb +1 -1
- data/lib/aruba/contracts/is_power_of_two.rb +3 -3
- data/lib/aruba/contracts/relative_path.rb +2 -2
- data/lib/aruba/cucumber.rb +7 -7
- data/lib/aruba/cucumber/command.rb +106 -95
- data/lib/aruba/cucumber/environment.rb +7 -7
- data/lib/aruba/cucumber/file.rb +50 -26
- data/lib/aruba/cucumber/hooks.rb +32 -29
- data/lib/aruba/cucumber/testing_frameworks.rb +32 -30
- data/lib/aruba/event_bus.rb +6 -4
- data/lib/aruba/event_bus/name_resolver.rb +12 -11
- data/lib/aruba/events.rb +2 -1
- data/lib/aruba/file_size.rb +1 -1
- data/lib/aruba/generators/script_file.rb +2 -2
- data/lib/aruba/hooks.rb +2 -4
- data/lib/aruba/in_config_wrapper.rb +8 -5
- data/lib/aruba/initializer.rb +14 -12
- data/lib/aruba/matchers/base/base_matcher.rb +3 -12
- data/lib/aruba/matchers/base/message_indenter.rb +2 -2
- data/lib/aruba/matchers/base/object_formatter.rb +2 -5
- data/lib/aruba/matchers/collection.rb +1 -1
- data/lib/aruba/matchers/collection/all.rb +1 -1
- data/lib/aruba/matchers/collection/include_an_object.rb +6 -6
- data/lib/aruba/matchers/command.rb +1 -1
- data/lib/aruba/matchers/command/be_successfully_executed.rb +6 -4
- data/lib/aruba/matchers/command/have_exit_status.rb +3 -1
- data/lib/aruba/matchers/command/have_finished_in_time.rb +4 -2
- data/lib/aruba/matchers/command/have_output.rb +4 -2
- data/lib/aruba/matchers/command/have_output_on_stderr.rb +3 -1
- data/lib/aruba/matchers/command/have_output_on_stdout.rb +3 -1
- data/lib/aruba/matchers/directory.rb +1 -1
- data/lib/aruba/matchers/directory/be_an_existing_directory.rb +2 -2
- data/lib/aruba/matchers/directory/have_sub_directory.rb +9 -4
- data/lib/aruba/matchers/environment.rb +1 -1
- data/lib/aruba/matchers/file.rb +1 -1
- data/lib/aruba/matchers/file/be_a_command_found_in_path.rb +1 -1
- data/lib/aruba/matchers/file/be_an_existing_executable.rb +2 -2
- data/lib/aruba/matchers/file/be_an_existing_file.rb +2 -2
- data/lib/aruba/matchers/file/have_file_content.rb +1 -1
- data/lib/aruba/matchers/file/have_file_size.rb +5 -3
- data/lib/aruba/matchers/file/have_same_file_content.rb +2 -2
- data/lib/aruba/matchers/path.rb +1 -1
- data/lib/aruba/matchers/path/a_path_matching_pattern.rb +1 -1
- data/lib/aruba/matchers/path/be_an_absolute_path.rb +1 -1
- data/lib/aruba/matchers/path/be_an_existing_path.rb +1 -1
- data/lib/aruba/matchers/path/have_permissions.rb +9 -6
- data/lib/aruba/matchers/string.rb +1 -1
- data/lib/aruba/matchers/string/include_output_string.rb +1 -1
- data/lib/aruba/matchers/string/match_output_string.rb +1 -1
- data/lib/aruba/matchers/string/output_string_eq.rb +1 -1
- data/lib/aruba/platform.rb +2 -2
- data/lib/aruba/platforms/announcer.rb +29 -17
- data/lib/aruba/platforms/aruba_file_creator.rb +3 -1
- data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +7 -2
- data/lib/aruba/platforms/aruba_logger.rb +11 -10
- data/lib/aruba/platforms/command_monitor.rb +7 -9
- data/lib/aruba/platforms/determine_disk_usage.rb +2 -4
- data/lib/aruba/platforms/filesystem_status.rb +20 -14
- data/lib/aruba/platforms/simple_table.rb +3 -3
- data/lib/aruba/platforms/unix_command_string.rb +2 -2
- data/lib/aruba/platforms/unix_environment_variables.rb +2 -4
- data/lib/aruba/platforms/unix_platform.rb +23 -23
- data/lib/aruba/platforms/unix_which.rb +2 -2
- data/lib/aruba/platforms/windows_command_string.rb +2 -2
- data/lib/aruba/platforms/windows_environment_variables.rb +3 -2
- data/lib/aruba/platforms/windows_platform.rb +7 -7
- data/lib/aruba/platforms/windows_which.rb +8 -4
- data/lib/aruba/processes/basic_process.rb +4 -4
- data/lib/aruba/processes/debug_process.rb +5 -3
- data/lib/aruba/processes/in_process.rb +10 -8
- data/lib/aruba/processes/spawn_process.rb +28 -25
- data/lib/aruba/rspec.rb +30 -20
- data/lib/aruba/runtime.rb +16 -9
- data/lib/aruba/setup.rb +25 -12
- data/lib/aruba/version.rb +1 -1
- metadata +77 -88
- data/.cucumberproignore +0 -3
- data/.document +0 -5
- data/.github/ISSUE_TEMPLATE.md +0 -48
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -41
- data/.gitignore +0 -38
- data/.rspec +0 -3
- data/.rubocop.yml +0 -31
- data/.rubocop_todo.yml +0 -262
- data/.simplecov +0 -36
- data/.travis.yml +0 -62
- data/.yardopts +0 -11
- data/Dockerfile +0 -67
- data/Gemfile +0 -12
- data/Rakefile +0 -80
- data/TODO.md +0 -13
- data/appveyor.yml +0 -29
- data/aruba.gemspec +0 -54
- data/bin/console +0 -7
- data/bin/test +0 -9
- data/config/.gitignore +0 -1
- data/cucumber.yml +0 -6
- data/docker-compose.yml +0 -26
- data/fixtures/cli-app/.gitignore +0 -9
- data/fixtures/cli-app/.rspec +0 -2
- data/fixtures/cli-app/README.md +0 -39
- data/fixtures/cli-app/Rakefile +0 -1
- data/fixtures/cli-app/bin/aruba-test-cli +0 -6
- data/fixtures/cli-app/cli-app.gemspec +0 -25
- data/fixtures/cli-app/features/support/aruba.rb +0 -1
- data/fixtures/cli-app/features/support/env.rb +0 -1
- data/fixtures/cli-app/lib/cli/app.rb +0 -9
- data/fixtures/cli-app/lib/cli/app/suppress_simple_cov_output.rb +0 -15
- data/fixtures/cli-app/lib/cli/app/version.rb +0 -5
- data/fixtures/cli-app/script/console +0 -14
- data/fixtures/cli-app/spec/spec_helper.rb +0 -7
- data/fixtures/cli-app/spec/support/aruba.rb +0 -1
- data/fixtures/copy/file.txt +0 -1
- data/fixtures/empty-app/.gitignore +0 -9
- data/fixtures/empty-app/.rspec +0 -2
- data/fixtures/empty-app/README.md +0 -24
- data/fixtures/empty-app/Rakefile +0 -1
- data/fixtures/empty-app/cli-app.gemspec +0 -25
- data/fixtures/empty-app/lib/cli/app.rb +0 -7
- data/fixtures/empty-app/lib/cli/app/version.rb +0 -5
- data/fixtures/getting-started-app/.gitignore +0 -4
- data/fixtures/getting-started-app/Gemfile +0 -4
- data/fixtures/getting-started-app/README.md +0 -3
- data/fixtures/getting-started-app/features/support/env.rb +0 -1
- data/lib/aruba/extensions/string/strip.rb +0 -25
- data/lib/aruba/tasks/docker_helpers.rb +0 -154
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "aruba/file_size"
|
2
2
|
|
3
3
|
module Aruba
|
4
4
|
module Platforms
|
@@ -7,9 +7,7 @@ module Aruba
|
|
7
7
|
# @private
|
8
8
|
class DetermineDiskUsage
|
9
9
|
def call(paths)
|
10
|
-
size = paths.flatten.
|
11
|
-
minimum_disk_space_used path
|
12
|
-
end.inject(0, &:+)
|
10
|
+
size = paths.flatten.sum { |path| minimum_disk_space_used path }
|
13
11
|
|
14
12
|
FileSize.new(size)
|
15
13
|
end
|
@@ -1,28 +1,34 @@
|
|
1
|
-
require 'forwardable'
|
2
|
-
|
3
1
|
module Aruba
|
4
2
|
module Platforms
|
5
3
|
# File System Status object
|
6
4
|
#
|
7
5
|
# This is a wrapper for File::Stat returning only a subset of information.
|
8
6
|
class FilesystemStatus
|
9
|
-
METHODS = [
|
10
|
-
:executable?,
|
11
|
-
:ctime,
|
12
|
-
:atime,
|
13
|
-
:mtime,
|
14
|
-
:size
|
15
|
-
].freeze
|
16
|
-
|
17
|
-
extend Forwardable
|
18
|
-
|
19
7
|
private
|
20
8
|
|
21
9
|
attr_reader :status
|
22
10
|
|
23
11
|
public
|
24
12
|
|
25
|
-
|
13
|
+
def executable?
|
14
|
+
status.executable?
|
15
|
+
end
|
16
|
+
|
17
|
+
def ctime
|
18
|
+
status.ctime
|
19
|
+
end
|
20
|
+
|
21
|
+
def atime
|
22
|
+
status.atime
|
23
|
+
end
|
24
|
+
|
25
|
+
def mtime
|
26
|
+
status.mtime
|
27
|
+
end
|
28
|
+
|
29
|
+
def size
|
30
|
+
status.size
|
31
|
+
end
|
26
32
|
|
27
33
|
def initialize(path)
|
28
34
|
@status = File::Stat.new(path)
|
@@ -30,7 +36,7 @@ module Aruba
|
|
30
36
|
|
31
37
|
# Return permissions
|
32
38
|
def mode
|
33
|
-
format(
|
39
|
+
format("%o", status.mode)[-4, 4].gsub(/^0*/, "")
|
34
40
|
end
|
35
41
|
|
36
42
|
# Return owner
|
@@ -27,12 +27,12 @@ module Aruba
|
|
27
27
|
# The table
|
28
28
|
def to_s
|
29
29
|
longest_key = hash.keys.map(&:to_s).max_by(&:length)
|
30
|
-
return
|
30
|
+
return "" if longest_key.nil?
|
31
31
|
|
32
32
|
name_size = longest_key.length
|
33
33
|
|
34
|
-
rows = hash.
|
35
|
-
|
34
|
+
rows = hash.map do |k, v|
|
35
|
+
format("# %-#{name_size}s => %s", k, v)
|
36
36
|
end
|
37
37
|
|
38
38
|
if opts[:sort] == true
|
@@ -9,11 +9,9 @@ module Aruba
|
|
9
9
|
attr_reader :other_env, :block
|
10
10
|
|
11
11
|
def initialize(other_env, &block)
|
12
|
-
@other_env = other_env.to_h.
|
12
|
+
@other_env = other_env.to_h.transform_values(&:to_s)
|
13
13
|
|
14
|
-
@block =
|
15
|
-
block
|
16
|
-
end
|
14
|
+
@block = block
|
17
15
|
end
|
18
16
|
|
19
17
|
def call(env)
|
@@ -1,20 +1,20 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
|
4
|
-
require
|
5
|
-
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
1
|
+
require "rbconfig"
|
2
|
+
require "pathname"
|
3
|
+
|
4
|
+
require "aruba/aruba_path"
|
5
|
+
|
6
|
+
require "aruba/platforms/simple_table"
|
7
|
+
require "aruba/platforms/unix_command_string"
|
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"
|
14
|
+
require "aruba/platforms/aruba_logger"
|
15
|
+
require "aruba/platforms/announcer"
|
16
|
+
require "aruba/platforms/command_monitor"
|
17
|
+
require "aruba/platforms/filesystem_status"
|
18
18
|
|
19
19
|
# Aruba
|
20
20
|
module Aruba
|
@@ -31,7 +31,7 @@ module Aruba
|
|
31
31
|
# @private
|
32
32
|
class UnixPlatform
|
33
33
|
def self.match?
|
34
|
-
!
|
34
|
+
!Cucumber::WINDOWS
|
35
35
|
end
|
36
36
|
|
37
37
|
def environment_variables
|
@@ -79,7 +79,7 @@ module Aruba
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def default_shell
|
82
|
-
|
82
|
+
"bash"
|
83
83
|
end
|
84
84
|
|
85
85
|
def detect_ruby(cmd)
|
@@ -91,11 +91,11 @@ module Aruba
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def deprecated(msg)
|
94
|
-
warn(format(
|
94
|
+
warn(format("%s. Called by %s", msg, caller[1]))
|
95
95
|
end
|
96
96
|
|
97
97
|
def current_ruby
|
98
|
-
::File.join(RbConfig::CONFIG[
|
98
|
+
::File.join(RbConfig::CONFIG["bindir"], RbConfig::CONFIG["ruby_install_name"])
|
99
99
|
end
|
100
100
|
|
101
101
|
def require_matching_files(pattern, base)
|
@@ -125,7 +125,7 @@ module Aruba
|
|
125
125
|
def chdir(dir_name, &block)
|
126
126
|
dir_name = ::File.expand_path(dir_name.to_s)
|
127
127
|
|
128
|
-
with_environment
|
128
|
+
with_environment "OLDPWD" => getwd, "PWD" => dir_name do
|
129
129
|
::Dir.chdir(dir_name, &block)
|
130
130
|
end
|
131
131
|
end
|
@@ -233,7 +233,7 @@ module Aruba
|
|
233
233
|
# @param [String] path
|
234
234
|
# The PATH, a string concatenated with ":", e.g. /usr/bin/:/bin on a
|
235
235
|
# UNIX-system
|
236
|
-
def which(program, path = ENV[
|
236
|
+
def which(program, path = ENV["PATH"])
|
237
237
|
UnixWhich.new.call(program, path)
|
238
238
|
end
|
239
239
|
|
@@ -13,7 +13,7 @@ module Aruba
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def call(program, path)
|
16
|
-
|
16
|
+
raise %(Invalid input program "#{program}" and/or path "#{path}".)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -70,7 +70,7 @@ module Aruba
|
|
70
70
|
#
|
71
71
|
# @param [String] path
|
72
72
|
# ENV['PATH']
|
73
|
-
def call(program, path = ENV[
|
73
|
+
def call(program, path = ENV["PATH"])
|
74
74
|
raise ArgumentError, "ENV['PATH'] cannot be empty" if path.nil? || path.empty?
|
75
75
|
|
76
76
|
program = program.to_s
|
@@ -15,7 +15,7 @@ module Aruba
|
|
15
15
|
|
16
16
|
# Convert to array
|
17
17
|
def to_a
|
18
|
-
[cmd_path,
|
18
|
+
[cmd_path, "/c", [escaped_command, *escaped_arguments].join(" ")]
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
@@ -30,7 +30,7 @@ module Aruba
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def cmd_path
|
33
|
-
Aruba.platform.which(
|
33
|
+
Aruba.platform.which("cmd.exe")
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "aruba/platforms/unix_environment_variables"
|
2
2
|
|
3
3
|
# Aruba
|
4
4
|
module Aruba
|
@@ -16,7 +16,8 @@ module Aruba
|
|
16
16
|
# C:>set PATH
|
17
17
|
# C:>Path=.;.\bin;c:\rubys\ruby-2.1.6-p336\bin;
|
18
18
|
#
|
19
|
-
# @example If you access environment variables through ENV, you can access
|
19
|
+
# @example If you access environment variables through ENV, you can access
|
20
|
+
# values no matter the case of the key:
|
20
21
|
# ENV["Path"] # => ".;.\bin;c:\rubys\ruby-2.1.6-p336\bin;"
|
21
22
|
# ENV["PATH"] # => ".;.\bin;c:\rubys\ruby-2.1.6-p336\bin;"
|
22
23
|
#
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require
|
1
|
+
require "cucumber/platform"
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
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"
|
7
7
|
|
8
8
|
# Aruba
|
9
9
|
module Aruba
|
@@ -20,7 +20,7 @@ module Aruba
|
|
20
20
|
# @private
|
21
21
|
class WindowsPlatform < UnixPlatform
|
22
22
|
def self.match?
|
23
|
-
|
23
|
+
Cucumber::WINDOWS
|
24
24
|
end
|
25
25
|
|
26
26
|
# @see UnixPlatform#command_string
|
@@ -34,7 +34,7 @@ module Aruba
|
|
34
34
|
end
|
35
35
|
|
36
36
|
# @see UnixPlatform#which
|
37
|
-
def which(program, path = ENV[
|
37
|
+
def which(program, path = ENV["PATH"])
|
38
38
|
WindowsWhich.new.call(program, path)
|
39
39
|
end
|
40
40
|
|
@@ -13,7 +13,7 @@ module Aruba
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def call(program, path)
|
16
|
-
|
16
|
+
raise %(Invalid input program "#{program}" and/or path "#{path}".)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -49,7 +49,7 @@ module Aruba
|
|
49
49
|
file = File.join(dir, program)
|
50
50
|
# Dir[] doesn't handle backslashes properly, so convert them. Also, if
|
51
51
|
# the program name doesn't have an extension, try them all.
|
52
|
-
file = file.tr('\\',
|
52
|
+
file = file.tr('\\', "/")
|
53
53
|
|
54
54
|
found = Dir[file].first
|
55
55
|
|
@@ -84,7 +84,7 @@ module Aruba
|
|
84
84
|
#
|
85
85
|
# @param [String] path
|
86
86
|
# ENV['PATH']
|
87
|
-
def call(program, path = ENV[
|
87
|
+
def call(program, path = ENV["PATH"])
|
88
88
|
raise ArgumentError, "ENV['PATH'] cannot be empty" if path.nil? || path.empty?
|
89
89
|
|
90
90
|
program = program.to_s
|
@@ -96,7 +96,11 @@ module Aruba
|
|
96
96
|
private
|
97
97
|
|
98
98
|
def windows_executable_extentions
|
99
|
-
|
99
|
+
if ENV["PATHEXT"]
|
100
|
+
format(".{%s}", ENV["PATHEXT"].tr(";", ",").tr(".", "")).downcase
|
101
|
+
else
|
102
|
+
".{exe,com,bat}"
|
103
|
+
end
|
100
104
|
end
|
101
105
|
end
|
102
106
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "aruba/platform"
|
2
|
+
require "shellwords"
|
3
3
|
|
4
4
|
# Aruba
|
5
5
|
module Aruba
|
@@ -14,7 +14,7 @@ module Aruba
|
|
14
14
|
attr_reader :exit_status, :environment, :working_directory, :main_class,
|
15
15
|
:io_wait_timeout, :exit_timeout, :startup_wait_time, :stop_signal
|
16
16
|
|
17
|
-
def initialize(cmd, exit_timeout, io_wait_timeout, working_directory,
|
17
|
+
def initialize(cmd, exit_timeout, io_wait_timeout, working_directory, # rubocop:disable Metrics/ParameterLists
|
18
18
|
environment = Aruba.platform.environment_variables.hash_from_env,
|
19
19
|
main_class = nil, stop_signal = nil, startup_wait_time = 0)
|
20
20
|
@cmd = cmd
|
@@ -135,7 +135,7 @@ module Aruba
|
|
135
135
|
def truncate(string, max_length)
|
136
136
|
return string if string.length <= max_length
|
137
137
|
|
138
|
-
string[0, max_length - 1]
|
138
|
+
"#{string[0, max_length - 1]} ..."
|
139
139
|
end
|
140
140
|
end
|
141
141
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "aruba/processes/spawn_process"
|
2
2
|
|
3
3
|
# Aruba
|
4
4
|
module Aruba
|
@@ -41,7 +41,8 @@ module Aruba
|
|
41
41
|
# @return [String]
|
42
42
|
# A predefined string to make users aware they are using the DebugProcess
|
43
43
|
def stdout(*)
|
44
|
-
|
44
|
+
"This is the debug launcher on STDOUT." \
|
45
|
+
" If this output is unexpected, please check your setup."
|
45
46
|
end
|
46
47
|
|
47
48
|
# Return stderr
|
@@ -49,7 +50,8 @@ module Aruba
|
|
49
50
|
# @return [String]
|
50
51
|
# A predefined string to make users aware they are using the DebugProcess
|
51
52
|
def stderr(*)
|
52
|
-
|
53
|
+
"This is the debug launcher on STDERR." \
|
54
|
+
" If this output is unexpected, please check your setup."
|
53
55
|
end
|
54
56
|
|
55
57
|
# Write to nothing
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "shellwords"
|
2
|
+
require "stringio"
|
3
|
+
require "aruba/processes/basic_process"
|
4
|
+
require "aruba/platform"
|
5
5
|
|
6
6
|
# Aruba
|
7
7
|
module Aruba
|
@@ -46,7 +46,7 @@ module Aruba
|
|
46
46
|
# @private
|
47
47
|
attr_reader :main_class
|
48
48
|
|
49
|
-
def initialize(cmd, exit_timeout, io_wait_timeout, working_directory,
|
49
|
+
def initialize(cmd, exit_timeout, io_wait_timeout, working_directory, # rubocop:disable Metrics/ParameterLists
|
50
50
|
environment = Aruba.platform.environment_variables.hash_from_env,
|
51
51
|
main_class = nil, stop_signal = nil, startup_wait_time = 0)
|
52
52
|
@cmd = cmd
|
@@ -61,14 +61,14 @@ module Aruba
|
|
61
61
|
|
62
62
|
# Start command
|
63
63
|
def start
|
64
|
-
|
64
|
+
raise "You need to call aruba.config.main_class = YourMainClass" unless main_class
|
65
65
|
|
66
66
|
@started = true
|
67
67
|
|
68
68
|
Dir.chdir @working_directory do
|
69
69
|
before_run
|
70
70
|
|
71
|
-
Aruba.platform.with_environment environment.merge(
|
71
|
+
Aruba.platform.with_environment environment.merge("PWD" => @working_directory) do
|
72
72
|
main_class.new(@argv, @stdin, @stdout, @stderr, @kernel).execute!
|
73
73
|
end
|
74
74
|
|
@@ -109,7 +109,9 @@ module Aruba
|
|
109
109
|
|
110
110
|
# Close io
|
111
111
|
def close_io(name)
|
112
|
-
|
112
|
+
unless [:stdin, :stdout, :stderr].include? name
|
113
|
+
raise ArgumentError, "Only stdin stdout and stderr are allowed to close"
|
114
|
+
end
|
113
115
|
|
114
116
|
get_instance_variable(name.to_sym).close
|
115
117
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "childprocess"
|
2
|
+
require "tempfile"
|
3
|
+
require "shellwords"
|
4
4
|
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
5
|
+
require "aruba/errors"
|
6
|
+
require "aruba/processes/basic_process"
|
7
|
+
require "aruba/platform"
|
8
8
|
|
9
9
|
# Aruba
|
10
10
|
module Aruba
|
@@ -48,7 +48,7 @@ module Aruba
|
|
48
48
|
#
|
49
49
|
# @param [Numeric] startup_wait_time
|
50
50
|
# The amount of seconds to wait after Aruba has started a command.
|
51
|
-
def initialize(cmd, exit_timeout, io_wait_timeout, working_directory,
|
51
|
+
def initialize(cmd, exit_timeout, io_wait_timeout, working_directory, # rubocop:disable Metrics/ParameterLists
|
52
52
|
environment = Aruba.platform.environment_variables.hash_from_env,
|
53
53
|
main_class = nil, stop_signal = nil, startup_wait_time = 0)
|
54
54
|
super
|
@@ -63,36 +63,32 @@ module Aruba
|
|
63
63
|
# @yield [SpawnProcess]
|
64
64
|
# Run code for process which was started
|
65
65
|
#
|
66
|
-
# rubocop:disable Metrics/MethodLength
|
67
66
|
def start
|
68
|
-
# rubocop:disable Layout/LineLength
|
69
67
|
if started?
|
70
|
-
error_message =
|
71
|
-
|
68
|
+
error_message =
|
69
|
+
"Command \"#{commandline}\" has already been started." \
|
70
|
+
" Please `#stop` the command first and `#start` it again." \
|
71
|
+
" Alternatively use `#restart`."
|
72
|
+
raise CommandAlreadyStartedError, error_message
|
72
73
|
end
|
73
74
|
|
74
|
-
# rubocop:enable Layout/LineLength
|
75
|
-
|
76
75
|
@started = true
|
77
76
|
|
78
77
|
@process = ChildProcess.build(*command_string.to_a)
|
79
|
-
@stdout_file = Tempfile.new(
|
80
|
-
@stderr_file = Tempfile.new(
|
78
|
+
@stdout_file = Tempfile.new("aruba-stdout-")
|
79
|
+
@stderr_file = Tempfile.new("aruba-stderr-")
|
81
80
|
|
82
81
|
@stdout_file.sync = true
|
83
82
|
@stderr_file.sync = true
|
84
83
|
|
85
|
-
|
86
|
-
|
87
|
-
@stderr_file.set_encoding('ASCII-8BIT')
|
88
|
-
end
|
84
|
+
@stdout_file.set_encoding("ASCII-8BIT")
|
85
|
+
@stderr_file.set_encoding("ASCII-8BIT")
|
89
86
|
|
90
87
|
@exit_status = nil
|
91
88
|
@duplex = true
|
92
89
|
|
93
90
|
before_run
|
94
91
|
|
95
|
-
@process.leader = true
|
96
92
|
@process.io.stdout = @stdout_file
|
97
93
|
@process.io.stderr = @stderr_file
|
98
94
|
@process.duplex = @duplex
|
@@ -113,7 +109,6 @@ module Aruba
|
|
113
109
|
|
114
110
|
yield self if block_given?
|
115
111
|
end
|
116
|
-
# rubocop:enable Metrics/MethodLength
|
117
112
|
|
118
113
|
# Access to stdin of process
|
119
114
|
def stdin
|
@@ -236,7 +231,7 @@ module Aruba
|
|
236
231
|
# The signal, i.e. 'TERM'
|
237
232
|
def send_signal(signal)
|
238
233
|
error_message = %(Command "#{commandline}" with PID "#{pid}" has already stopped.)
|
239
|
-
|
234
|
+
raise CommandAlreadyStoppedError, error_message if @process.exited?
|
240
235
|
|
241
236
|
Process.kill signal, pid
|
242
237
|
rescue Errno::ESRCH
|
@@ -267,13 +262,21 @@ module Aruba
|
|
267
262
|
private
|
268
263
|
|
269
264
|
def command_string
|
270
|
-
|
265
|
+
if command_path.nil?
|
266
|
+
raise LaunchError,
|
267
|
+
%(Command "#{command}" not found in PATH-variable "#{environment['PATH']}".)
|
268
|
+
end
|
271
269
|
|
272
270
|
Aruba.platform.command_string.new(command_path, *arguments)
|
273
271
|
end
|
274
272
|
|
275
273
|
def command_path
|
276
|
-
@command_path ||=
|
274
|
+
@command_path ||=
|
275
|
+
if Aruba.platform.builtin_shell_commands.include?(command)
|
276
|
+
command
|
277
|
+
else
|
278
|
+
Aruba.platform.which(command, environment["PATH"])
|
279
|
+
end
|
277
280
|
end
|
278
281
|
|
279
282
|
def wait_for_io(time_to_wait)
|
@@ -287,7 +290,7 @@ module Aruba
|
|
287
290
|
data = file.read
|
288
291
|
file.close
|
289
292
|
|
290
|
-
data.force_encoding(
|
293
|
+
data.force_encoding("UTF-8")
|
291
294
|
end
|
292
295
|
end
|
293
296
|
end
|