Skip to content
Permalink
Browse files
Isolate backup *.coverdata from other beam instances
If multiple beam instances are launched in parallel with the same current
working directory, it is possible for the backup cover data from one
instance to be squashed and deleted by other instances. By adding the OS
pid of beam.smp itself to the filename, we avoid this potential issue.
  • Loading branch information
dcsommer authored and eproxus committed Nov 6, 2018
1 parent ef435a7 commit e63865c16e72cce11dea3ff86895c1197cbec9c3
Showing 1 changed file with 5 additions and 4 deletions.
@@ -39,12 +39,13 @@ rename_module(File, Name) ->
ok.

%% @doc Dump cover data for `Mod' into a .coverdata file in the current
%% directory. Return the absolute file name.
%% directory. Return the absolute path to the backup file.
dump_coverdata(Mod) ->
{ok, CWD} = file:get_cwd(),
File = filename:join(CWD, atom_to_list(Mod) ++ ".coverdata"),
ok = cover:export(File, Mod),
File.
File = lists:concat([Mod, ".", os:getpid(), ".coverdata"]),
Path = filename:join(CWD, File),
ok = cover:export(Path, Mod),
Path.

%%=============================================================================
%% Internal functions

0 comments on commit e63865c

Please sign in to comment.