Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

More reliable check_spec'ing for Cover-compiled modules. #54

Merged
merged 1 commit into from

2 participants

@jhlywa

check_spec indirectly used code:which/0 to load the BEAM of a targeted
module. If the module was compiled with {cover_enabled, true}, proper
failed to load the BEAM and resorted to recompiling the module with a
hardcode list of compilation options. If the targeted module depended
on any additional flags (such as include dirs), the compilation failed
and check_spec returned an error.

This fix uses code:get_object_code/1 (instead of code:which/1) to
retrieve the BEAM for a given module, sidestepping the need to
recompile any Cover-compiled modules.

@jhlywa jhlywa Cover-compiled modules are now more reliably check_spec'ed
check_spec indirectly used code:which/0 to load the BEAM of a targeted
module.   If the module was compiled with {cover_enabled, true}, proper
failed to load the BEAM and resorted to recompiling the module with a
hardcode list of compilation options.  If the targeted module depended
on any additional flags (such as include dirs), the compilation failed
and check_spec returned an error.

This fix uses code:get_object_code/1 (instead of code:which/1) to
retrieve the BEAM for a given module, sidestepping the need to
recompile any Cover-compiled modules.
b9db143
@kostis
Collaborator

Thanks for this pull request. It can of course be merged as is but, since this is exactly the kind of code that may easily break by accident as there is nothing that exercises it and it's not so common that users have cover-compiled modules, we would appreciate if you can include a small test together with the patch.

The (unit) tests of PropEr are normally run with

make tests

at the top dir. Let us know.

@kostis
Collaborator

Ping.

Are you working on an appropriate test for this, or should we merge this pull request as is?

@jhlywa

Sorry for the delay. I've been working on a few check_spec tests and should have something for you soon.

@kostis
Collaborator

Hi @jhlywa

It seems that you are even more swamped than we are... Can we expect the tests for this issue sometime soon?

Kostis

@kostis kostis was assigned
@kostis kostis merged commit a5bd59a into from
@kostis
Collaborator

I've merged the pull request, because I think it's an improvement, but I still do not like it that we have no tests for this. If you find some time, tests would be appreciated. Otherwise, this functionality runs the risk of being accidentally broken in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 27, 2012
  1. @jhlywa

    Cover-compiled modules are now more reliably check_spec'ed

    jhlywa authored
    check_spec indirectly used code:which/0 to load the BEAM of a targeted
    module.   If the module was compiled with {cover_enabled, true}, proper
    failed to load the BEAM and resorted to recompiling the module with a
    hardcode list of compilation options.  If the targeted module depended
    on any additional flags (such as include dirs), the compilation failed
    and check_spec returned an error.
    
    This fix uses code:get_object_code/1 (instead of code:which/1) to
    retrieve the BEAM for a given module, sidestepping the need to
    recompile any Cover-compiled modules.
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 4 deletions.
  1. +4 −4 src/proper_typeserver.erl
View
8 src/proper_typeserver.erl
@@ -606,15 +606,15 @@ get_exp_info(Mod) ->
-spec get_code_and_exports(mod_name()) ->
rich_result2([abs_form()],mod_exp_funs()).
get_code_and_exports(Mod) ->
- case code:which(Mod) of
- ObjFileName when is_list(ObjFileName) ->
- case get_chunks(ObjFileName) of
+ case code:get_object_code(Mod) of
+ {Mod, ObjBin, _ObjFileName} ->
+ case get_chunks(ObjBin) of
{ok,_AbsCode,_ModExpFuns} = Result ->
Result;
{error,Reason} ->
get_code_and_exports_from_source(Mod, Reason)
end;
- _ErrAtom when is_atom(_ErrAtom) ->
+ error ->
get_code_and_exports_from_source(Mod, cant_find_object_file)
end.
Something went wrong with that request. Please try again.