seq_trace token unexpectedly cleared by file:read_file

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

seq_trace token unexpectedly cleared by file:read_file

Vince Foley
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?



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions