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

Pin the path of execution to a particular trace #181

Open
aherrmann opened this Issue Feb 6, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@aherrmann
Copy link
Contributor

aherrmann commented Feb 6, 2018

While working on a dejafu test-case I thought of a feature that, I think, could be very useful to debug test failures:
Would it be possible to pin execution to one particular trace in a dejafu test?
I'm having a feature in mind similar to passing a seed to QuickCheck to replay a previous test.

Consider the following example.
Say, that a test fails on an alwaysSame predicate in a randomly run.
Dejafu will return a sample of different results and the corresponding traces.
If the tested code is complex and generates large traces, then it can be difficult to determine where it went wrong based on the traces alone.
Sometimes it might be easier to just "printf-debug" by inserting some calls to traceM.
However, when execution follows multiple traces at the same time,
then the debug output of those different traces will be interleaved,
which can make it very difficult to extract meaningful information out of it.
Being able to pin execution to only one particular trace would make this much easier.
In the case of a failure on alwaysSame, one could pick a trace that produced an unexpected result,
rerun the test with execution pinned to that trace, and start debugging.

@barrucadu

This comment has been minimized.

Copy link
Owner

barrucadu commented Feb 6, 2018

Thanks for the suggestion. You can do this already, with a little work:

replay :: (MonadConc n, MonadRef r n) => MemType -> Trace -> ConcT r n a -> n (Either Failure a, s, Trace)
replay = runConcurrent (Scheduler sched) where
  sched (Just (tid, _)) _ ((Continue, _, _):rest) = (Just tid, rest)
  sched _ _ ((Start    tid, _, _):rest) = (Just tid, rest)
  sched _ _ ((SwitchTo tid, _, _):rest) = (Just tid, rest)
  sched _ _ rest = (Nothing, rest)

Although I agree it would be better to have this in dejafu itself.

@aherrmann

This comment has been minimized.

Copy link
Contributor

aherrmann commented Feb 7, 2018

@barrucadu I was not aware that this is already possible. Thanks a lot for the explanation!

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