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

(Failing feature) - Directory manipulation inside an interactive process #17

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
3 participants
@rspeicher
Contributor

rspeicher commented Oct 3, 2010

I was attempting to use aruba to test an application I'm working on which needs interactive input and also does some filesystem manipulation, including directory renaming.

After running the app interactively, providing it input through "Then I type ..." and then checking that a directory exists and another one doesn't, I got a failing feature even after verifying their existence/non-existence with ruby-debug.

I've added a failing feature in this branch which demonstrates the behavior.

[failing_feature][~/Code/ruby/aruba] cucumber features/interactive.feature
Feature: Interactive process control
  In order to test interactive command line applications
  As a developer using Cucumber
  I want to use the interactive session steps

  Scenario: Running ruby interactively      # features/interactive.feature:7
    Given a file named "echo.rb" with:      # lib/aruba/cucumber.rb:66
      """
      while res = gets.chomp
        break if res == "quit"
        puts res.reverse
      end
      """
    When I run "ruby echo.rb" interactively # lib/aruba/cucumber.rb:98
    And I type "hello, world"               # lib/aruba/cucumber.rb:102
    And I type "quit"                       # lib/aruba/cucumber.rb:102
    Then the output should contain:         # lib/aruba/cucumber.rb:114
      """
      dlrow ,olleh
      """

  Scenario: Running a native binary interactively # features/interactive.feature:23
    When I run "bc -q" interactively              # lib/aruba/cucumber.rb:98
    And I type "4 + 3"                            # lib/aruba/cucumber.rb:102
    And I type "quit"                             # lib/aruba/cucumber.rb:102
    Then the output should contain:               # lib/aruba/cucumber.rb:114
      """
      7
      """

  Scenario: Directory manipulation in an interactive process # features/interactive.feature:32
    Given a directory named "rename_me"                      # lib/aruba/cucumber.rb:62
    When I run "mv rename_me renamed" interactively          # lib/aruba/cucumber.rb:98
    Then the following directories should exist:             # lib/aruba/cucumber.rb:187
      | renamed |
      expected directory?("renamed") to return true, got false (RSpec::Expectations::ExpectationNotMetError)
      ./features/support/../../lib/aruba/api.rb:79:in `check_directory_presence'
      ./features/support/../../lib/aruba/api.rb:77:in `each'
      ./features/support/../../lib/aruba/api.rb:77:in `check_directory_presence'
      ./features/support/../../lib/aruba/api.rb:9:in `chdir'
      ./features/support/../../lib/aruba/api.rb:9:in `in_current_dir'
      ./features/support/../../lib/aruba/api.rb:76:in `check_directory_presence'
      ./features/support/../../lib/aruba/cucumber.rb:188:in `/^the following directories should exist:$/'
      features/interactive.feature:35:in `Then the following directories should exist:'
    And the following directories should not exist:          # lib/aruba/cucumber.rb:191
      | rename_me |

Failing Scenarios:
cucumber features/interactive.feature:32 # Scenario: Directory manipulation in an interactive process

3 scenarios (1 failed, 2 passed)
13 steps (1 failed, 1 skipped, 11 passed)
0m0.085s
[failing_feature][~/Code/ruby/aruba] ruby -e "puts File.directory? 'tmp/aruba/renamed'"
true
[failing_feature][~/Code/ruby/aruba] ruby -e "puts File.directory? 'tmp/aruba/rename_me'"
false
@msassak

This comment has been minimized.

Show comment
Hide comment
@msassak

msassak Oct 6, 2010

Member

Thanks for the failing feature! The problem is that interactive processes take a bit longer to finish than the normal simple ones, and the Then step is being executed before the OS call to manipulate the directory structure is finished. The OS call is definitely finished, however, by the time the test completes, which is why it seems to be acting crazy and claiming something that clearly does exist does not.

For a quick hack you can add a step like "When sleep" that sleeps for a half second or so before the Then step. That should allow the interactive step to finish. Otherwise this should be fixed pretty soon.

Member

msassak commented Oct 6, 2010

Thanks for the failing feature! The problem is that interactive processes take a bit longer to finish than the normal simple ones, and the Then step is being executed before the OS call to manipulate the directory structure is finished. The OS call is definitely finished, however, by the time the test completes, which is why it seems to be acting crazy and claiming something that clearly does exist does not.

For a quick hack you can add a step like "When sleep" that sleeps for a half second or so before the Then step. That should allow the interactive step to finish. Otherwise this should be fixed pretty soon.

@rspeicher

This comment has been minimized.

Show comment
Hide comment
@rspeicher

rspeicher Oct 6, 2010

Contributor

Ah ha. Thank you for clearing that up!

Contributor

rspeicher commented Oct 6, 2010

Ah ha. Thank you for clearing that up!

@aslakhellesoy

This comment has been minimized.

Show comment
Hide comment
@aslakhellesoy

aslakhellesoy Nov 13, 2010

Update scenario with newer steps. Closed by 6f168de.

aslakhellesoy commented Nov 13, 2010

Update scenario with newer steps. Closed by 6f168de.

dchelimsky pushed a commit that referenced this pull request Apr 17, 2011

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment