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
data/{bin → exe}/aruba
RENAMED
data/fixtures/cli-app/Rakefile
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'bundler/gem_tasks'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'aruba/cucumber'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative 'aruba'
|
|
@@ -2,12 +2,12 @@ module SimpleCov
|
|
|
2
2
|
module Formatter
|
|
3
3
|
class HTMLFormatter
|
|
4
4
|
def format(result)
|
|
5
|
-
Dir[File.join(File.dirname(__FILE__),
|
|
5
|
+
Dir[File.join(File.dirname(__FILE__), '../public/*')].each do |path|
|
|
6
6
|
FileUtils.cp_r(path, asset_output_path)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
File.open(File.join(output_path,
|
|
10
|
-
file.puts template(
|
|
9
|
+
File.open(File.join(output_path, 'index.html'), 'wb') do |file|
|
|
10
|
+
file.puts template('layout').result(binding)
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
end
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
require 'cli/app/version'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
::Dir.glob(::File.expand_path('../**/*.rb', __FILE__)).each { |f| require File.join(File.dirname(f), File.basename(f, '.rb')) }
|
|
5
|
-
else
|
|
6
|
-
::Dir.glob(File.expand_path('../**/*.rb', __FILE__)).each { |f| require_relative f }
|
|
7
|
-
end
|
|
3
|
+
::Dir.glob(File.expand_path('**/*.rb', __dir__)).each { |f| require_relative f }
|
|
8
4
|
|
|
9
5
|
module Cli
|
|
10
6
|
module App
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
$LOAD_PATH.unshift File.expand_path('
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
|
|
2
2
|
|
|
3
3
|
require 'cli/app'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
::Dir.glob(::File.expand_path('../support/**/*.rb', __FILE__)).each { |f| require_relative f }
|
|
9
|
-
end
|
|
5
|
+
require_relative 'support/aruba'
|
|
6
|
+
|
|
7
|
+
::Dir.glob(::File.expand_path('../support/**/*.rb', __FILE__)).each { |f| require_relative f }
|
data/fixtures/empty-app/Rakefile
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'bundler/gem_tasks'
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
require 'cli/app/version'
|
|
2
2
|
|
|
3
|
-
if RUBY_VERSION < '1.9.3'
|
|
4
|
-
::Dir.glob(::File.expand_path('../**/*.rb', __FILE__)).each { |f| require File.join(File.dirname(f), File.basename(f, '.rb')) }
|
|
5
|
-
else
|
|
6
|
-
::Dir.glob(File.expand_path('../**/*.rb', __FILE__)).each { |f| require_relative f }
|
|
7
|
-
end
|
|
8
|
-
|
|
9
3
|
module Cli
|
|
10
4
|
module App
|
|
11
5
|
# Your code goes here...
|
data/lib/aruba/api/commands.rb
CHANGED
|
@@ -5,17 +5,6 @@ require 'aruba/command'
|
|
|
5
5
|
|
|
6
6
|
# require 'win32/file' if File::ALT_SEPARATOR
|
|
7
7
|
|
|
8
|
-
# Aruba
|
|
9
|
-
module Aruba
|
|
10
|
-
class << self
|
|
11
|
-
# @deprecated
|
|
12
|
-
attr_accessor :process
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# @deprecated
|
|
16
|
-
# self.process = Aruba::Processes::SpawnProcess
|
|
17
|
-
end
|
|
18
|
-
|
|
19
8
|
# Aruba
|
|
20
9
|
module Aruba
|
|
21
10
|
# Api
|
|
@@ -103,6 +92,30 @@ module Aruba
|
|
|
103
92
|
self
|
|
104
93
|
end
|
|
105
94
|
|
|
95
|
+
# Get stdout of all processes
|
|
96
|
+
#
|
|
97
|
+
# @return [String]
|
|
98
|
+
# The stdout of all processes which have run before
|
|
99
|
+
def all_stdout
|
|
100
|
+
aruba.command_monitor.all_stdout
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# Get stderr of all processes
|
|
104
|
+
#
|
|
105
|
+
# @return [String]
|
|
106
|
+
# The stderr of all processes which have run before
|
|
107
|
+
def all_stderr
|
|
108
|
+
aruba.command_monitor.all_stderr
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Get stderr and stdout of all processes
|
|
112
|
+
#
|
|
113
|
+
# @return [String]
|
|
114
|
+
# The stderr and stdout of all processes which have run before
|
|
115
|
+
def all_output
|
|
116
|
+
aruba.command_monitor.all_output
|
|
117
|
+
end
|
|
118
|
+
|
|
106
119
|
# Find a started command
|
|
107
120
|
#
|
|
108
121
|
# @param [String, Command] commandline
|
|
@@ -119,108 +132,33 @@ module Aruba
|
|
|
119
132
|
# @param [Hash] opts
|
|
120
133
|
# Options
|
|
121
134
|
#
|
|
122
|
-
# @option [
|
|
135
|
+
# @option opts [Numeric] exit_timeout
|
|
123
136
|
# If the timeout is reached the command will be killed
|
|
124
137
|
#
|
|
125
|
-
# @option [
|
|
138
|
+
# @option opts [Numeric] io_wait_timeout
|
|
126
139
|
# Wait for IO to finish
|
|
127
140
|
#
|
|
128
|
-
# @option [
|
|
141
|
+
# @option opts [Numeric] startup_wait_time
|
|
129
142
|
# Wait for a command to start
|
|
130
143
|
#
|
|
131
|
-
# @option [String] stop_signal
|
|
144
|
+
# @option opts [String] stop_signal
|
|
132
145
|
# Use signal to stop command
|
|
133
146
|
#
|
|
134
147
|
# @yield [SpawnProcess]
|
|
135
148
|
# Run block with process
|
|
136
149
|
#
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
def run_command(*args)
|
|
140
|
-
fail ArgumentError, 'Please pass at least a command as first argument.' if args.empty?
|
|
141
|
-
|
|
142
|
-
cmd = args.shift
|
|
143
|
-
|
|
144
|
-
if args.last.is_a? Hash
|
|
145
|
-
opts = args.pop
|
|
146
|
-
|
|
147
|
-
exit_timeout = opts[:exit_timeout].nil? ? aruba.config.exit_timeout : opts[:exit_timeout]
|
|
148
|
-
io_wait_timeout = opts[:io_wait_timeout].nil? ? aruba.config.io_wait_timeout : opts[:io_wait_timeout]
|
|
149
|
-
stop_signal = opts[:stop_signal].nil? ? aruba.config.stop_signal : opts[:stop_signal]
|
|
150
|
-
startup_wait_time = opts[:startup_wait_time].nil? ? aruba.config.startup_wait_time : opts[:startup_wait_time]
|
|
151
|
-
else
|
|
152
|
-
if args.size > 0
|
|
153
|
-
Aruba.platform.deprecated(
|
|
154
|
-
"Please pass options to `#run_command` as named parameters/hash and don\'t use the old style, e.g. `#run_command('cmd', :exit_timeout => 5)`.")
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
exit_timeout = args[0].nil? ? aruba.config.exit_timeout : args[0]
|
|
158
|
-
io_wait_timeout = args[1].nil? ? aruba.config.io_wait_timeout : args[1]
|
|
159
|
-
stop_signal = args[2].nil? ? aruba.config.stop_signal : args[2]
|
|
160
|
-
startup_wait_time = args[3].nil? ? aruba.config.startup_wait_time : args[3]
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
cmd = replace_variables(cmd)
|
|
164
|
-
|
|
165
|
-
@commands ||= []
|
|
166
|
-
@commands << cmd
|
|
167
|
-
|
|
168
|
-
environment = aruba.environment
|
|
169
|
-
working_directory = expand_path('.')
|
|
170
|
-
event_bus = aruba.event_bus
|
|
171
|
-
|
|
172
|
-
cmd = Aruba.platform.detect_ruby(cmd)
|
|
173
|
-
|
|
174
|
-
mode = if Aruba.process
|
|
175
|
-
# rubocop:disable Metrics/LineLength
|
|
176
|
-
Aruba.platform.deprecated('The use of "Aruba.process = <process>" and "Aruba.process.main_class" is deprecated. Use "Aruba.configure { |config| config.command_launcher = :in_process|:debug|:spawn }" and "Aruba.configure { |config| config.main_class = <klass> }" instead.')
|
|
177
|
-
# rubocop:enable Metrics/LineLength
|
|
178
|
-
Aruba.process
|
|
179
|
-
else
|
|
180
|
-
aruba.config.command_launcher
|
|
181
|
-
end
|
|
182
|
-
|
|
183
|
-
main_class = if Aruba.process.respond_to?(:main_class) && Aruba.process.main_class
|
|
184
|
-
# rubocop:disable Metrics/LineLength
|
|
185
|
-
Aruba.platform.deprecated('The use of "Aruba.process = <process>" and "Aruba.process.main_class" is deprecated. Use "Aruba.configure { |config| config.command_launcher = :in_process|:debug|:spawn }" and "Aruba.configure { |config| config.main_class = <klass> }" instead.')
|
|
186
|
-
# rubocop:enable Metrics/LineLength
|
|
187
|
-
Aruba.process.main_class
|
|
188
|
-
else
|
|
189
|
-
aruba.config.main_class
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
command = Command.new(
|
|
193
|
-
cmd,
|
|
194
|
-
:mode => mode,
|
|
195
|
-
:exit_timeout => exit_timeout,
|
|
196
|
-
:io_wait_timeout => io_wait_timeout,
|
|
197
|
-
:working_directory => working_directory,
|
|
198
|
-
:environment => environment.to_hash,
|
|
199
|
-
:main_class => main_class,
|
|
200
|
-
:stop_signal => stop_signal,
|
|
201
|
-
:startup_wait_time => startup_wait_time,
|
|
202
|
-
:event_bus => event_bus
|
|
203
|
-
)
|
|
150
|
+
def run_command(cmd, opts = {})
|
|
151
|
+
command = prepare_command(cmd, opts)
|
|
204
152
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
# rubocop:enable Metrics/LineLength
|
|
209
|
-
aruba.config.before(:cmd, self, cmd)
|
|
153
|
+
unless command.interactive?
|
|
154
|
+
raise NotImplementedError,
|
|
155
|
+
'Running interactively is not supported with this process launcher.'
|
|
210
156
|
end
|
|
211
157
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
command.start
|
|
215
|
-
|
|
216
|
-
aruba.announcer.announce(:stop_signal, command.pid, stop_signal) if stop_signal
|
|
217
|
-
|
|
218
|
-
aruba.config.after(:command, self, command)
|
|
158
|
+
start_command(command)
|
|
219
159
|
|
|
220
160
|
block_given? ? yield(command) : command
|
|
221
161
|
end
|
|
222
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
|
223
|
-
# rubocop:enable Metrics/MethodLength
|
|
224
162
|
|
|
225
163
|
# Run a command with aruba
|
|
226
164
|
#
|
|
@@ -233,70 +171,45 @@ module Aruba
|
|
|
233
171
|
# @param [Hash] options
|
|
234
172
|
# Options for aruba
|
|
235
173
|
#
|
|
236
|
-
# @option [
|
|
174
|
+
# @option options [Boolean] fail_on_error
|
|
237
175
|
# Should aruba fail on error?
|
|
238
176
|
#
|
|
239
|
-
# @option [
|
|
177
|
+
# @option options [Numeric] exit_timeout
|
|
240
178
|
# Timeout for execution
|
|
241
179
|
#
|
|
242
|
-
# @option [
|
|
180
|
+
# @option options [Numeric] io_wait_timeout
|
|
243
181
|
# Timeout for IO - STDERR, STDOUT
|
|
244
182
|
#
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
fail_on_error = opts.delete(:fail_on_error) == true ? true : false
|
|
255
|
-
else
|
|
256
|
-
if args.size > 0
|
|
257
|
-
# rubocop:disable Metrics/LineLength
|
|
258
|
-
Aruba.platform.deprecated("Please pass options to `#run_command_and_stop` as named parameters/hash and don\'t use the old style with positional parameters, NEW: e.g. `#run_command_and_stop('cmd', :exit_timeout => 5)`.")
|
|
259
|
-
# rubocop:enable Metrics/LineLength
|
|
260
|
-
end
|
|
261
|
-
|
|
262
|
-
fail_on_error = args[0] == false ? false : true
|
|
263
|
-
|
|
264
|
-
opts = {
|
|
265
|
-
:exit_timeout => (args[1] || aruba.config.exit_timeout),
|
|
266
|
-
:io_wait_timeout => (args[2] || aruba.config.io_wait_timeout),
|
|
267
|
-
:stop_signal => (args[3] || aruba.config.stop_signal),
|
|
268
|
-
:startup_wait_time => (args[4] || aruba.config.startup_wait_time)
|
|
269
|
-
}
|
|
270
|
-
end
|
|
271
|
-
|
|
272
|
-
command = run_command(cmd, opts)
|
|
183
|
+
def run_command_and_stop(cmd, opts = {})
|
|
184
|
+
fail_on_error = if opts.key?(:fail_on_error)
|
|
185
|
+
opts.delete(:fail_on_error) == true
|
|
186
|
+
else
|
|
187
|
+
true
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
command = prepare_command(cmd, opts)
|
|
191
|
+
start_command(command)
|
|
273
192
|
command.stop
|
|
274
193
|
|
|
275
|
-
|
|
276
|
-
@last_exit_status = command.exit_status
|
|
277
|
-
@timed_out = command.timed_out?
|
|
278
|
-
end
|
|
194
|
+
return unless fail_on_error
|
|
279
195
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
raise e
|
|
288
|
-
end
|
|
196
|
+
begin
|
|
197
|
+
expect(command).to have_finished_in_time
|
|
198
|
+
expect(command).to be_successfully_executed
|
|
199
|
+
rescue ::RSpec::Expectations::ExpectationNotMetError => e
|
|
200
|
+
aruba.announcer.activate(aruba.config.activate_announcer_on_command_failure)
|
|
201
|
+
aruba.event_bus.notify Events::CommandStopped.new(command)
|
|
202
|
+
raise e
|
|
289
203
|
end
|
|
290
204
|
end
|
|
291
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
|
292
|
-
# rubocop:enable Metrics/MethodLength
|
|
293
205
|
|
|
294
206
|
# Provide data to command via stdin
|
|
295
207
|
#
|
|
296
208
|
# @param [String] input
|
|
297
209
|
# The input for the command
|
|
298
210
|
def type(input)
|
|
299
|
-
return close_input if
|
|
211
|
+
return close_input if input == "\u0004"
|
|
212
|
+
|
|
300
213
|
last_command_started.write(input << "\n")
|
|
301
214
|
end
|
|
302
215
|
|
|
@@ -304,6 +217,59 @@ module Aruba
|
|
|
304
217
|
def close_input
|
|
305
218
|
last_command_started.close_io(:stdin)
|
|
306
219
|
end
|
|
220
|
+
|
|
221
|
+
private
|
|
222
|
+
|
|
223
|
+
# rubocop:disable Metrics/MethodLength
|
|
224
|
+
def prepare_command(cmd, opts)
|
|
225
|
+
exit_timeout = opts[:exit_timeout].nil? ? aruba.config.exit_timeout : opts[:exit_timeout]
|
|
226
|
+
io_wait_timeout = opts[:io_wait_timeout].nil? ? aruba.config.io_wait_timeout : opts[:io_wait_timeout]
|
|
227
|
+
stop_signal = opts[:stop_signal].nil? ? aruba.config.stop_signal : opts[:stop_signal]
|
|
228
|
+
startup_wait_time = opts[:startup_wait_time].nil? ? aruba.config.startup_wait_time : opts[:startup_wait_time]
|
|
229
|
+
|
|
230
|
+
cmd = replace_variables(cmd)
|
|
231
|
+
|
|
232
|
+
@commands ||= []
|
|
233
|
+
@commands << cmd
|
|
234
|
+
|
|
235
|
+
environment = aruba.environment
|
|
236
|
+
working_directory = expand_path('.')
|
|
237
|
+
event_bus = aruba.event_bus
|
|
238
|
+
|
|
239
|
+
cmd = Aruba.platform.detect_ruby(cmd)
|
|
240
|
+
|
|
241
|
+
mode = aruba.config.command_launcher
|
|
242
|
+
|
|
243
|
+
main_class = aruba.config.main_class
|
|
244
|
+
|
|
245
|
+
Command.new(
|
|
246
|
+
cmd,
|
|
247
|
+
mode: mode,
|
|
248
|
+
exit_timeout: exit_timeout,
|
|
249
|
+
io_wait_timeout: io_wait_timeout,
|
|
250
|
+
working_directory: working_directory,
|
|
251
|
+
environment: environment.to_hash,
|
|
252
|
+
main_class: main_class,
|
|
253
|
+
stop_signal: stop_signal,
|
|
254
|
+
startup_wait_time: startup_wait_time,
|
|
255
|
+
event_bus: event_bus
|
|
256
|
+
)
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
# rubocop:enable Metrics/MethodLength
|
|
260
|
+
|
|
261
|
+
def start_command(command)
|
|
262
|
+
aruba.config.before(:command, self, command)
|
|
263
|
+
|
|
264
|
+
in_current_directory do
|
|
265
|
+
command.start
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
stop_signal = command.stop_signal
|
|
269
|
+
aruba.announcer.announce(:stop_signal, command.pid, stop_signal) if stop_signal
|
|
270
|
+
|
|
271
|
+
aruba.config.after(:command, self, command)
|
|
272
|
+
end
|
|
307
273
|
end
|
|
308
274
|
end
|
|
309
275
|
end
|
data/lib/aruba/api/core.rb
CHANGED
|
@@ -3,8 +3,6 @@ require 'aruba/runtime'
|
|
|
3
3
|
require 'aruba/errors'
|
|
4
4
|
require 'aruba/setup'
|
|
5
5
|
|
|
6
|
-
require 'aruba/config/jruby'
|
|
7
|
-
|
|
8
6
|
# Aruba
|
|
9
7
|
module Aruba
|
|
10
8
|
# Api
|
|
@@ -17,6 +15,8 @@ module Aruba
|
|
|
17
15
|
|
|
18
16
|
# Aruba Runtime
|
|
19
17
|
def aruba
|
|
18
|
+
# TODO: Check this variable being accessed inconsistently. Should only be using the memo!
|
|
19
|
+
# Renaming this to `aruba` causes 100's of rspec failures. Needs a deeper dive, approach with caution!
|
|
20
20
|
@_aruba_runtime ||= Runtime.new
|
|
21
21
|
end
|
|
22
22
|
|
|
@@ -31,6 +31,15 @@ module Aruba
|
|
|
31
31
|
self
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
# Execute block in Aruba's current directory
|
|
35
|
+
#
|
|
36
|
+
# @yield
|
|
37
|
+
# The block which should be run in current directory
|
|
38
|
+
def in_current_directory(&block)
|
|
39
|
+
create_directory '.' unless directory?('.')
|
|
40
|
+
cd('.', &block)
|
|
41
|
+
end
|
|
42
|
+
|
|
34
43
|
# Switch to directory
|
|
35
44
|
#
|
|
36
45
|
# @param [String] dir
|
|
@@ -55,15 +64,16 @@ module Aruba
|
|
|
55
64
|
aruba.current_directory << dir
|
|
56
65
|
new_directory = expand_path('.')
|
|
57
66
|
|
|
58
|
-
aruba.event_bus.notify Events::ChangedWorkingDirectory.new(:
|
|
67
|
+
aruba.event_bus.notify Events::ChangedWorkingDirectory.new(old: old_directory, new: new_directory)
|
|
59
68
|
|
|
60
69
|
old_dir = Aruba.platform.getwd
|
|
61
70
|
|
|
62
|
-
|
|
71
|
+
real_new_directory = File.expand_path(aruba.current_directory, aruba.root_directory)
|
|
72
|
+
Aruba.platform.chdir real_new_directory
|
|
63
73
|
|
|
64
74
|
result = with_environment(
|
|
65
75
|
'OLDPWD' => old_dir,
|
|
66
|
-
'PWD' =>
|
|
76
|
+
'PWD' => real_new_directory,
|
|
67
77
|
&block
|
|
68
78
|
)
|
|
69
79
|
ensure
|
|
@@ -80,7 +90,7 @@ module Aruba
|
|
|
80
90
|
aruba.current_directory << dir
|
|
81
91
|
new_directory = expand_path('.')
|
|
82
92
|
|
|
83
|
-
aruba.event_bus.notify Events::ChangedWorkingDirectory.new(:
|
|
93
|
+
aruba.event_bus.notify Events::ChangedWorkingDirectory.new(old: old_directory, new: new_directory)
|
|
84
94
|
|
|
85
95
|
self
|
|
86
96
|
end
|
|
@@ -117,58 +127,66 @@ module Aruba
|
|
|
117
127
|
# # => <path>/test/fixtures/file
|
|
118
128
|
# expand_path('%/file')
|
|
119
129
|
#
|
|
130
|
+
# @example Absolute directory
|
|
131
|
+
#
|
|
132
|
+
# # => /foo/bar
|
|
133
|
+
# expand_path('/foo/bar')
|
|
134
|
+
#
|
|
120
135
|
# rubocop:disable Metrics/MethodLength
|
|
121
136
|
# rubocop:disable Metrics/CyclomaticComplexity
|
|
137
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
|
122
138
|
def expand_path(file_name, dir_string = nil)
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
# rubocop:disable Metrics/LineLength
|
|
139
|
+
# rubocop:disable Layout/LineLength
|
|
126
140
|
message = %(Filename "#{file_name}" needs to be a string. It cannot be nil or empty either. Please use `expand_path('.')` if you want the current directory to be expanded.)
|
|
127
|
-
# rubocop:enable
|
|
141
|
+
# rubocop:enable Layout/LineLength
|
|
128
142
|
|
|
129
143
|
fail ArgumentError, message unless file_name.is_a?(String) && !file_name.empty?
|
|
130
144
|
|
|
131
|
-
# rubocop:disable
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
nil
|
|
139
|
-
else
|
|
140
|
-
file_name.chars.to_a[2..-1].join
|
|
141
|
-
end
|
|
142
|
-
else
|
|
143
|
-
prefix = file_name[0]
|
|
144
|
-
rest = file_name[2..-1]
|
|
145
|
-
end
|
|
145
|
+
# rubocop:disable Layout/LineLength
|
|
146
|
+
fail %(Aruba's working directory does not exist. Maybe you forgot to run `setup_aruba` before using its API.) unless Aruba.platform.directory? File.join(aruba.config.root_directory, aruba.config.working_directory)
|
|
147
|
+
|
|
148
|
+
# rubocop:enable Layout/LineLength
|
|
149
|
+
|
|
150
|
+
prefix = file_name[0]
|
|
151
|
+
rest = file_name[2..-1]
|
|
146
152
|
|
|
147
153
|
if aruba.config.fixtures_path_prefix == prefix
|
|
148
154
|
path = File.join(*[aruba.fixtures_directory, rest].compact)
|
|
149
155
|
|
|
150
|
-
# rubocop:disable
|
|
156
|
+
# rubocop:disable Layout/LineLength
|
|
151
157
|
fail ArgumentError, %(Fixture "#{rest}" does not exist in fixtures directory "#{aruba.fixtures_directory}". This was the one we found first on your system from all possible candidates: #{aruba.config.fixtures_directories.map { |p| format('"%s"', p) }.join(', ')}.) unless Aruba.platform.exist? path
|
|
152
|
-
|
|
158
|
+
|
|
159
|
+
# rubocop:enable Layout/LineLength
|
|
153
160
|
|
|
154
161
|
path
|
|
155
|
-
elsif '~'
|
|
162
|
+
elsif prefix == '~'
|
|
156
163
|
path = with_environment do
|
|
157
|
-
|
|
164
|
+
File.expand_path(file_name)
|
|
158
165
|
end
|
|
159
166
|
|
|
160
|
-
fail ArgumentError, 'Expanding "~/" to "/" is not allowed' if path
|
|
161
|
-
fail ArgumentError, %(Expanding "~/" to a relative path "#{path}" is not allowed) unless
|
|
167
|
+
fail ArgumentError, 'Expanding "~/" to "/" is not allowed' if path == '/'
|
|
168
|
+
fail ArgumentError, %(Expanding "~/" to a relative path "#{path}" is not allowed) unless Aruba.platform.absolute_path? path
|
|
162
169
|
|
|
163
170
|
path.to_s
|
|
171
|
+
elsif absolute? file_name
|
|
172
|
+
unless aruba.config.allow_absolute_paths
|
|
173
|
+
caller_location = caller_locations(1, 1).first
|
|
174
|
+
caller_file_line = "#{caller_location.path}:#{caller_location.lineno}"
|
|
175
|
+
aruba.logger.warn "Aruba's `expand_path` method was called with an absolute path at #{caller_file_line}, which is not recommended." \
|
|
176
|
+
' Change the call to pass a relative path or set config.allow_absolute_paths = true to silence this warning'
|
|
177
|
+
end
|
|
178
|
+
file_name
|
|
164
179
|
else
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
180
|
+
with_environment do
|
|
181
|
+
directory = File.expand_path(aruba.current_directory, aruba.root_directory)
|
|
182
|
+
directory = File.expand_path(dir_string, directory) if dir_string
|
|
183
|
+
File.expand_path(file_name, directory)
|
|
184
|
+
end
|
|
168
185
|
end
|
|
169
186
|
end
|
|
170
187
|
# rubocop:enable Metrics/MethodLength
|
|
171
|
-
# rubocop:enable
|
|
188
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
|
189
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
|
172
190
|
|
|
173
191
|
# Run block with environment
|
|
174
192
|
#
|
|
@@ -178,14 +196,10 @@ module Aruba
|
|
|
178
196
|
# @yield
|
|
179
197
|
# The block of code which should be run with the changed environment variables
|
|
180
198
|
def with_environment(env = {}, &block)
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
ensure
|
|
186
|
-
# make sure the old environment is really restored in "aruba.environment"
|
|
187
|
-
aruba.environment.clear
|
|
188
|
-
aruba.environment.update old_aruba_env
|
|
199
|
+
aruba.environment.nest do |nested_env|
|
|
200
|
+
nested_env.update(env)
|
|
201
|
+
Aruba.platform.with_environment nested_env.to_h, &block
|
|
202
|
+
end
|
|
189
203
|
end
|
|
190
204
|
end
|
|
191
205
|
end
|