Skip to content

Commit

Permalink
Auto add -f for -m that have .erl
Browse files Browse the repository at this point in the history
Closes #130.
  • Loading branch information
aronisstav committed Feb 17, 2017
1 parent f683588 commit a5846ce
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/concuerror_options.erl
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ finalize_2(Options) ->
[ fun proplists:unfold/1
, fun set_verbosity/1
, fun add_to_path/1
, fun add_missing_file/1
, fun load_files/1
, fun add_options_from_module/1
, fun add_derived_defaults/1
Expand Down Expand Up @@ -506,6 +507,31 @@ add_to_path(Options) ->

%%%-----------------------------------------------------------------------------

add_missing_file(Options) ->
case proplists:get_all_values(module, Options) of
[Module] ->
try
_ = Module:module_info(attributes),
Options
catch
_:_ ->
case proplists:get_all_values(file, Options) of
[] ->
Source = atom_to_list(Module) ++ ".erl",
Msg = "Automatically added '--file ~s'.",
opt_info(Msg, [Source]),
case filelib:is_file(Source) of
true -> [{file, Source}|Options];
false -> Options
end;
_ -> Options
end
end;
_ -> Options
end.

%%%-----------------------------------------------------------------------------

load_files(Options) ->
case proplists:get_all_values(file, Options) of
[] -> Options;
Expand Down
4 changes: 4 additions & 0 deletions tests-real/suites/options/other-tests
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ ln -s $(which $CONCUERROR) concuerror
rm -rf concuerror
good

testing "Limited automatic compilation with -m"
$CONCUERROR -m foo 2> $Console
good

trap - 0

echo -e "\e[1;32mSUCCESS!\e[0m"

0 comments on commit a5846ce

Please sign in to comment.