Skip to content

Commit

Permalink
add cucumber/aruba-based automated tests
Browse files Browse the repository at this point in the history
They are meant to match more or less the tutorial scripts. The main
difference is probably going to be UI.
  • Loading branch information
doudou committed Feb 19, 2018
1 parent 6e39253 commit 0d60e2d
Show file tree
Hide file tree
Showing 8 changed files with 213 additions and 2 deletions.
1 change: 1 addition & 0 deletions .config/cucumber.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
default: --fail-fast
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@
data/tree.yml

draft/

vendor/
tmp/
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
45 changes: 43 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
GIT
remote: git://github.com/doudou/middleman-navtree.git
remote: https://github.com/doudou/middleman-navtree
revision: e0c283445f864732d66d78903321b4b880e0fdec
specs:
middleman-navtree (0.1.11)
i18n (~> 0.7.0)
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:
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -166,7 +205,9 @@ PLATFORMS
ruby

DEPENDENCIES
aruba!
bootstrap-sass
cucumber
html-proofer
middleman (>= 4.0.0)
middleman-gh-pages
Expand All @@ -180,4 +221,4 @@ DEPENDENCIES
wdm (~> 0.1.0)

BUNDLED WITH
1.15.1
1.16.0
50 changes: 50 additions & 0 deletions features/01 - Basics/01 - Installation.feature
Original file line number Diff line number Diff line change
@@ -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"

35 changes: 35 additions & 0 deletions features/01 - Basics/02 - Getting Started.feature
Original file line number Diff line number Diff line change
@@ -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

75 changes: 75 additions & 0 deletions features/step_definitions/aruba_interactive_script.rb
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions features/support/aruba.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require 'aruba/cucumber'

0 comments on commit 0d60e2d

Please sign in to comment.