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

Prevent duplicating stderr/stdout for run_simple commands #374

Closed
e2 opened this issue Apr 6, 2016 · 10 comments · Fixed by #517
Closed

Prevent duplicating stderr/stdout for run_simple commands #374

e2 opened this issue Apr 6, 2016 · 10 comments · Fixed by #517

Comments

@e2
Copy link
Contributor

e2 commented Apr 6, 2016

Summary

When stderr+stdout announcing is enabled for run_simple in RSpec, both announcements are duplicated.

E.g. if a cli command outputs "hello world" in STDOUT, you'll see:

<<-STDOUT
hello world
STDOUT

<<-STDOUT
hello world
STDOUT

Expected Behavior

If the command is only run once, it should print each stderr/stdout announcement only once.

Current Behavior

Currently, the stop() call in run_simple() sends the notifications to announce the process's stderr+stdout. Then, stop_all_commands does the same.

Possible Solution

The sanest "workaround" for now is: just temporarily disable announcing during the stop in run_simple. Since the output is gathered when the process ends anyway, this isn't a problem.

I implemented this in my own fork here:

e2@c540485

Ideally, there should be a way to "consume" stderr/stdout during announcements. And ideally there would be a "streaming" of stderr/stdout live while the app is running.

Steps to Reproduce (for bugs)

  1. Aruba + RSpec
  2. Activate announcing for stdout
  3. run_simple with a simple 'hello world' script
  4. You'll have the announcement appear twice (once for stop inside run_simple, and once for stop_all_commands when the test is done)

Context

I want to see the output of commands - and it's annoying to get errors showing up multiple times on the screen. Especially annoying is having two sets of stdout+stderr. No to mention it's very confusing. (At first I though somehow the test ran twice).

Your Environment

Project without cucumber (RSpec only, standard setup with aruba init --test-framework=rspec).

@maxmeyer
Copy link
Member

maxmeyer commented Apr 6, 2016

I see. Good that you find the reason. Let me think about that one. Maybe we should an option to silently stop a command. WDYT?

@e2
Copy link
Contributor Author

e2 commented Apr 7, 2016

No, I don't think that would be useful. Users don't know that the output is announced during stop. It's too low level to know about it.

Just think of Ruby's backticks syntax to execute and capture output - it's simple and understandable with no options. There's no "double output" or silencing option. The same with popen and open3 - the fact that commands are stopped and streams are closed are almost invisible to the user.

What should happen instead is: Aruba should provide aggregated and partial output at all times. E.g. "announce-aggregated-stdout" would be the equivalent of what it does not. For short-running "run_simple" commands, you only want the aggregate anyway. (at least until Aruba supports live/real-time output in the future output).

E.g. The docker-api gem allows capturing and streaming out live output.

So this is a decent fix until then.

@maxmeyer maxmeyer added this to the 1.0.0 milestone May 7, 2016
ghost pushed a commit that referenced this issue May 9, 2016
If a users decided to use `run_simple`, a command is stopped twice:

1. After the configured wait time
2. On the end of test suite via terminate_all_commands

This makes the output appear twice. This is fixed by this PR. It also
make a method call fail:

1. Command already stopped, `#stop` is called again
2. Comannd has not been started, but ist `#stop`ped
ghost pushed a commit that referenced this issue May 9, 2016
If a users decided to use `run_simple`, a command is stopped twice:

1. After the configured wait time
2. On the end of test suite via terminate_all_commands

This makes the output appear twice. This is fixed by this PR. It also
make a method call fail:

1. Command already stopped, `#stop` is called again
2. Comannd has not been started, but ist `#stop`ped
ghost pushed a commit that referenced this issue May 9, 2016
If a users decided to use `run_simple`, a command is stopped twice:

1. After the configured wait time
2. On the end of test suite via terminate_all_commands

This makes the output appear twice. This is fixed by this PR. It also
make a method call fail:

1. Command already stopped, `#stop` is called again
2. Comannd has not been started, but ist `#stop`ped
@ghost ghost mentioned this issue May 9, 2016
6 tasks
ghost pushed a commit that referenced this issue Jun 17, 2016
If a users decided to use `run_simple`, a command is stopped twice:

1. After the configured wait time
2. On the end of test suite via terminate_all_commands

This makes the output appear twice. This is fixed by this PR. It also
make a method call fail:

1. Command already stopped, `#stop` is called again
2. Comannd has not been started, but ist `#stop`ped
@jrab89
Copy link

jrab89 commented Aug 24, 2016

I've noticed this too. For example, when running echo.feature:

Feature: echo

  @announce-stdout
  Scenario: With 'something' as input
    When I successfully run `echo something`
    Then the output should contain "something"

I get this:

$ cucumber features/echo.feature
Feature: echo

<<-STDOUT
something

STDOUT

<<-STDOUT
something

STDOUT

<<-STDOUT
something

STDOUT

  @announce-stdout
  Scenario: With 'something' as input          # features/echo.feature:4
    When I successfully run `echo something`   # aruba-0.14.1/lib/aruba/cucumber/command.rb:27
<<-STDOUT
something

STDOUT

    Then the output should contain "something" # aruba-0.14.1/lib/aruba/cucumber/command.rb:159
<<-STDOUT
something

STDOUT

<<-STDOUT
something

STDOUT


1 scenario (1 passed)
2 steps (2 passed)
0m0.121s

aruba 0.14.1
cucumber 2.4.0
rspec 3.5.2

@ghost
Copy link

ghost commented Aug 29, 2016

Hi @jrab89 can you try to use the branch still and see if it's fixed by fff944b. I backported a fix from master. If your answer is yes, I'm going to release 0.14.3 with this fix.

@jrab89
Copy link

jrab89 commented Sep 20, 2016

Using aruba from the still branch I'm getting

$ cucumber features/echo.feature                                                                                                                                                     
Feature: echo

<<-STDOUT
something

STDOUT

<<-STDOUT
something

STDOUT

<<-STDOUT
something

STDOUT

  @announce-stdout
  Scenario: With 'something' as input          # features/echo.feature:4
    When I successfully run `echo something`   # aruba-0.14.2/lib/aruba/cucumber/command.rb:27
<<-STDOUT
something

STDOUT

    Then the output should contain "something" # aruba-0.14.2/lib/aruba/cucumber/command.rb:159

1 scenario (1 passed)
2 steps (2 passed)
0m0.119s

@stale
Copy link

stale bot commented Nov 9, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week if no further activity occurs.

@stale stale bot added the stale These issues were closed by stalebot and need to be reviewed to see if they're still relevant. label Nov 9, 2017
@stale
Copy link

stale bot commented Nov 16, 2017

This issue has been automatically closed because of inactivity. You can support the Cucumber core team on opencollective.

@stale stale bot closed this as completed Nov 16, 2017
@mvz mvz reopened this Nov 22, 2017
@stale stale bot removed the stale These issues were closed by stalebot and need to be reviewed to see if they're still relevant. label Nov 22, 2017
@mvz
Copy link
Contributor

mvz commented Nov 22, 2017

This was fixed in the stale branch, but is potentially still a problem in master.

mvz pushed a commit that referenced this issue Nov 22, 2017
If a users decided to use `run_simple`, a command is stopped twice:

1. After the configured wait time
2. On the end of test suite via terminate_all_commands

This makes the output appear twice. This is fixed by this PR. It also
make a method call fail:

1. Command already stopped, `#stop` is called again
2. Comannd has not been started, but ist `#stop`ped
@mvz mvz mentioned this issue Nov 22, 2017
2 tasks
@stale
Copy link

stale bot commented Jan 21, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week if no further activity occurs.

@stale stale bot added the stale These issues were closed by stalebot and need to be reviewed to see if they're still relevant. label Jan 21, 2018
@mvz
Copy link
Contributor

mvz commented Jan 21, 2018

Waiting for #517...

@stale stale bot removed the stale These issues were closed by stalebot and need to be reviewed to see if they're still relevant. label Jan 21, 2018
mvz pushed a commit that referenced this issue Feb 2, 2018
If a users decided to use `run_simple`, a command is stopped twice:

1. After the configured wait time
2. On the end of test suite via terminate_all_commands

This makes the output appear twice. This is fixed by this PR. It also
make a method call fail:

1. Command already stopped, `#stop` is called again
2. Comannd has not been started, but ist `#stop`ped
mvz pushed a commit that referenced this issue Feb 3, 2018
If a users decided to use `run_simple`, a command is stopped twice:

1. After the configured wait time
2. On the end of test suite via terminate_all_commands

This makes the output appear twice. This is fixed by this PR. It also
make a method call fail:

1. Command already stopped, `#stop` is called again
2. Comannd has not been started, but ist `#stop`ped
mvz pushed a commit that referenced this issue Feb 3, 2018
If a users decided to use `run_simple`, a command is stopped twice:

1. After the configured wait time
2. On the end of test suite via terminate_all_commands

This makes the output appear twice. This is fixed by this PR. It also
make a method call fail:

1. Command already stopped, `#stop` is called again
2. Comannd has not been started, but ist `#stop`ped
mvz pushed a commit that referenced this issue Feb 4, 2018
If a users decided to use `run_simple`, a command is stopped twice:

1. After the configured wait time
2. On the end of test suite via terminate_all_commands

This makes the output appear twice. This is fixed by this PR. It also
make a method call fail:

1. Command already stopped, `#stop` is called again
2. Comannd has not been started, but ist `#stop`ped
@mvz mvz closed this as completed in #517 Feb 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants