dangmoody / Temper

Single header-only testing framework written in C99.
MIT License
6 stars 1 forks source link

Minor threading functionality needed #5

Closed Mike430 closed 3 years ago

Mike430 commented 3 years ago

So this morning I added Aborts to the conditional checks as it's another thing I use ALOT and felt tantrum just wouldn't be complete without. After submitting it I realised what I'd writted just wasn't going to hold water especially if we start adding fixtures or anyone starts writing any helper functions for their tests.

Currently all the abort sequence does is call return. So if your test calls a function with an abort in it, the test doesn't stop.

The solution: Each test needs to run it's own thread. When an abort is triggered, the thread is terminated.

I found a simple solution I was going to implement but suddenly realised it was for linux and mac only - it was using the pthread library. I next went to MSDN and it turned into a very deep rabbit hole that requires discussion. We'll need to discuss this over a call further:

Threads for C https://docs.microsoft.com/en-us/cpp/parallel/sample-multithread-c-program?view=msvc-160

Creating and terminating in C++ https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createthread https://docs.microsoft.com/en-us/windows/win32/procthread/terminating-a-thread

dangmoody commented 3 years ago

Added for Windows in 92fcc2f4ae43789003d0602417c5ac545a585681. Added for Linux in 2d3d21ffc16192cacf42f1ff0b5fafba77be1e8c.