[erlang-questions] seq_trace token unexpectedly cleared by file:read_file
Vince Foley
vincefoley@REDACTED
Fri Mar 30 16:24:11 CEST 2018
Hi folks,
I'm experimenting with seq_trace which seems to be super powerful. However
I've run into a case where the token gets unexpectedly cleared out...
I ran into it using Elixir, when calling a module that isn't yet loaded in
a test. I tracked it down further and was able to reproduce it when simply
calling `file:read_file`. Same thing happens if the file exists or not.
Example:
```
-module(seq_fail).
-include_lib("eunit/include/eunit.hrl").
seq_fail_test() ->
seq_trace:set_token(label, 123),
?assertMatch({_, 123, _, _, _}, seq_trace:get_token()),
{error, enoent} = file:read_file('not_there'),
?assertMatch({_, 123, _, _, _}, seq_trace:get_token()).
```
Running the test fails the second match:
```
1) seq_fail:seq_fail_test/0: module 'seq_fail'
Failure/Error: ?assertMatch({ _ , 123 , _ , _ , _ }, seq_trace :
get_token ( ))
expected: = { _ , 123 , _ , _ , _ }
got: []
%% .../_build/test/lib/seq_fail/src/seq_fail.erl:9:in
`seq_fail:-seq_fail_test/0-fun-1-/0
```
I dug into the code for `file:read_file` and came across some interesting
things (like erlang:dt_spread_tag) but couldn't track it any further...
Anyone have ideas?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180330/e87c7b85/attachment.htm>
More information about the erlang-questions
mailing list