GithubHelp home page GithubHelp logo

Capture output until about narwhal HOT 5 CLOSED

vberlier avatar vberlier commented on May 28, 2024
Capture output until

from narwhal.

Comments (5)

vberlier avatar vberlier commented on May 28, 2024

Hmm I guess it would be possible but then you would still need some sort of timeout. Otherwise if the thread never outputs the required substring the test would hang indefinitely. The best solution would be to join the thread before exiting the CAPTURE_OUTPUT block.

from narwhal.

eerimoq avatar eerimoq commented on May 28, 2024

At the moment the thread runs indefinitely, so I was curious if I could test it unmodified. Adding logic to end it when the input is closed and use join is possible of course.

A timeout would certainly be needed. =)

from narwhal.

vberlier avatar vberlier commented on May 28, 2024

I'm thinking about adding something like this:

ASSERT_OUTPUT("OK!") {
    // ...
}

This would combine CAPTURE_OUTPUT and ASSERT_SUBSTRING. This version would be synchronous but specifying a timeout as a second argument would make it wait up to the desired amount of time before failing.

ASSERT_OUTPUT("OK!", 50000) {
    // ...
}

The issue is that the test could still fail depending on what the CPU is doing so I'm not sure if it's an actual improvement. The difference here is that the test would succeed as soon as the specified substring gets captured.

from narwhal.

eerimoq avatar eerimoq commented on May 28, 2024

I agree, timeouts are generally not recommended as they are not reliable. I think I'll make my thread end gracefully eventually, and I'll use the sleep for now.

Good idea to check the substring automatically. Though, sometimes, the user want to check for an exact match.

from narwhal.

vberlier avatar vberlier commented on May 28, 2024

Yeah I don't see a way of making things significantly better. And having access to the output as a variable is more flexible anyway. I'll think about it and maybe reopen this if I come up with a better solution :/

from narwhal.

Related Issues (9)

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.