Skip to content

Commit

Permalink
Stop running processes before checking for directory presence
Browse files Browse the repository at this point in the history
  • Loading branch information
msassak committed Oct 16, 2010
1 parent 28bc53b commit 6e9dd3f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
4 changes: 1 addition & 3 deletions features/interactive.feature
Expand Up @@ -29,13 +29,11 @@ Feature: Interactive process control
7
"""

@wip
Scenario: Filesystem checks
Scenario: Stop processes before checking for filesystem changes
See: http://github.com/aslakhellesoy/aruba/issues#issue/17 for context

Given a directory named "rename_me"
When I run "mv rename_me renamed" interactively
And sleep 1
Then the following directories should exist:
| renamed |
And the following directories should not exist:
Expand Down
39 changes: 25 additions & 14 deletions lib/aruba/api.rb
Expand Up @@ -74,6 +74,8 @@ def check_exact_file_content(file, exact_content)
end

def check_directory_presence(paths, expect_presence)
stop_processes!

in_current_dir do
paths.each do |path|
if expect_presence
Expand Down Expand Up @@ -143,37 +145,46 @@ def install_gems(gemfile)
end
end

def run_simple(cmd, fail_on_error=true)
@last_exit_status = run(cmd) do |process|
announce_or_puts(process.stdout) if @announce_stdout
announce_or_puts(process.stderr) if @announce_stderr
process.stop
end

if(@last_exit_status != 0 && fail_on_error)
fail("Exit status was #{@last_exit_status}. Output:\n#{all_output}")
end
def processes
@processes ||= {}
end

def run_interactive(cmd)
@interactive = run(cmd)
def stop_processes!
processes.each do |_, process|
process.stop
end
end

def run(cmd)
cmd = detect_ruby(cmd)
@processes ||= {}

in_current_dir do
announce_or_puts("$ cd #{Dir.pwd}") if @announce_dir
announce_or_puts("$ #{cmd}") if @announce_cmd

process = @processes[cmd] = Process.new(cmd)
process = processes[cmd] = Process.new(cmd)
process.run!

block_given? ? yield(process) : process
end
end

def run_simple(cmd, fail_on_error=true)
@last_exit_status = run(cmd) do |process|
announce_or_puts(process.stdout) if @announce_stdout
announce_or_puts(process.stderr) if @announce_stderr
process.stop
end

if(@last_exit_status != 0 && fail_on_error)
fail("Exit status was #{@last_exit_status}. Output:\n#{all_output}")
end
end

def run_interactive(cmd)
@interactive = run(cmd)
end

def write_interactive(input)
@interactive.stdin.write(input)
end
Expand Down

0 comments on commit 6e9dd3f

Please sign in to comment.