Skip to content

Commit

Permalink
Fix "When I run <shell> interactively"
Browse files Browse the repository at this point in the history
Aruba changed its process management which made this harder:
cucumber/aruba#432
  • Loading branch information
jdelStrother committed Nov 6, 2020
1 parent db8664c commit e1691b6
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 59 deletions.
9 changes: 4 additions & 5 deletions features/command_init.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ Feature: init command
| -s --wrap=false | should not |

Scenario Outline: Evaling init -s defines status shortcuts in environment
When I run `<shell>` interactively
And I type `eval "$(scmpuff init -s)"`
And I type "type scmpuff_status"
And I type "type scmpuff_clear_vars"
And I type "exit"
When I run the following in <shell>:
| eval "$(scmpuff init -s)" |
| type scmpuff_status |
| type scmpuff_clear_vars |
Then the output should not contain "not found"
Examples:
| shell |
Expand Down
49 changes: 23 additions & 26 deletions features/shell_functions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ Feature: scmpuff_status function
propogated to the user and not swallowed by the shell function, and that
non-zero exit codes from the underlying process are preserved.

When I run `<shell>` interactively
And I type `eval "$(scmpuff init -ws)"`
And I type "scmpuff_status"
And I type "exit $?"
When I run the following in <shell>:
| eval "$(scmpuff init -ws)" |
| scmpuff_status |
| exit $? |
Then the exit status should be 128
And the output should contain:
"""
Expand All @@ -32,10 +32,10 @@ Feature: scmpuff_status function

Scenario Outline: Basic functionality works with shell wrapper.
Given I am in a git repository
When I run `<shell>` interactively
And I type `eval "$(scmpuff init -ws)"`
And I type "scmpuff_status"
And I type "exit $?"
When I run the following in <shell>:
| eval "$(scmpuff init -ws)" |
| scmpuff_status |
| exit $? |
Then the exit status should be 0
And the output should contain "No changes (working directory clean)"
Examples:
Expand All @@ -46,11 +46,10 @@ Feature: scmpuff_status function
Scenario Outline: Sets proper environment variables in shell
Given I am in a complex working tree status matching scm_breeze tests
And the scmpuff environment variables have been cleared
When I run `<shell>` interactively
And I type `eval "$(scmpuff init -s)"`
And I type "scmpuff_status"
And I type `echo -e "e1:$e1\ne2:$e2\ne3:$e3\ne4:$e4\ne5:$e5\n"`
And I type "exit"
When I run the following in <shell>:
| eval "$(scmpuff init -s)" |
| scmpuff_status |
| echo -e "e1:$e1\ne2:$e2\ne3:$e3\ne4:$e4\ne5:$e5\n" |
Then the output should match /^e1:.*new_file$/
And the output should match /^e2:.*deleted_file$/
And the output should match /^e3:.*new_file$/
Expand All @@ -66,11 +65,10 @@ Feature: scmpuff_status function
And an empty file named "aa bb"
And an empty file named "bb|cc"
And an empty file named "cc*dd"
When I run `<shell>` interactively
And I type `eval "$(scmpuff init -s)"`
And I type "scmpuff_status"
And I type `echo -e "e1:$e1\ne2:$e2\ne3:$e3\ne4:$e4\n"`
And I type "exit"
When I run the following in <shell>:
| eval "$(scmpuff init -s)" |
| scmpuff_status |
| echo -e "e1:$e1\ne2:$e2\ne3:$e3\ne4:$e4\n" |
Then the output should match /^e1:.*aa bb$/
And the output should match /^e2:.*bb\|cc$/
And the output should match /^e3:.*cc\*dd$/
Expand All @@ -83,14 +81,13 @@ Feature: scmpuff_status function
Scenario Outline: Clears extra environment variables from before
Given I am in a complex working tree status matching scm_breeze tests
And the scmpuff environment variables have been cleared
When I run `<shell>` interactively
And I type `eval "$(scmpuff init -s)"`
And I type "scmpuff_status"
And I type "git add new_file"
And I type "git commit -m 'so be it'"
And I type "scmpuff_status"
And I type `echo -e "e1:$e1\ne2:$e2\ne3:$e3\ne4:$e4\ne5:$e5\n"`
And I type "exit"
When I run the following in <shell>:
| eval "$(scmpuff init -s)" |
| scmpuff_status |
| git add new_file |
| git commit -m 'so be it' |
| scmpuff_status |
| echo -e "e1:$e1\ne2:$e2\ne3:$e3\ne4:$e4\ne5:$e5\n" |
Then the output should match /^e1:.*deleted_file$/
And the output should match /^e2:.*untracked_file$/
And the output should match /^e3:$/
Expand Down
51 changes: 23 additions & 28 deletions features/shell_wrappers.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ Feature: optional wrapping of normal git cmds in the shell
Given I am in a git repository
And a 4 byte file named "foo.bar"
And a 4 byte file named "bar.foo"
When I run `<shell>` interactively
And I type `eval "$(scmpuff init -ws)"`
And I type "scmpuff_status"
And I type "git add 1"
And I type "exit"
When I run the following in <shell>:
| eval "$(scmpuff init -ws)" |
| scmpuff_status |
| git add 1 |
| exit |
Then the output should contain:
"""
# On branch: master | [*] => $e*
Expand All @@ -36,32 +36,29 @@ Feature: optional wrapping of normal git cmds in the shell
Scenario Outline: Wrapped `git add` can handle files with spaces properly
Given I am in a git repository
And an empty file named "file with spaces.txt"
When I run `<shell>` interactively
And I type `eval "$(scmpuff init -ws)"`
And I type "scmpuff_status"
And I type "git add 1"
And I type "exit"
When I run the following in <shell>:
| eval "$(scmpuff init -ws)" |
| scmpuff_status |
| git add 1 |
Then the exit status should be 0
And the output should match /new file:\s+\[1\] file with spaces.txt/
Examples:
| shell |
| bash |
| zsh |


Scenario Outline: Wrapped `git reset` can handle files with spaces properly
This is different and more complex because `git status --porcelain` puts it
inside quotes for the case where it is already added (but doesnt in the ??
case surprisingly), and also it expands using --relative.

Given I am in a git repository
And an empty file named "file with spaces.txt"
And I successfully run `git add "file with spaces.txt"`
When I run `<shell>` interactively
And I type `eval "$(scmpuff init -ws)"`
And I type "scmpuff_status"
And I type "git reset 1"
And I type "exit"
And I successfully run `git add "file with spaces.txt"`
When I run the following in <shell>:
| eval "$(scmpuff init -ws)" |
| scmpuff_status |
| git reset 1 |
Then the exit status should be 0
When I run `scmpuff status`
Then the stdout from "scmpuff status" should contain:
Expand All @@ -82,11 +79,10 @@ Feature: optional wrapping of normal git cmds in the shell
And I successfully run `git commit -m "initial commit"`
And a 4 byte file named "foo.bar"
And I successfully run `git add foo.bar`
When I run `<shell>` interactively
And I type `eval "$(scmpuff init -ws)"`
And I type "scmpuff_status"
And I type "git restore --staged 1"
And I type "exit"
When I run the following in <shell>:
| eval "$(scmpuff init -ws)" |
| scmpuff_status |
| git restore --staged 1 |
Then the exit status should be 0
When I run `scmpuff status`
Then the stdout from "scmpuff status" should contain:
Expand All @@ -105,12 +101,11 @@ Feature: optional wrapping of normal git cmds in the shell
And an empty file named "file with spaces.txt"
And an empty file named "file2.txt"
And an empty file named "untracked file.txt"
When I run `<shell>` interactively
And I type `eval "$(scmpuff init -ws)"`
And I type "scmpuff_status"
And I type `FILE="file with spaces.txt"`
And I type `git add "$FILE" 2`
And I type "exit"
When I run the following in <shell>:
| eval "$(scmpuff init -ws)" |
| scmpuff_status |
| FILE="file with spaces.txt" |
| git add "$FILE" 2 |
Then the exit status should be 0
And the output should contain:
"""
Expand Down
9 changes: 9 additions & 0 deletions features/step_definitions/scmpuff_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@
type(cmd)
end

When(/^I run the following in (.+):$/) do |shell, list|
step "I run `#{shell}` interactively"
list.raw.each do |item|
type(item.first)
end
type "exit"
last_command_started.wait
end

#
# Make table/list versions of common Aruba functions:
#
Expand Down

0 comments on commit e1691b6

Please sign in to comment.