diff --git a/.config/cucumber.yml b/.config/cucumber.yml new file mode 100644 index 0000000..58d864a --- /dev/null +++ b/.config/cucumber.yml @@ -0,0 +1 @@ +default: --fail-fast diff --git a/.gitignore b/.gitignore index e31b666..84e56d5 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,6 @@ data/tree.yml draft/ + +vendor/ +tmp/ diff --git a/Gemfile b/Gemfile index ae1dc72..d3496a6 100644 --- a/Gemfile +++ b/Gemfile @@ -24,3 +24,8 @@ gem 'mini_racer' gem 'html-proofer' gem 'middleman-navtree', git: 'https://github.com/doudou/middleman-navtree' + +group :features do + gem 'cucumber' + gem 'aruba', git: 'https://github.com/thirteenltda/aruba', branch: 'still' +end diff --git a/Gemfile.lock b/Gemfile.lock index 0814877..2e418b5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,5 +1,5 @@ GIT - remote: git://github.com/doudou/middleman-navtree.git + remote: https://github.com/doudou/middleman-navtree revision: e0c283445f864732d66d78903321b4b880e0fdec specs: middleman-navtree (0.1.11) @@ -7,6 +7,19 @@ GIT middleman-core (>= 3.3) titleize (~> 1.3) +GIT + remote: https://github.com/thirteenltda/aruba + revision: d517facb5f89115d3f6e7157126bc4c60de78c7c + branch: still + specs: + aruba (0.14.3) + childprocess (~> 0.8.0) + contracts (~> 0.9) + cucumber (>= 1.3.19) + ffi (~> 1.9.10) + rspec-expectations (>= 2.99) + thor (~> 0.19) + GEM remote: https://rubygems.org/ specs: @@ -23,6 +36,9 @@ GEM bootstrap-sass (3.3.7) autoprefixer-rails (>= 5.2.1) sass (>= 3.3.4) + builder (3.2.3) + childprocess (0.8.0) + ffi (~> 1.0, >= 1.0.11) chunky_png (1.3.8) coffee-script (2.4.1) coffee-script-source @@ -43,6 +59,23 @@ GEM sass (>= 3.2, < 3.5) concurrent-ruby (1.0.5) contracts (0.13.0) + cucumber (3.1.0) + builder (>= 2.1.2) + cucumber-core (~> 3.1.0) + cucumber-expressions (~> 5.0.4) + cucumber-wire (~> 0.0.1) + diff-lcs (~> 1.3) + gherkin (~> 5.0) + multi_json (>= 1.7.5, < 2.0) + multi_test (>= 0.1.2) + cucumber-core (3.1.0) + backports (>= 3.8.0) + cucumber-tag_expressions (~> 1.1.0) + gherkin (>= 5.0.0) + cucumber-expressions (5.0.7) + cucumber-tag_expressions (1.1.1) + cucumber-wire (0.0.1) + diff-lcs (1.3) dotenv (2.2.1) em-websocket (0.5.1) eventmachine (>= 0.12.9) @@ -55,6 +88,7 @@ GEM fast_blank (1.0.0) fastimage (2.1.0) ffi (1.9.18) + gherkin (5.0.0) haml (5.0.1) temple (>= 0.8.0) tilt @@ -126,6 +160,7 @@ GEM libv8 (~> 5.3) minitest (5.10.2) multi_json (1.12.1) + multi_test (0.1.2) nokogiri (1.8.0) mini_portile2 (~> 2.2.0) padrino-helpers (0.13.3.4) @@ -144,6 +179,10 @@ GEM rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) rouge (2.1.1) + rspec-expectations (3.7.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.7.0) + rspec-support (3.7.0) sass (3.4.25) servolux (0.13.0) susy (1.0.9) @@ -166,7 +205,9 @@ PLATFORMS ruby DEPENDENCIES + aruba! bootstrap-sass + cucumber html-proofer middleman (>= 4.0.0) middleman-gh-pages @@ -180,4 +221,4 @@ DEPENDENCIES wdm (~> 0.1.0) BUNDLED WITH - 1.15.1 + 1.16.0 diff --git a/features/01 - Basics/01 - Installation.feature b/features/01 - Basics/01 - Installation.feature new file mode 100644 index 0000000..dd1d8ea --- /dev/null +++ b/features/01 - Basics/01 - Installation.feature @@ -0,0 +1,50 @@ +Feature: Installation + @disable-bundler + Scenario: Bootstrapping + # High timeout, we're building and installing stuff + Given the aruba exit timeout is 3600 seconds + # High timeout because of variability due to network access + Given the default answer timeout is 3600 seconds + + When I run the following script: + """bash + mkdir dev + cd dev + """ + When I cd to "dev" + And I run the following script: + """bash + wget http://rock-robotics.org/autoproj_bootstrap + """ + Then the following files should exist: + | autoproj_bootstrap | + + When I run the following script interactively: + """bash + ruby autoproj_bootstrap git \ + https://github.com/rock-gazebo/buildconf + """ + And I answer "" to "Which prepackaged software" + And I answer "" to "The current directory is not empty, continue bootstrapping anyway ?" + When I stop the command started last + Then the exit status should be 0 + Then the output should contain "successfully" + + When I run the following script interactively: + """bash + set -e + echo $PWD + source env.sh + aup --all -k + amake --all -k + """ + And I answer "" to "How should I interact with gitorious.org" + And I answer "" to "How should I interact with github.com" + And I answer "" to "whether C++11 should be enabled" + And I answer "" to "Do you need compatibility with OCL ?" + And I answer "" to "the target operating system for Orocos/RTT" + And I answer "" to "which CORBA implementation should the RTT use ?" + When I stop the command started last + Then the exit status should be 0 + Then the output should contain "Command finished successfully" + diff --git a/features/01 - Basics/02 - Getting Started.feature b/features/01 - Basics/02 - Getting Started.feature new file mode 100644 index 0000000..8dc723c --- /dev/null +++ b/features/01 - Basics/02 - Getting Started.feature @@ -0,0 +1,35 @@ +Feature: Getting Started + @disable-bundler + @no-clobber + Scenario: Creating the bundle + Given I cd to "dev" + And I successfully run the following script: + """bash + set -e + source env.sh + acd + cd bundles + syskit init syskit_basics + cd syskit_basics + """ + + When I cd to "bundles/syskit_basics" + And I run the following script in background: + """bash + set -e + source ../../env.sh + syskit run + """ + Then stdout gets "ready" within 5 seconds + + When I successfully run the following script: + """bash + set -e + source ../../env.sh + syskit quit + """ + Then the output should contain "closed communication" + + When I stop the command started last + Then the exit status should be 0 + diff --git a/features/step_definitions/aruba_interactive_script.rb b/features/step_definitions/aruba_interactive_script.rb new file mode 100644 index 0000000..f8af1cb --- /dev/null +++ b/features/step_definitions/aruba_interactive_script.rb @@ -0,0 +1,75 @@ +default_answer_timeout = 5 + +When(/^I run the following (?:commands|script)(?: (?:with|in) `([^`]+)`)? in background:$/) do |shell, commands| + prepend_environment_variable('PATH', expand_path('bin') + File::PATH_SEPARATOR) + + Aruba.platform.mkdir(expand_path('bin')) + shell ||= Aruba.platform.default_shell + + Aruba::ScriptFile.new(:interpreter => shell, :content => commands, + :path => expand_path('bin/myscript')).call + step 'I run `myscript` in background' +end + +When(/^I run the following (?:commands|script)(?: (?:with|in) `([^`]+)`)? interactively:$/) do |shell, commands| + prepend_environment_variable('PATH', expand_path('bin') + File::PATH_SEPARATOR) + + Aruba.platform.mkdir(expand_path('bin')) + shell ||= Aruba.platform.default_shell + + Aruba::ScriptFile.new(:interpreter => shell, :content => commands, + :path => expand_path('bin/myscript')).call + step 'I run `myscript` interactively' +end + +When(/^I successfully run the following (?:commands|script)(?: (?:with|in) `([^`]+)`)?:$/) do |shell, commands| + prepend_environment_variable('PATH', expand_path('bin') + File::PATH_SEPARATOR) + + Aruba.platform.mkdir(expand_path('bin')) + shell ||= Aruba.platform.default_shell + + Aruba::ScriptFile.new(:interpreter => shell, :content => commands, + :path => expand_path('bin/myscript')).call + step "I successfully run `myscript` for up to #{aruba.config.exit_timeout} seconds" +end + +When(/^I answer "([^"]*)" to "([^"]+)"(?: from (\w+))?$/) do |answer, question, channel| + step "I wait for #{channel || 'stdout'} to have \"#{question}\"" + step "I type \"#{answer}\"" +end + +When(/^the default answer timeout is (\d+) seconds$/) do |timeout| + default_answer_timeout = Integer(timeout) +end + +When(/^I wait for (stdout|stderr) to have "([^"]+)"(?: within (\d+) seconds)?$/) do |channel, pattern_string, timeout| + commands = all_commands + if !timeout || timeout == 0 + timeout = default_answer_timeout + end + deadline = Time.now + Integer(timeout) + pattern = Regexp.new(Regexp.quote(pattern_string)) + puts "#{pattern} #{timeout}" + while true + combined_output = commands.map do |c| + c.send(channel.to_sym, wait_for_io: 0).chomp + end.join("\n") + if combined_output =~ pattern + break + elsif commands.all? { |c| c.stopped? } + puts "ALL STOPPED #{commands.map { |c| c.to_s }}" + step "stdout should contain \"#{pattern_string}\"" + elsif Time.now > deadline + raise "timed out (#{timeout} seconds) while waiting for #{combined_output} to contain #{pattern_string}" + end + sleep 0.1 + end +end + +When(/^(stdout|stderr) gets "([^"]+)"(?: within (\d+) seconds)?$/) do |channel, pattern_string, timeout| + if !timeout || timeout == 0 + step "I wait for #{channel} to have \"#{pattern_string}\"" + else + step "I wait for #{channel} to have \"#{pattern_string}\" within #{timeout} seconds" + end +end diff --git a/features/support/aruba.rb b/features/support/aruba.rb new file mode 100644 index 0000000..fb0a661 --- /dev/null +++ b/features/support/aruba.rb @@ -0,0 +1 @@ +require 'aruba/cucumber'