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

Aruba doesn't seem to be able to run commands that accept input using Unix input redirection #573

Open
luismadrigal opened this issue Sep 10, 2018 · 5 comments

Comments

@luismadrigal
Copy link

Summary

I am using Aruba and RSpec to test a CLI. The CLI accepts input files both as arguments and via STDIN.

The Aruba testing framework can perform the first command but does not seem to be able to do the second.

Expected Behavior

The expectation is that both commands should run successfully. I am not sure if this is a bug or an improvement. But I think that since it is a standard way of writing CLIs that the framework for testing them should support it.

All of these should be supported.

run("ruby myprog.rb input.csv")
run("ruby myprog.rb < input.csv")
run("cat input.csv | ruby myprog.rb")

Current Behavior

run("ruby myprog.rb input.csv")  # succeeds 
run("ruby myprog.rb < input.csv")  # fails

This is the error message that is being displayed.

got: "/Users/dev/Projects/Test/run.rb:54:in `each': No such file or directory @ rb_sysopen - < (Errno::ENOENT)

The expectation is that both commands should run successfully. I am not sure if this is a bug or if am suggesting an improvement.

Possible Solution

Steps to Reproduce (for bugs)

  1. Find a program that accepts input via STDIN ( perhaps more can work. )
  2. Run the command and pass the file as an argument in the command line. more input.csv
  3. Run the command use STDIN to provide the input in the command line. more < input.csv
  4. Create an Aruba/RSpec test to run the first command run( more input.csv)
  5. Create an Aruba/Rspec test to run the second coomand run(more < input.csv)

Context & Motivation

CLIs are supposed to conform to the POSIX standard and behavior and those are all standard behaviors for most command line apps.

Your Environment

  • Version used:
    aruba (0.14.6)
    rspec (3.8.0)

  • Operating System and version:
    MacOS (10.16.2)

  • Link to your project:
    N/A

@stale
Copy link

stale bot commented Nov 9, 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 Nov 9, 2018
@xtrasimplicity xtrasimplicity removed the stale These issues were closed by stalebot and need to be reviewed to see if they're still relevant. label Nov 10, 2018
@xtrasimplicity
Copy link
Member

@luismadrigal, Does it work if you use run("ruby myprog.rb <input.csv") instead? (Notice the lack of spacing between < and input.csv).

@xtrasimplicity xtrasimplicity changed the title Aruba doesn't seem to be able to run commands that accept input via STDIN Aruba doesn't seem to be able to run commands that accept input using Unix input redirection Nov 22, 2018
@stale
Copy link

stale bot commented Jan 22, 2019

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 22, 2019
@mvz mvz removed the stale These issues were closed by stalebot and need to be reviewed to see if they're still relevant. label Jan 27, 2019
@binaryape
Copy link

I've had problems similar to this:

When the tested executable checks for stdin, it freezes: it seems to find an open, empty pipe and hangs waiting for input.

After I added reading from stdin almost all tests broke. I worked around this by using an ENV variable to turn of reading from stdin for most tests.

Where I was testing pipes I continued to get errors until I wrapped the run command in a bash shell:

When I run bash -c "echo 'http://example.com/does_not_exist' | mdqt get"

These are ugly workarounds but without them nothing worked anymore.

@mvz
Copy link
Contributor

mvz commented Apr 12, 2022

In a way this is the correct workaround since Aruba does not emulate a full shell when running commands.

Some documentation should be added for this at least. I don't know if we can reliably detect attempts to add input redirection in the command and then warn or abort.

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

No branches or pull requests

4 participants