Comments (5)
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.
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.
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.
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from narwhal.