aruba 0.14.9 → 1.0.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/.cucumberproignore +3 -0
- data/.github/ISSUE_TEMPLATE.md +48 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +41 -0
- data/.gitignore +1 -0
- data/.rspec +1 -1
- data/.rubocop.yml +20 -179
- data/.rubocop_todo.yml +262 -0
- data/.simplecov +7 -5
- data/.travis.yml +54 -46
- data/.yardopts +3 -0
- data/CHANGELOG.md +613 -246
- data/CONTRIBUTING.md +247 -45
- data/Dockerfile +67 -0
- data/Gemfile +5 -96
- data/LICENSE +1 -1
- data/README.md +57 -180
- data/Rakefile +63 -32
- data/appveyor.yml +8 -11
- data/aruba.gemspec +47 -41
- data/bin/console +7 -0
- data/bin/test +9 -0
- data/cucumber.yml +4 -24
- data/doc/dependency_decisions.yml +42 -2
- data/docker-compose.yml +26 -0
- data/{bin → exe}/aruba +1 -1
- data/fixtures/cli-app/Rakefile +1 -1
- data/fixtures/cli-app/bin/aruba-test-cli +6 -0
- data/fixtures/cli-app/cli-app.gemspec +1 -2
- data/fixtures/cli-app/features/support/aruba.rb +1 -0
- data/fixtures/cli-app/features/support/env.rb +1 -1
- data/fixtures/cli-app/lib/cli/app/suppress_simple_cov_output.rb +3 -3
- data/fixtures/cli-app/lib/cli/app/version.rb +1 -1
- data/fixtures/cli-app/lib/cli/app.rb +1 -5
- data/fixtures/cli-app/spec/spec_helper.rb +4 -6
- data/fixtures/empty-app/Rakefile +1 -1
- data/fixtures/empty-app/cli-app.gemspec +1 -2
- data/fixtures/empty-app/lib/cli/app/version.rb +1 -1
- data/fixtures/empty-app/lib/cli/app.rb +0 -6
- data/fixtures/getting-started-app/Gemfile +1 -1
- data/lib/aruba/api/commands.rb +109 -143
- data/lib/aruba/api/core.rb +57 -43
- data/lib/aruba/api/environment.rb +16 -7
- data/lib/aruba/api/filesystem.rb +42 -29
- data/lib/aruba/api/text.rb +3 -9
- data/lib/aruba/api.rb +6 -11
- data/lib/aruba/aruba_path.rb +27 -89
- data/lib/aruba/basic_configuration.rb +4 -24
- data/lib/aruba/cli.rb +1 -1
- data/lib/aruba/colorizer.rb +10 -99
- data/lib/aruba/command.rb +2 -0
- data/lib/aruba/config/jruby.rb +15 -5
- data/lib/aruba/config_wrapper.rb +1 -1
- data/lib/aruba/configuration.rb +92 -0
- data/lib/aruba/console/help.rb +1 -7
- data/lib/aruba/console.rb +5 -5
- data/lib/aruba/contracts/absolute_path.rb +2 -2
- data/lib/aruba/contracts/relative_path.rb +2 -2
- data/lib/aruba/cucumber/command.rb +171 -160
- data/lib/aruba/cucumber/environment.rb +1 -1
- data/lib/aruba/cucumber/file.rb +21 -35
- data/lib/aruba/cucumber/hooks.rb +17 -56
- data/lib/aruba/cucumber/testing_frameworks.rb +74 -50
- data/lib/aruba/cucumber.rb +0 -5
- data/lib/aruba/event_bus/name_resolver.rb +5 -16
- data/lib/aruba/hooks.rb +1 -1
- data/lib/aruba/in_config_wrapper.rb +5 -1
- data/lib/aruba/initializer.rb +36 -42
- data/lib/aruba/matchers/base/base_matcher.rb +2 -2
- data/lib/aruba/matchers/base/message_indenter.rb +19 -0
- data/lib/aruba/matchers/base/object_formatter.rb +2 -9
- data/lib/aruba/matchers/collection/include_an_object.rb +7 -9
- data/lib/aruba/matchers/command/be_successfully_executed.rb +6 -4
- data/lib/aruba/matchers/command/have_exit_status.rb +14 -4
- data/lib/aruba/matchers/command/have_finished_in_time.rb +3 -5
- data/lib/aruba/matchers/command/have_output.rb +10 -5
- data/lib/aruba/matchers/command/have_output_on_stderr.rb +2 -2
- data/lib/aruba/matchers/command/have_output_on_stdout.rb +2 -2
- data/lib/aruba/matchers/command/have_output_size.rb +2 -2
- data/lib/aruba/matchers/directory/be_an_existing_directory.rb +5 -7
- data/lib/aruba/matchers/directory/have_sub_directory.rb +4 -6
- data/lib/aruba/matchers/file/be_a_command_found_in_path.rb +2 -4
- data/lib/aruba/matchers/file/be_an_existing_executable.rb +4 -6
- data/lib/aruba/matchers/file/be_an_existing_file.rb +5 -7
- data/lib/aruba/matchers/file/have_file_content.rb +4 -4
- data/lib/aruba/matchers/file/have_file_size.rb +6 -8
- data/lib/aruba/matchers/file/have_same_file_content.rb +5 -8
- data/lib/aruba/matchers/path/a_path_matching_pattern.rb +2 -4
- data/lib/aruba/matchers/path/be_an_absolute_path.rb +3 -5
- data/lib/aruba/matchers/path/be_an_existing_path.rb +4 -6
- data/lib/aruba/matchers/path/have_permissions.rb +6 -8
- data/lib/aruba/matchers/string/include_output_string.rb +8 -10
- data/lib/aruba/matchers/string/match_output_string.rb +9 -11
- data/lib/aruba/matchers/string/output_string_eq.rb +7 -9
- data/lib/aruba/platform.rb +0 -8
- data/lib/aruba/platforms/announcer.rb +42 -79
- data/lib/aruba/platforms/aruba_file_creator.rb +2 -6
- data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +2 -2
- data/lib/aruba/platforms/aruba_logger.rb +23 -7
- data/lib/aruba/platforms/command_monitor.rb +12 -107
- data/lib/aruba/platforms/determine_disk_usage.rb +56 -14
- data/lib/aruba/platforms/filesystem_status.rb +10 -14
- data/lib/aruba/platforms/local_environment.rb +2 -2
- data/lib/aruba/platforms/simple_table.rb +3 -11
- data/lib/aruba/platforms/unix_command_string.rb +7 -11
- data/lib/aruba/platforms/unix_environment_variables.rb +18 -27
- data/lib/aruba/platforms/unix_platform.rb +20 -51
- data/lib/aruba/platforms/unix_which.rb +2 -1
- data/lib/aruba/platforms/windows_command_string.rb +15 -10
- data/lib/aruba/platforms/windows_environment_variables.rb +43 -44
- data/lib/aruba/platforms/windows_platform.rb +4 -0
- data/lib/aruba/platforms/windows_which.rb +4 -3
- data/lib/aruba/processes/basic_process.rb +28 -30
- data/lib/aruba/processes/debug_process.rb +12 -3
- data/lib/aruba/processes/in_process.rb +17 -8
- data/lib/aruba/processes/spawn_process.rb +57 -46
- data/lib/aruba/rspec.rb +14 -36
- data/lib/aruba/runtime.rb +3 -6
- data/lib/aruba/setup.rb +6 -6
- data/lib/aruba/tasks/docker_helpers.rb +154 -0
- data/lib/aruba/version.rb +1 -1
- metadata +191 -244
- data/features/.nav +0 -72
- data/features/api/command/find_command.feature +0 -83
- data/features/api/command/last_command_started.feature +0 -50
- data/features/api/command/last_command_stopped.feature +0 -89
- data/features/api/command/run.feature +0 -414
- data/features/api/command/run_simple.feature +0 -242
- data/features/api/command/send_signal.feature +0 -53
- data/features/api/command/stderr.feature +0 -46
- data/features/api/command/stdout.feature +0 -46
- data/features/api/command/stop.feature +0 -131
- data/features/api/command/stop_all_commands.feature +0 -53
- data/features/api/command/terminate_all_commands.feature +0 -53
- data/features/api/command/which.feature +0 -37
- data/features/api/core/expand_path.feature +0 -88
- data/features/api/environment/append_environment_variable.feature +0 -128
- data/features/api/environment/delete_environment_variable.feature +0 -63
- data/features/api/environment/prepend_environment_variable.feature +0 -128
- data/features/api/environment/set_environment_variable.feature +0 -376
- data/features/api/filesystem/cd.feature +0 -184
- data/features/api/filesystem/create_directory.feature +0 -57
- data/features/api/filesystem/disk_usage.feature +0 -152
- data/features/api/filesystem/does_exist.feature +0 -62
- data/features/api/filesystem/fixtures.feature +0 -104
- data/features/api/filesystem/is_absolute.feature +0 -48
- data/features/api/filesystem/is_directory.feature +0 -53
- data/features/api/filesystem/is_file.feature +0 -54
- data/features/api/filesystem/is_relative.feature +0 -48
- data/features/api/filesystem/move.feature +0 -119
- data/features/api/text/extract_text.feature +0 -87
- data/features/api/text/replace_variables.feature +0 -45
- data/features/api/text/sanitize_text.feature +0 -228
- data/features/api/text/unescape_text.feature +0 -127
- data/features/cli/console.feature +0 -52
- data/features/cli/init.feature +0 -79
- data/features/configuration/activate_announcer_on_command_failure.feature +0 -38
- data/features/configuration/command_runtime_environment.feature +0 -129
- data/features/configuration/console_history_file.feature +0 -38
- data/features/configuration/exit_timeout.feature +0 -52
- data/features/configuration/fixtures_directories.feature +0 -38
- data/features/configuration/fixtures_path_prefix.feature +0 -23
- data/features/configuration/home_directory.feature +0 -80
- data/features/configuration/io_timeout.feature +0 -30
- data/features/configuration/keep_ansi.feature +0 -30
- data/features/configuration/log_level.feature +0 -38
- data/features/configuration/physical_block_size.feature +0 -53
- data/features/configuration/remove_ansi_escape_sequences.feature +0 -38
- data/features/configuration/root_directory.feature +0 -30
- data/features/configuration/startup_wait_time.feature +0 -48
- data/features/configuration/usage.feature +0 -159
- data/features/configuration/working_directory.feature +0 -33
- data/features/development/build.feature +0 -15
- data/features/getting_started/cleanup.feature +0 -58
- data/features/getting_started/run_commands.feature +0 -187
- data/features/getting_started/supported_testing_frameworks.feature +0 -104
- data/features/getting_started/writing_good_feature_tests.feature +0 -38
- data/features/hooks/after/command.feature +0 -46
- data/features/hooks/before/command.feature +0 -75
- data/features/matchers/collection/include_an_object.feature +0 -72
- data/features/matchers/directory/have_sub_directory.feature +0 -110
- data/features/matchers/file/be_a_command_found_in_path.feature +0 -115
- data/features/matchers/file/be_existing_executable.feature +0 -88
- data/features/matchers/file/be_existing_file.feature +0 -82
- data/features/matchers/file/have_file_content.feature +0 -123
- data/features/matchers/file/have_file_size.feature +0 -107
- data/features/matchers/path/be_an_absolute_path.feature +0 -74
- data/features/matchers/path/be_an_existing_path.feature +0 -97
- data/features/matchers/path/have_permissions.feature +0 -118
- data/features/matchers/timeouts.feature +0 -48
- data/features/platforms/jruby.feature +0 -14
- data/features/rspec/integration.feature +0 -179
- data/features/step_definitions/aruba_dev_steps.rb +0 -56
- data/features/step_definitions/hooks.rb +0 -156
- data/features/steps/command/debug.feature +0 -92
- data/features/steps/command/exit_statuses.feature +0 -136
- data/features/steps/command/in_process.feature +0 -485
- data/features/steps/command/interactive.feature +0 -90
- data/features/steps/command/output.feature +0 -567
- data/features/steps/command/run.feature +0 -66
- data/features/steps/command/send_signal.feature +0 -104
- data/features/steps/command/shell.feature +0 -155
- data/features/steps/command/stderr.feature +0 -68
- data/features/steps/command/stdout.feature +0 -109
- data/features/steps/command/stop.feature +0 -313
- data/features/steps/core/announce.feature +0 -283
- data/features/steps/environment/append_environment_variable.feature +0 -52
- data/features/steps/environment/disable_bunder.feature +0 -18
- data/features/steps/environment/home_variable.feature +0 -62
- data/features/steps/environment/prepend_environment_variable.feature +0 -52
- data/features/steps/environment/set_environment_variable.feature +0 -49
- data/features/steps/filesystem/append_to_file.feature +0 -45
- data/features/steps/filesystem/cd_to_directory.feature +0 -33
- data/features/steps/filesystem/check_file_content.feature +0 -61
- data/features/steps/filesystem/check_permissions_of_file.feature +0 -39
- data/features/steps/filesystem/compare_files.feature +0 -42
- data/features/steps/filesystem/copy.feature +0 -45
- data/features/steps/filesystem/create_directory.feature +0 -57
- data/features/steps/filesystem/create_file.feature +0 -76
- data/features/steps/filesystem/existence_of_directory.feature +0 -57
- data/features/steps/filesystem/existence_of_file.feature +0 -43
- data/features/steps/filesystem/file_content.feature +0 -86
- data/features/steps/filesystem/fixtures.feature +0 -64
- data/features/steps/filesystem/move.feature +0 -45
- data/features/steps/filesystem/non_existence_of_directory.feature +0 -69
- data/features/steps/filesystem/non_existence_of_file.feature +0 -80
- data/features/steps/filesystem/overwrite_file.feature +0 -72
- data/features/steps/filesystem/remove_directory.feature +0 -38
- data/features/steps/filesystem/remove_file.feature +0 -38
- data/features/steps/filesystem/use_fixture.feature +0 -77
- data/features/steps/overview.feature +0 -25
- data/features/support/aruba.rb +0 -7
- data/features/support/env.rb +0 -33
- data/features/support/jruby.rb +0 -5
- data/features/support/simplecov_setup.rb +0 -8
- data/fixtures/cli-app/bin/cli +0 -6
- data/fixtures/spawn_process/stderr.sh +0 -3
- data/lib/aruba/api/deprecated.rb +0 -1234
- data/lib/aruba/config.rb +0 -107
- data/lib/aruba/cucumber/core.rb +0 -5
- data/lib/aruba/cucumber/rvm.rb +0 -3
- data/lib/aruba/in_process.rb +0 -14
- data/lib/aruba/jruby.rb +0 -4
- data/lib/aruba/matchers/deprecated/file.rb +0 -17
- data/lib/aruba/matchers/deprecated.rb +0 -1
- data/lib/aruba/matchers/path/match_path_pattern.rb +0 -41
- data/lib/aruba/matchers/rspec_matcher_include_regexp.rb +0 -25
- data/lib/aruba/platforms/disk_usage_calculator.rb +0 -20
- data/lib/aruba/reporting.rb +0 -126
- data/lib/aruba/spawn_process.rb +0 -11
- data/script/bootstrap +0 -28
- data/script/console +0 -16
- data/script/test +0 -3
- data/spec/aruba/api/bundler_spec.rb +0 -15
- data/spec/aruba/api/deprecated_spec.rb +0 -308
- data/spec/aruba/api/environment/restore_env_spec.rb +0 -86
- data/spec/aruba/api/environment/set_env_spec.rb +0 -46
- data/spec/aruba/api/filesystem/file_size_spec.rb +0 -28
- data/spec/aruba/api/runtime_spec.rb +0 -28
- data/spec/aruba/api_spec.rb +0 -981
- data/spec/aruba/aruba_path_spec.rb +0 -103
- data/spec/aruba/basic_configuration_spec.rb +0 -5
- data/spec/aruba/configuration_spec.rb +0 -5
- data/spec/aruba/hooks_spec.rb +0 -17
- data/spec/aruba/in_config_wrapper_spec.rb +0 -25
- data/spec/aruba/jruby_spec.rb +0 -55
- data/spec/aruba/matchers/command/have_output_size_spec.rb +0 -25
- data/spec/aruba/matchers/command_spec.rb +0 -174
- data/spec/aruba/matchers/deprecated_spec.rb +0 -120
- data/spec/aruba/matchers/directory_spec.rb +0 -57
- data/spec/aruba/matchers/file_spec.rb +0 -208
- data/spec/aruba/matchers/path_spec.rb +0 -58
- data/spec/aruba/platform/simple_table_spec.rb +0 -23
- data/spec/aruba/platform/windows_environment_variables_spec.rb +0 -500
- data/spec/aruba/platforms/unix_command_string_spec.rb +0 -17
- data/spec/aruba/platforms/windows_command_string_spec.rb +0 -22
- data/spec/aruba/rspec_spec.rb +0 -15
- data/spec/aruba/runtime_spec.rb +0 -29
- data/spec/aruba/spawn_process_spec.rb +0 -96
- data/spec/event_bus/name_resolver_spec.rb +0 -68
- data/spec/event_bus_spec.rb +0 -158
- data/spec/spec_helper.rb +0 -20
- data/spec/support/configs/.keep +0 -0
- data/spec/support/configs/aruba.rb +0 -5
- data/spec/support/configs/pry.rb +0 -3
- data/spec/support/configs/rspec.rb +0 -15
- data/spec/support/helpers/.keep +0 -0
- data/spec/support/helpers/reporting.rb +0 -44
- data/spec/support/matchers/.keep +0 -0
- data/spec/support/matchers/option.rb +0 -35
- data/spec/support/shared_contexts/.keep +0 -0
- data/spec/support/shared_contexts/aruba.rb +0 -49
- data/spec/support/shared_examples/.keep +0 -0
- data/spec/support/shared_examples/configuration.rb +0 -116
- data/spec/support/shared_examples/directory.rb +0 -7
- data/spec/support/shared_examples/file.rb +0 -7
- data/templates/css/console.css +0 -24
- data/templates/css/filesystem.css +0 -42
- data/templates/css/pygments-autumn.css +0 -59
- data/templates/files.erb +0 -14
- data/templates/images/LICENSE +0 -22
- data/templates/images/folder.png +0 -0
- data/templates/images/page_white.png +0 -0
- data/templates/images/page_white_gherkin.png +0 -0
- data/templates/images/page_white_ruby.png +0 -0
- data/templates/index.erb +0 -20
- data/templates/js/filesystem.js +0 -5
- data/templates/js/jquery-1.11.3.min.js +0 -5
- data/templates/main.erb +0 -34
|
@@ -19,24 +19,38 @@ module Aruba
|
|
|
19
19
|
# @private
|
|
20
20
|
class SpawnProcess < BasicProcess
|
|
21
21
|
# Use as default launcher
|
|
22
|
-
def self.match?(
|
|
22
|
+
def self.match?(_mode)
|
|
23
23
|
true
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
# Create process
|
|
27
27
|
#
|
|
28
|
-
# @
|
|
28
|
+
# @param [String] cmd
|
|
29
29
|
# Command string
|
|
30
30
|
#
|
|
31
|
-
# @
|
|
31
|
+
# @param [Numeric] exit_timeout
|
|
32
32
|
# The timeout until we expect the command to be finished
|
|
33
33
|
#
|
|
34
|
-
# @
|
|
34
|
+
# @param [Numeric] io_wait_timeout
|
|
35
35
|
# The timeout until we expect the io to be finished
|
|
36
36
|
#
|
|
37
|
-
# @
|
|
37
|
+
# @param [String] working_directory
|
|
38
38
|
# The directory where the command will be executed
|
|
39
|
-
|
|
39
|
+
#
|
|
40
|
+
# @param [Hash] environment
|
|
41
|
+
# Environment variables
|
|
42
|
+
#
|
|
43
|
+
# @param [Class] main_class
|
|
44
|
+
# E.g. Cli::App::Runner
|
|
45
|
+
#
|
|
46
|
+
# @param [String] stop_signal
|
|
47
|
+
# Name of signal to send to stop process. E.g. 'HUP'.
|
|
48
|
+
#
|
|
49
|
+
# @param [Numeric] startup_wait_time
|
|
50
|
+
# The amount of seconds to wait after Aruba has started a command.
|
|
51
|
+
def initialize(cmd, exit_timeout, io_wait_timeout, working_directory,
|
|
52
|
+
environment = Aruba.platform.environment_variables.hash_from_env,
|
|
53
|
+
main_class = nil, stop_signal = nil, startup_wait_time = 0)
|
|
40
54
|
super
|
|
41
55
|
|
|
42
56
|
@process = nil
|
|
@@ -51,21 +65,27 @@ module Aruba
|
|
|
51
65
|
#
|
|
52
66
|
# rubocop:disable Metrics/MethodLength
|
|
53
67
|
def start
|
|
54
|
-
# rubocop:disable
|
|
55
|
-
|
|
56
|
-
|
|
68
|
+
# rubocop:disable Layout/LineLength
|
|
69
|
+
if started?
|
|
70
|
+
error_message = %(Command "#{commandline}" has already been started. Please `#stop` the command first and `#start` it again. Alternatively use `#restart`.\n#{caller.join("\n")})
|
|
71
|
+
fail CommandAlreadyStartedError, error_message
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# rubocop:enable Layout/LineLength
|
|
57
75
|
|
|
58
76
|
@started = true
|
|
59
77
|
|
|
60
|
-
@process = ChildProcess.build(*
|
|
78
|
+
@process = ChildProcess.build(*command_string.to_a)
|
|
61
79
|
@stdout_file = Tempfile.new('aruba-stdout-')
|
|
62
80
|
@stderr_file = Tempfile.new('aruba-stderr-')
|
|
63
81
|
|
|
64
82
|
@stdout_file.sync = true
|
|
65
83
|
@stderr_file.sync = true
|
|
66
84
|
|
|
67
|
-
|
|
68
|
-
|
|
85
|
+
if RUBY_VERSION >= '1.9'
|
|
86
|
+
@stdout_file.set_encoding('ASCII-8BIT')
|
|
87
|
+
@stderr_file.set_encoding('ASCII-8BIT')
|
|
88
|
+
end
|
|
69
89
|
|
|
70
90
|
@exit_status = nil
|
|
71
91
|
@duplex = true
|
|
@@ -86,7 +106,7 @@ module Aruba
|
|
|
86
106
|
sleep startup_wait_time
|
|
87
107
|
end
|
|
88
108
|
rescue ChildProcess::LaunchError => e
|
|
89
|
-
raise LaunchError, "It tried to start #{
|
|
109
|
+
raise LaunchError, "It tried to start #{commandline}. " + e.message
|
|
90
110
|
end
|
|
91
111
|
|
|
92
112
|
after_run
|
|
@@ -140,14 +160,6 @@ module Aruba
|
|
|
140
160
|
end
|
|
141
161
|
end
|
|
142
162
|
|
|
143
|
-
def read_stdout
|
|
144
|
-
# rubocop:disable Metrics/LineLength
|
|
145
|
-
Aruba.platform.deprecated('The use of "#read_stdout" is deprecated. Use "#stdout" instead. To reduce the time to wait for io, pass `:wait_for_io => 0` or some suitable for your use case')
|
|
146
|
-
# rubocop:enable Metrics/LineLength
|
|
147
|
-
|
|
148
|
-
stdout(:wait_for_io => 0)
|
|
149
|
-
end
|
|
150
|
-
|
|
151
163
|
def write(input)
|
|
152
164
|
return if stopped?
|
|
153
165
|
|
|
@@ -161,11 +173,7 @@ module Aruba
|
|
|
161
173
|
def close_io(name)
|
|
162
174
|
return if stopped?
|
|
163
175
|
|
|
164
|
-
|
|
165
|
-
@process.io.send(name.to_sym).close
|
|
166
|
-
else
|
|
167
|
-
@process.io.public_send(name.to_sym).close
|
|
168
|
-
end
|
|
176
|
+
@process.io.public_send(name.to_sym).close
|
|
169
177
|
end
|
|
170
178
|
|
|
171
179
|
# Stop command
|
|
@@ -197,18 +205,19 @@ module Aruba
|
|
|
197
205
|
# ... and set the exit status
|
|
198
206
|
wait
|
|
199
207
|
else
|
|
200
|
-
|
|
208
|
+
begin
|
|
209
|
+
@process.stop
|
|
210
|
+
rescue Errno::EPERM # This can occur on MacOS
|
|
211
|
+
nil
|
|
212
|
+
end
|
|
201
213
|
end
|
|
202
214
|
end
|
|
203
215
|
|
|
204
|
-
@exit_status
|
|
216
|
+
@exit_status = @process.exit_code
|
|
205
217
|
|
|
206
218
|
@stdout_cache = read_temporary_output_file @stdout_file
|
|
207
219
|
@stderr_cache = read_temporary_output_file @stderr_file
|
|
208
220
|
|
|
209
|
-
# @stdout_file = nil
|
|
210
|
-
# @stderr_file = nil
|
|
211
|
-
|
|
212
221
|
@started = false
|
|
213
222
|
|
|
214
223
|
@exit_status
|
|
@@ -226,11 +235,12 @@ module Aruba
|
|
|
226
235
|
# @param [String] signal
|
|
227
236
|
# The signal, i.e. 'TERM'
|
|
228
237
|
def send_signal(signal)
|
|
229
|
-
|
|
238
|
+
error_message = %(Command "#{commandline}" with PID "#{pid}" has already stopped.)
|
|
239
|
+
fail CommandAlreadyStoppedError, error_message if @process.exited?
|
|
230
240
|
|
|
231
241
|
Process.kill signal, pid
|
|
232
242
|
rescue Errno::ESRCH
|
|
233
|
-
raise CommandAlreadyStoppedError,
|
|
243
|
+
raise CommandAlreadyStoppedError, error_message
|
|
234
244
|
end
|
|
235
245
|
|
|
236
246
|
# Return file system stats for the given command
|
|
@@ -238,7 +248,7 @@ module Aruba
|
|
|
238
248
|
# @return [Aruba::Platforms::FilesystemStatus]
|
|
239
249
|
# This returns a File::Stat-object
|
|
240
250
|
def filesystem_status
|
|
241
|
-
Aruba.platform.filesystem_status.new(
|
|
251
|
+
Aruba.platform.filesystem_status.new(command_path)
|
|
242
252
|
end
|
|
243
253
|
|
|
244
254
|
# Content of command
|
|
@@ -247,22 +257,27 @@ module Aruba
|
|
|
247
257
|
# The content of the script/command. This might be binary output as
|
|
248
258
|
# string if your command is a binary executable.
|
|
249
259
|
def content
|
|
250
|
-
File.read
|
|
260
|
+
File.read command_path
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
def interactive?
|
|
264
|
+
true
|
|
251
265
|
end
|
|
252
266
|
|
|
253
267
|
private
|
|
254
268
|
|
|
255
269
|
def command_string
|
|
256
|
-
#
|
|
257
|
-
cmd = Aruba.platform.which(command, environment['PATH'])
|
|
270
|
+
fail LaunchError, %(Command "#{command}" not found in PATH-variable "#{environment['PATH']}".) if command_path.nil?
|
|
258
271
|
|
|
259
|
-
|
|
272
|
+
Aruba.platform.command_string.new(command_path, *arguments)
|
|
273
|
+
end
|
|
260
274
|
|
|
261
|
-
|
|
275
|
+
def command_path
|
|
276
|
+
@command_path ||= (Aruba.platform.builtin_shell_commands.include?(command) ? command : Aruba.platform.which(command, environment['PATH']))
|
|
262
277
|
end
|
|
263
278
|
|
|
264
|
-
def wait_for_io(time_to_wait
|
|
265
|
-
sleep time_to_wait
|
|
279
|
+
def wait_for_io(time_to_wait)
|
|
280
|
+
sleep time_to_wait
|
|
266
281
|
yield
|
|
267
282
|
end
|
|
268
283
|
|
|
@@ -272,11 +287,7 @@ module Aruba
|
|
|
272
287
|
data = file.read
|
|
273
288
|
file.close
|
|
274
289
|
|
|
275
|
-
|
|
276
|
-
data.force_encoding('UTF-8')
|
|
277
|
-
else
|
|
278
|
-
data
|
|
279
|
-
end
|
|
290
|
+
data.force_encoding('UTF-8')
|
|
280
291
|
end
|
|
281
292
|
end
|
|
282
293
|
end
|
data/lib/aruba/rspec.rb
CHANGED
|
@@ -4,32 +4,36 @@ require 'aruba'
|
|
|
4
4
|
require 'aruba/api'
|
|
5
5
|
require 'aruba/version'
|
|
6
6
|
|
|
7
|
-
if Aruba::VERSION >= '1.0.0'
|
|
8
|
-
Aruba.configure do |config|
|
|
9
|
-
config.working_directory = 'tmp/rspec'
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
7
|
RSpec.configure do |config|
|
|
14
|
-
config.include Aruba::Api, :
|
|
8
|
+
config.include Aruba::Api, type: :aruba
|
|
15
9
|
|
|
16
10
|
# Setup environment for aruba
|
|
17
11
|
config.around :each do |example|
|
|
18
12
|
if self.class.include? Aruba::Api
|
|
19
13
|
setup_aruba
|
|
14
|
+
|
|
15
|
+
# Modify PATH to include project/bin
|
|
16
|
+
prepend_environment_variable 'PATH',
|
|
17
|
+
aruba.config.command_search_paths.join(File::PATH_SEPARATOR) + File::PATH_SEPARATOR
|
|
18
|
+
|
|
19
|
+
# Use configured home directory as HOME
|
|
20
|
+
set_environment_variable 'HOME', aruba.config.home_directory
|
|
20
21
|
end
|
|
21
22
|
|
|
22
23
|
example.run
|
|
23
24
|
|
|
24
25
|
next unless self.class.include? Aruba::Api
|
|
26
|
+
|
|
25
27
|
stop_all_commands
|
|
26
28
|
end
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
config.around :each do |example|
|
|
31
|
+
if self.class.include? Aruba::Api
|
|
32
|
+
with_environment do
|
|
31
33
|
example.run
|
|
32
34
|
end
|
|
35
|
+
else
|
|
36
|
+
example.run
|
|
33
37
|
end
|
|
34
38
|
end
|
|
35
39
|
|
|
@@ -43,21 +47,9 @@ RSpec.configure do |config|
|
|
|
43
47
|
config.before :each do |example|
|
|
44
48
|
next unless self.class.include?(Aruba::Api)
|
|
45
49
|
|
|
46
|
-
if example.metadata[:announce_environment]
|
|
47
|
-
Aruba.platform.deprecated 'announce_environment is deprecated. Use announce_changed_environment instead'
|
|
48
|
-
|
|
49
|
-
aruba.announcer.activate(:changed_environment)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
50
|
aruba.announcer.activate(:full_environment) if example.metadata[:announce_full_environment]
|
|
53
51
|
aruba.announcer.activate(:changed_environment) if example.metadata[:announce_changed_environment]
|
|
54
52
|
|
|
55
|
-
if example.metadata[:announce_modified_environment]
|
|
56
|
-
Aruba.platform.deprecated 'announce_modified_environment is deprecated. Use announce_changed_environment instead'
|
|
57
|
-
|
|
58
|
-
aruba.announcer.activate(:changed_environment)
|
|
59
|
-
end
|
|
60
|
-
|
|
61
53
|
aruba.announcer.activate(:command) if example.metadata[:announce_command]
|
|
62
54
|
aruba.announcer.activate(:directory) if example.metadata[:announce_directory]
|
|
63
55
|
aruba.announcer.activate(:full_environment) if example.metadata[:announce_full_environment]
|
|
@@ -89,18 +81,4 @@ RSpec.configure do |config|
|
|
|
89
81
|
aruba.announcer.activate(:command_filesystem_status)
|
|
90
82
|
end
|
|
91
83
|
end
|
|
92
|
-
|
|
93
|
-
# Modify PATH to include project/bin
|
|
94
|
-
config.before :each do
|
|
95
|
-
next unless self.class.include? Aruba::Api
|
|
96
|
-
|
|
97
|
-
prepend_environment_variable 'PATH', aruba.config.command_search_paths.join(':') + ':'
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
# Use configured home directory as HOME
|
|
101
|
-
config.before :each do |example|
|
|
102
|
-
next unless self.class.include? Aruba::Api
|
|
103
|
-
|
|
104
|
-
set_environment_variable 'HOME', aruba.config.home_directory
|
|
105
|
-
end
|
|
106
84
|
end
|
data/lib/aruba/runtime.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require 'aruba/
|
|
1
|
+
require 'aruba/configuration'
|
|
2
2
|
require 'aruba/aruba_path'
|
|
3
3
|
require 'aruba/config_wrapper'
|
|
4
4
|
require 'aruba/events'
|
|
@@ -49,11 +49,7 @@ module Aruba
|
|
|
49
49
|
|
|
50
50
|
@environment.update(@config.command_runtime_environment)
|
|
51
51
|
|
|
52
|
-
@command_monitor =
|
|
53
|
-
opts.fetch(:command_monitor, Aruba.platform.command_monitor.new(:announcer => @announcer))
|
|
54
|
-
else
|
|
55
|
-
opts.fetch(:command_monitor, Aruba.platform.command_monitor.new)
|
|
56
|
-
end
|
|
52
|
+
@command_monitor = opts.fetch(:command_monitor, Aruba.platform.command_monitor.new(announcer: @announcer))
|
|
57
53
|
|
|
58
54
|
@logger = opts.fetch(:logger, Aruba.platform.logger.new)
|
|
59
55
|
@logger.mode = @config.log_level
|
|
@@ -86,6 +82,7 @@ module Aruba
|
|
|
86
82
|
directory = candidates.find { |d| Aruba.platform.directory? d }
|
|
87
83
|
|
|
88
84
|
fail "No existing fixtures directory found in #{candidates.map { |d| format('"%s"', d) }.join(', ')}." unless directory
|
|
85
|
+
|
|
89
86
|
directory
|
|
90
87
|
end
|
|
91
88
|
|
data/lib/aruba/setup.rb
CHANGED
|
@@ -25,7 +25,7 @@ module Aruba
|
|
|
25
25
|
|
|
26
26
|
def working_directory(clobber = true)
|
|
27
27
|
if clobber
|
|
28
|
-
Aruba.platform.rm File.join(runtime.config.root_directory, runtime.config.working_directory), :
|
|
28
|
+
Aruba.platform.rm File.join(runtime.config.root_directory, runtime.config.working_directory), force: true
|
|
29
29
|
end
|
|
30
30
|
Aruba.platform.mkdir File.join(runtime.config.root_directory, runtime.config.working_directory)
|
|
31
31
|
Aruba.platform.chdir runtime.config.root_directory
|
|
@@ -36,11 +36,11 @@ module Aruba
|
|
|
36
36
|
runtime.event_bus.register(
|
|
37
37
|
:command_started,
|
|
38
38
|
proc do |event|
|
|
39
|
-
runtime.announcer.announce
|
|
40
|
-
runtime.announcer.announce
|
|
41
|
-
runtime.announcer.announce
|
|
42
|
-
runtime.announcer.announce
|
|
43
|
-
runtime.announcer.announce
|
|
39
|
+
runtime.announcer.announce(:command) { event.entity.commandline }
|
|
40
|
+
runtime.announcer.announce(:timeout, 'exit') { event.entity.exit_timeout }
|
|
41
|
+
runtime.announcer.announce(:timeout, 'io wait') { event.entity.io_wait_timeout }
|
|
42
|
+
runtime.announcer.announce(:wait_time, 'startup wait time') { event.entity.startup_wait_time }
|
|
43
|
+
runtime.announcer.announce(:full_environment) { event.entity.environment }
|
|
44
44
|
end
|
|
45
45
|
)
|
|
46
46
|
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
require 'psych'
|
|
2
|
+
|
|
3
|
+
module Aruba
|
|
4
|
+
class DockerRunInstance
|
|
5
|
+
protected
|
|
6
|
+
|
|
7
|
+
attr_reader :file, :instance
|
|
8
|
+
|
|
9
|
+
public
|
|
10
|
+
|
|
11
|
+
def initialize(file, instance)
|
|
12
|
+
@file = file
|
|
13
|
+
@instance = instance
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def method_missing(m, *_args)
|
|
17
|
+
@file.public_send m, instance
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def respond_to_missing?(m)
|
|
21
|
+
@file.respond_to? m
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
class DockerBuildCommandLineBuilder
|
|
26
|
+
protected
|
|
27
|
+
|
|
28
|
+
attr_reader :run_instance, :opts
|
|
29
|
+
|
|
30
|
+
public
|
|
31
|
+
|
|
32
|
+
def initialize(run_instance, opts = {})
|
|
33
|
+
@run_instance = run_instance
|
|
34
|
+
@opts = opts
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def to_cli
|
|
38
|
+
cache = opts[:cache]
|
|
39
|
+
application_version = opts[:version]
|
|
40
|
+
docker_file = run_instance.docker_file
|
|
41
|
+
docker_image = run_instance.image
|
|
42
|
+
|
|
43
|
+
cmdline = []
|
|
44
|
+
cmdline << 'docker'
|
|
45
|
+
cmdline << 'build'
|
|
46
|
+
cmdline << '--no-cache=true' if cache == 'false'
|
|
47
|
+
|
|
48
|
+
%w(http_proxy https_proxy HTTP_PROXY HTTPS_PROXY).each do |var|
|
|
49
|
+
next unless ENV.key? var
|
|
50
|
+
|
|
51
|
+
proxy_uri = URI(ENV[var])
|
|
52
|
+
proxy_uri.host = '172.17.0.1'
|
|
53
|
+
cmdline << "--build-arg #{var}=#{proxy_uri}"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
cmdline << "-t #{docker_image}:#{application_version}"
|
|
57
|
+
cmdline << "-f #{docker_file}"
|
|
58
|
+
cmdline << File.dirname(docker_file)
|
|
59
|
+
|
|
60
|
+
cmdline.join(' ')
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
class DockerRunCommandLineBuilder
|
|
65
|
+
protected
|
|
66
|
+
|
|
67
|
+
attr_reader :run_instance, :opts
|
|
68
|
+
|
|
69
|
+
public
|
|
70
|
+
|
|
71
|
+
def initialize(run_instance, opts = {})
|
|
72
|
+
@run_instance = run_instance
|
|
73
|
+
@opts = opts
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def to_cli
|
|
77
|
+
volumes = run_instance.volumes
|
|
78
|
+
image = run_instance.image
|
|
79
|
+
command = opts[:command]
|
|
80
|
+
|
|
81
|
+
cmdline = []
|
|
82
|
+
cmdline << 'docker'
|
|
83
|
+
cmdline << 'run'
|
|
84
|
+
cmdline << '-it'
|
|
85
|
+
cmdline << '--rm'
|
|
86
|
+
cmdline << "--name #{run_instance.container_name}"
|
|
87
|
+
|
|
88
|
+
volumes.each do |v|
|
|
89
|
+
cmdline << "-v #{expand_volume_paths(v)}"
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
cmdline << image
|
|
93
|
+
cmdline << command if command
|
|
94
|
+
|
|
95
|
+
cmdline.join(' ')
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
private
|
|
99
|
+
|
|
100
|
+
def expand_volume_paths(volume_paths)
|
|
101
|
+
volume_paths.split(':').map { |path| File.expand_path(path) }.join(':')
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
class DockerComposeFile
|
|
106
|
+
protected
|
|
107
|
+
|
|
108
|
+
attr_reader :data
|
|
109
|
+
|
|
110
|
+
public
|
|
111
|
+
|
|
112
|
+
def initialize(path)
|
|
113
|
+
@data = Psych.load_file(path)['services']
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def volumes(instance)
|
|
117
|
+
fetch(instance)['volumes']
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def build_context(instance)
|
|
121
|
+
fetch(instance).fetch('build', {})['context']
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def build_arguments(instance)
|
|
125
|
+
fetch(instance).fetch('build', {})['args']
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def docker_file(instance)
|
|
129
|
+
fetch(instance).fetch('build', {})['dockerfile']
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def image(instance)
|
|
133
|
+
fetch(instance)['image']
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def container_name(instance)
|
|
137
|
+
fetch(instance)['container_name']
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def command(instance)
|
|
141
|
+
fetch(instance)['command']
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def working_directory(instance)
|
|
145
|
+
fetch(instance)['working_dir']
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
private
|
|
149
|
+
|
|
150
|
+
def fetch(instance)
|
|
151
|
+
Hash(data).fetch(instance.to_s)
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
data/lib/aruba/version.rb
CHANGED