GithubHelp home page GithubHelp logo

Unable to test TTY behavior about assert_cmd HOT 5 OPEN

snshn avatar snshn commented on August 11, 2024
Unable to test TTY behavior

from assert_cmd.

Comments (5)

snshn avatar snshn commented on August 11, 2024 1

Just tried it, seems to be leading to the same behavior as without it, just slightly different verbose output. I think there needs to be a switch somewhere that toggles on "this should run exactly as when the user runs it in their terminal". The current default behavior is correct, since in theory, tests do run not directly in the terminal, but in their own environment (cargo, in this case). I just need to test things and let cargo know to make the program think it's inside of a TTY when it comes to STDOUT.

from assert_cmd.

epage avatar epage commented on August 11, 2024 1

We always capture stdout/stderr so we can run assertions on them. We'd need to add support for something like portable_ptr to do this.

Overall, I'd recommend providing a flag / env variable to give users control over this behavior. At that point, its only a question of whether the auto-detection works or not.

from assert_cmd.

epage avatar epage commented on August 11, 2024 1

Check out https://doc.rust-lang.org/std/process/struct.Command.html#method.env

from assert_cmd.

smoelius avatar smoelius commented on August 11, 2024

Just a thought: maybe --nocapture would make a difference(?).

from assert_cmd.

snshn avatar snshn commented on August 11, 2024

You're probably right on the money about the software being tested that must be responsible for being able to behave a certain way, not the testing framework. I will look at wget, curl, and other popular tools to see what format they use for ENV variables (naming is important for things like that sometimes, wouldn't want to make it too weird). Meanwhile, could you please hint at how to provide ENV variables to my CLI tool via assert_cmd, is it just .arg() put before the tool's name, or it has kind of cross-platform wrapper for it, or it should be put in front of cargo test? Thank you...

from assert_cmd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.