From e1691b682b1d5cf6426ed6a0773707295893d2fd Mon Sep 17 00:00:00 2001 From: Jonathan del Strother Date: Fri, 6 Nov 2020 19:03:01 +0000 Subject: [PATCH] Fix "When I run interactively" Aruba changed its process management which made this harder: https://github.com/cucumber/aruba/issues/432 --- features/command_init.feature | 9 ++-- features/shell_functions.feature | 49 ++++++++++----------- features/shell_wrappers.feature | 51 ++++++++++------------ features/step_definitions/scmpuff_steps.rb | 9 ++++ 4 files changed, 59 insertions(+), 59 deletions(-) diff --git a/features/command_init.feature b/features/command_init.feature index f12e024..72544a2 100644 --- a/features/command_init.feature +++ b/features/command_init.feature @@ -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 `` 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 : + | eval "$(scmpuff init -s)" | + | type scmpuff_status | + | type scmpuff_clear_vars | Then the output should not contain "not found" Examples: | shell | diff --git a/features/shell_functions.feature b/features/shell_functions.feature index fb71e8f..ae18c10 100644 --- a/features/shell_functions.feature +++ b/features/shell_functions.feature @@ -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 `` interactively - And I type `eval "$(scmpuff init -ws)"` - And I type "scmpuff_status" - And I type "exit $?" + When I run the following in : + | eval "$(scmpuff init -ws)" | + | scmpuff_status | + | exit $? | Then the exit status should be 128 And the output should contain: """ @@ -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 `` interactively - And I type `eval "$(scmpuff init -ws)"` - And I type "scmpuff_status" - And I type "exit $?" + When I run the following in : + | 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: @@ -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 `` 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 : + | 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$/ @@ -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 `` 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 : + | 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$/ @@ -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 `` 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 : + | 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:$/ diff --git a/features/shell_wrappers.feature b/features/shell_wrappers.feature index 4030adc..592a8ef 100644 --- a/features/shell_wrappers.feature +++ b/features/shell_wrappers.feature @@ -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 `` 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 : + | eval "$(scmpuff init -ws)" | + | scmpuff_status | + | git add 1 | + | exit | Then the output should contain: """ # On branch: master | [*] => $e* @@ -36,11 +36,10 @@ 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 `` 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 : + | 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: @@ -48,7 +47,6 @@ Feature: optional wrapping of normal git cmds in the 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 ?? @@ -56,12 +54,11 @@ Feature: optional wrapping of normal git cmds in the shell 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 `` 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 : + | 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: @@ -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 `` 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 : + | 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: @@ -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 `` 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 : + | 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: """ diff --git a/features/step_definitions/scmpuff_steps.rb b/features/step_definitions/scmpuff_steps.rb index 1c1b187..186c188 100644 --- a/features/step_definitions/scmpuff_steps.rb +++ b/features/step_definitions/scmpuff_steps.rb @@ -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: #