-
Notifications
You must be signed in to change notification settings - Fork 41
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
Expose concuerror_loader:load_binary/3 #301
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #301 +/- ##
==========================================
- Coverage 95.74% 2.67% -93.08%
==========================================
Files 12 12
Lines 3668 3661 -7
==========================================
- Hits 3512 98 -3414
- Misses 156 3563 +3407
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #301 +/- ##
==========================================
- Coverage 95.74% 95.69% -0.06%
==========================================
Files 12 12
Lines 3668 3670 +2
==========================================
Hits 3512 3512
- Misses 156 158 +2
Continue to review full report at Codecov.
|
This will allow to provide hack for implementing support for ExUnit tests which are composed of dynamically generated modules (see parapluu#299).
04c196d
to
ba178bf
Compare
IMO, this PR is really bad. For starters, its diff is unnecessarily big (there is very little reason to move functions around). Second, and more important, it does not make sense on its own. It should instead be part of a PR that implements what #299 wants to do. If that is not implemented, for whatever reason, there is no point to add and expose the `load_binary/3' function as far as Concuerror is concerned. |
@kostis, I prefer to accept the PR sooner, rather than wait until 'everything is done'. I also disagree that it is 'really bad'. Moving the few lines of code makes sense for grouping the exported functions a bit better. However, I agree that we should document internally (not officially) why this function is exposed, and cover it with a test, along the lines of what it is used for so far, but maybe without using Elixir. Such a test can be created using https://github.com/parapluu/Concuerror/blob/5bf0fed/tests-real/suites/options/other-tests#L46 (-L54) as a template. @hauleth, it would be great if you gave it a shot. Otherwise I'll try to find some time to do it before the end of this week. |
@kostis the reason to move functions around is that in original source code the functions with the same name were grouped together and separated from the private functions. So to keep that layout I needed to move functions a little. About "making sense" on its own - the #299 is blocked on ERL-805 and it doesn't seem that it will be resolved any time soon, so the only possible solution right now is to "hack around" by instrumenting BEAM code directly, wich this function allows (using original example): %% Define module in memory
Module = erl_syntax:attribute(erl_syntax:atom(module),[erl_syntax:atom(sample)]).
ModForm = erl_syntax:revert(Module).
Export = erl_syntax:attribute(erl_syntax:atom(export),[erl_syntax:list([erl_syntax:arity_qualifier(erl_syntax:atom(test),erl_syntax:integer(0))])]).
ExportForm = erl_syntax:revert(Export).
% define the function body
Body = erl_syntax:atom(nil).
% define the first clause
Clause = erl_syntax:clause([],[],[Body]).
% define the function
Function = erl_syntax:function(erl_syntax:atom(test),[Clause]).
FunctionForm = erl_syntax:revert(Function).
{ok, Mod, Bin1} = compile:forms([ModForm,ExportForm, FunctionForm]).
code:load_binary(Mod, [], Bin1).
%% Now run concuerror on it
concuerror_loader:load_binary(Mod, '', Bin1).
concuerror:run([{module, sample}]). Will work. This will allow me to create Elixir wrapper for tests without blockers. So I would say, that this provides requested solution for #299 using current BEAM tools available. |
Actually, I think that we can fix #299 by adding a |
Summary
This will allow to provide hack for implementing support for ExUnit
tests which are composed of dynamically generated modules (see #299).
Checklist