Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs in features/aruba #452

Merged
merged 8 commits into from
Jul 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions features/02_configure_aruba/root_directory.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,3 @@ Feature: Use root directory of aruba
"""
tmp/aruba
"""

Scenario: Modify value
Given a file named "features/support/aruba_config.rb" with:
"""
Aruba.configure do |config|
config.root_directory = '/tmp/'
end
"""
Then I successfully run `cucumber`
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Feature: Getting started with Cucumber and aruba
Given a file named "features/support/env.rb" with:
"""
require 'aruba/api'
require 'aruba/cucumber/file'
World(Aruba::Api)

Before do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,34 +417,6 @@ Feature: All output of commands which were executed
When I run `cucumber`
Then the features should all pass

Scenario: Detect output from all processes (deprecated)
Given an executable named "bin/aruba-test-cli1" with:
"""bash
#!/usr/bin/env bash

echo 'This is cli1'
"""
And an executable named "bin/aruba-test-cli2" with:
"""bash
#!/usr/bin/env bash

echo 'This is cli2'
"""
And a file named "features/output.feature" with:
"""cucumber
Feature: Run command
Scenario: Run command
When I run `aruba-test-cli1`
When I run `aruba-test-cli2`
Then the stdout should contain exactly:
\"\"\"
This is cli1
This is cli2
\"\"\"
"""
When I run `cucumber`
Then the features should all pass

Scenario: Handle little output
Given an executable named "bin/aruba-test-cli" with:
"""bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,6 @@ Feature: STDERR of commands which were executed
When I run `cucumber`
Then the features should all pass

Scenario: Detect stderr from all processes (deprecated)
Given a file named "features/output.feature" with:
"""
Feature: Run command
Scenario: Run command
When I run `bash -c 'printf "hello world!\n" >&2'`
And I run `bash -c 'cat >&2 '` interactively
And I type "hola"
And I type ""
Then the stderr should contain:
\"\"\"
hello world!
hola
\"\"\"
And the stdout should not contain anything
"""
When I run `cucumber`
Then the features should all pass

Scenario: Detect stderr from named source
Given a file named "features/output.feature" with:
"""
Expand Down
15 changes: 1 addition & 14 deletions features/04_aruba_api/core/expand_path.feature
Original file line number Diff line number Diff line change
Expand Up @@ -56,30 +56,17 @@ Feature: Expand paths with aruba

Scenario: Use ~ in path

Now this useses the HOME-variable from your normal shell HOME-variable.
From 1.0.0 on HOME will be `File.join(aruba.config.root_directory,
Aruba sets HOME to `File.join(aruba.config.root_directory,
aruba.config.working_directory)`. If you want HOME have some other value,
you need to configure it explicitly via `Aruba.configure {}`.

Given a file named "spec/expand_path_spec.rb" with:
"""ruby
require 'spec_helper'

# Old before 1.0.0
RSpec.describe 'Expand path', :type => :aruba do
let(:path) { '~/path/to/dir' }

it { expect(expand_path(path)).to match %r</home/[^/]+/path/to/dir> }
end

# New from 1.0.0
RSpec.describe 'Expand path', :type => :aruba do
let(:path) { '~/path/to/dir' }

before(:each) do
set_environment_variable('HOME', File.join(aruba.config.root_directory, aruba.config.working_directory))
end

it { expect(expand_path(path)).to eq File.join(aruba.config.root_directory, aruba.config.working_directory, 'path/to/dir') }
end
"""
Expand Down
84 changes: 42 additions & 42 deletions features/04_aruba_api/text/sanitize_text.feature
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Feature: Sanitize text from output
before(:each) { run_command('aruba-test-cli') }
before(:each) { stop_all_commands }

it { expect(sanitize_text(last_command_started.output)).to eq "texttext" }
it { expect(sanitize_text(last_command_started.output)).to eq "texttext" }
end
"""
When I run `rspec`
Expand All @@ -121,7 +121,7 @@ Feature: Sanitize text from output
before(:each) { run_command('aruba-test-cli') }
before(:each) { stop_all_commands }

it { expect(sanitize_text(last_command_started.output)).to eq "texttext" }
it { expect(sanitize_text(last_command_started.output)).to eq "texttext" }
end
"""
When I run `rspec`
Expand Down Expand Up @@ -167,6 +167,46 @@ Feature: Sanitize text from output
When I run `rspec`
Then the specs should all pass

Scenario: Output contains \017, but removable is disabled by configuration
Given an executable named "bin/aruba-test-cli" with:
"""
#!/bin/bash
echo -n 'text\017text'
"""
And a file named "spec/sanitize_spec.rb" with:
"""
require 'spec_helper'

RSpec.describe 'Run command', :type => :aruba, :remove_ansi_escape_sequences => false, :keep_ansi => true do
before(:each) { run_command('aruba-test-cli') }
before(:each) { stop_all_commands }

it { expect(sanitize_text(last_command_started.output)).to eq "texttext" }
end
"""
When I run `rspec`
Then the specs should all pass

Scenario: Output contains \016, but removable is disabled by configuration
Given an executable named "bin/aruba-test-cli" with:
"""
#!/bin/bash
echo -n 'text\016text'
"""
And a file named "spec/sanitize_spec.rb" with:
"""
require 'spec_helper'

RSpec.describe 'Run command', :type => :aruba, :remove_ansi_escape_sequences => false, :keep_ansi => true do
before(:each) { run_command('aruba-test-cli') }
before(:each) { stop_all_commands }

it { expect(sanitize_text(last_command_started.output)).to eq "texttext" }
end
"""
When I run `rspec`
Then the specs should all pass

Scenario: Output contains ansi escape codes prefixed by \e, but removable is disabled by configuration
Given an executable named "bin/aruba-test-cli" with:
"""
Expand All @@ -186,43 +226,3 @@ Feature: Sanitize text from output
"""
When I run `rspec`
Then the specs should all pass

# Scenario: Output contains ansi escape code \016
# Given an executable named "bin/aruba-test-cli" with:
# """
# #!/bin/bash
# echo -n "\016Text"
# """
# And a file named "spec/sanitize_spec.rb" with:
# """
# require 'spec_helper'
#
# RSpec.describe 'Run command', :type => :aruba do
# before(:each) { run_command('aruba-test-cli') }
# before(:each) { stop_all_commands }
#
# it { expect(sanitize_text(last_command_started.output)).to eq "Text" }
# end
# """
# When I run `rspec`
# Then the specs should all pass

# Scenario: Output contains ansi escape code \017
# Given an executable named "bin/aruba-test-cli" with:
# """
# #!/bin/bash
# echo -n "\017Text"
# """
# And a file named "spec/sanitize_spec.rb" with:
# """
# require 'spec_helper'
#
# RSpec.describe 'Run command', :type => :aruba do
# before(:each) { run_command('aruba-test-cli') }
# before(:each) { stop_all_commands }
#
# it { expect(sanitize_text(last_command_started.output)).to eq "Text" }
# end
# """
# When I run `rspec`
# Then the specs should all pass
2 changes: 1 addition & 1 deletion features/04_aruba_api/text/unescape_text.feature
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Feature: Unescape special characters in text
require 'spec_helper'

RSpec.describe 'Run command', :type => :aruba do
before(:each) { run_command(aruba-test-'cli') }
before(:each) { run_command('aruba-test-cli') }
before(:each) { stop_all_commands }

it { expect(unescape_text(last_command.output)).to eq "text\"text" }
Expand Down
6 changes: 1 addition & 5 deletions lib/aruba/api/text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ def unescape_text(text)
# @param [#to_s] text
# Input
def extract_text(text)
if Aruba::VERSION < '1'
text.gsub(/(?:\e|\033)\[\d+(?>(;\d+)*)m/, '')
else
text.gsub(/(?:\e|\033)\[\d+(?>(;\d+)*)m/, '').gsub(/\\\[|\\\]/, '').gsub(/\007|\016|\017/, '')
end
text.gsub(/(?:\e|\033)\[\d+(?>(;\d+)*)m/, '').gsub(/\\\[|\\\]/, '').gsub(/\007|\016|\017/, '')
end

# Unescape special characters and remove ANSI characters
Expand Down
6 changes: 1 addition & 5 deletions lib/aruba/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ module Aruba
#
# This defines the configuration options of aruba
class Configuration < BasicConfiguration
if Aruba::VERSION >= '1.0.0'
option_reader :root_directory, :contract => { None => String }, :default => Dir.getwd
else
option_accessor :root_directory, :contract => { String => String }, :default => Dir.getwd
end
option_reader :root_directory, :contract => { None => String }, :default => Dir.getwd

option_accessor :working_directory, :contract => { Aruba::Contracts::RelativePath => Aruba::Contracts::RelativePath }, :default => 'tmp/aruba'

Expand Down
2 changes: 1 addition & 1 deletion lib/aruba/platforms/command_monitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def last_command_started=(cmd)
@last_command_started = find(cmd)
end

# Set last command started
# Set last command stopped
#
# @param [String] cmd
# The commandline of the command
Expand Down