Browse Source

Merge pull request #619 from tsloughter/app_find

only look for top level apps and those directly under apps/ or lib/
pull/567/merge
Fred Hebert 9 years ago
parent
commit
0a4b43f678
8 changed files with 40 additions and 48 deletions
  1. +1
    -1
      src/rebar.hrl
  2. +2
    -10
      src/rebar_app_discover.erl
  3. +4
    -4
      test/rebar_compile_SUITE.erl
  4. +2
    -2
      test/rebar_deps_SUITE.erl
  5. +2
    -2
      test/rebar_dialyzer_SUITE.erl
  6. +19
    -19
      test/rebar_eunit_SUITE.erl
  7. +6
    -6
      test/rebar_src_dirs_SUITE.erl
  8. +4
    -4
      test/rebar_test_utils.erl

+ 1
- 1
src/rebar.hrl View File

@ -15,7 +15,7 @@
-define(DEFAULT_BASE_DIR, "_build").
-define(DEFAULT_ROOT_DIR, ".").
-define(DEFAULT_PROJECT_APP_DIRS, ["apps", "lib", "."]).
-define(DEFAULT_PROJECT_APP_DIRS, ["apps/*", "lib/*", "."]).
-define(DEFAULT_CHECKOUTS_DIR, "_checkouts").
-define(DEFAULT_DEPS_DIR, "lib").
-define(DEFAULT_PLUGINS_DIR, "plugins").

+ 2
- 10
src/rebar_app_discover.erl View File

@ -94,25 +94,17 @@ all_app_dirs(LibDirs) ->
app_dirs(LibDir) ->
Path1 = filename:join([LibDir,
"*",
"src",
"*.app.src"]),
Path2 = filename:join([LibDir,
"src",
"*.app.src"]),
Path3 = filename:join([LibDir,
"*",
"ebin",
"*.app"]),
Path4 = filename:join([LibDir,
Path2 = filename:join([LibDir,
"ebin",
"*.app"]),
lists:usort(lists:foldl(fun(Path, Acc) ->
Files = filelib:wildcard(ec_cnv:to_list(Path)),
[app_dir(File) || File <- Files] ++ Acc
end, [], [Path1, Path2, Path3, Path4])).
end, [], [Path1, Path2])).
find_unbuilt_apps(LibDirs) ->
find_apps(LibDirs, invalid).

+ 4
- 4
test/rebar_compile_SUITE.erl View File

@ -65,10 +65,10 @@ build_release_apps(Config) ->
Name1 = rebar_test_utils:create_random_name("relapp1_"),
Vsn1 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_app(filename:join([AppDir,Name1]), Name1, Vsn1, [kernel, stdlib]),
rebar_test_utils:create_app(filename:join([AppDir,"apps",Name1]), Name1, Vsn1, [kernel, stdlib]),
Name2 = rebar_test_utils:create_random_name("relapp2_"),
Vsn2 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_app(filename:join([AppDir,Name2]), Name2, Vsn2, [kernel, stdlib]),
rebar_test_utils:create_app(filename:join([AppDir,"apps",Name2]), Name2, Vsn2, [kernel, stdlib]),
rebar_test_utils:run_and_check(
Config, [], ["compile"],
@ -80,7 +80,7 @@ build_checkout_apps(Config) ->
CheckoutsDir = ?config(checkouts, Config),
Name1 = rebar_test_utils:create_random_name("checkapp1_"),
Vsn1 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_app(filename:join([AppDir,Name1]), Name1, Vsn1, [kernel, stdlib]),
rebar_test_utils:create_app(AppDir, Name1, Vsn1, [kernel, stdlib]),
Name2 = rebar_test_utils:create_random_name("checkapp2_"),
Vsn2 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_app(filename:join([CheckoutsDir,Name2]), Name2, Vsn2, [kernel, stdlib]),
@ -96,7 +96,7 @@ build_checkout_deps(Config) ->
DepsDir = filename:join([AppDir, "_build", "default", "lib"]),
Name1 = rebar_test_utils:create_random_name("checkapp1_"),
Vsn1 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_app(filename:join([AppDir,Name1]), Name1, Vsn1, [kernel, stdlib]),
rebar_test_utils:create_app(AppDir, Name1, Vsn1, [kernel, stdlib]),
Name2 = rebar_test_utils:create_random_name("checkapp2_"),
Vsn2 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_app(filename:join([CheckoutsDir,Name2]), Name2, Vsn2, [kernel, stdlib]),

+ 2
- 2
test/rebar_deps_SUITE.erl View File

@ -222,7 +222,7 @@ sub_app_deps(Config) ->
Name = rebar_test_utils:create_random_name("sub_app1_"),
Vsn = rebar_test_utils:create_random_vsn(),
SubAppsDir = filename:join([AppDir, Name]),
SubAppsDir = filename:join([AppDir, "apps", Name]),
SubDeps = rebar_test_utils:top_level_deps(rebar_test_utils:expand_deps(git, [{"a", "1.0.0", []}
,{"b", "2.0.0", []}])),
rebar_test_utils:create_app(SubAppsDir, Name, Vsn, [kernel, stdlib]),
@ -246,7 +246,7 @@ newly_added_dep(Config) ->
Name = rebar_test_utils:create_random_name("app_"),
Vsn = rebar_test_utils:create_random_vsn(),
SubAppsDir = filename:join([AppDir, Name]),
SubAppsDir = filename:join([AppDir, "apps", Name]),
rebar_test_utils:create_app(SubAppsDir, Name, Vsn, [kernel, stdlib]),
TopDeps = rebar_test_utils:top_level_deps(rebar_test_utils:expand_deps(git, [{"b", "1.0.0", []}])),

+ 2
- 2
test/rebar_dialyzer_SUITE.erl View File

@ -112,11 +112,11 @@ build_release_plt(Config) ->
Name1 = rebar_test_utils:create_random_name("relapp1_"),
Vsn1 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_app(filename:join([AppDir,Name1]), Name1, Vsn1,
rebar_test_utils:create_app(filename:join([AppDir,"apps",Name1]), Name1, Vsn1,
[erts]),
Name2 = rebar_test_utils:create_random_name("relapp2_"),
Vsn2 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_app(filename:join([AppDir,Name2]), Name2, Vsn2,
rebar_test_utils:create_app(filename:join([AppDir,"apps",Name2]), Name2, Vsn2,
[erts, ec_cnv:to_atom(Name1)]),
rebar_test_utils:run_and_check(Config, RebarConfig, ["dialyzer"],

+ 19
- 19
test/rebar_eunit_SUITE.erl View File

@ -59,13 +59,13 @@ test_multi_app(Config) ->
Name1 = rebar_test_utils:create_random_name("multi_app1_"),
Vsn1 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_eunit_app(filename:join([AppDir,Name1]),
rebar_test_utils:create_eunit_app(filename:join([AppDir,"apps",Name1]),
Name1,
Vsn1,
[kernel, stdlib]),
Name2 = rebar_test_utils:create_random_name("multi_app2_"),
Vsn2 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_eunit_app(filename:join([AppDir,Name2]),
rebar_test_utils:create_eunit_app(filename:join([AppDir,"apps",Name2]),
Name2,
Vsn2,
[kernel, stdlib]),
@ -117,13 +117,13 @@ test_multi_exports(Config) ->
Name1 = rebar_test_utils:create_random_name("multi_exports_app1_"),
Vsn1 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_eunit_app(filename:join([AppDir,Name1]),
rebar_test_utils:create_eunit_app(filename:join([AppDir,"apps",Name1]),
Name1,
Vsn1,
[kernel, stdlib]),
Name2 = rebar_test_utils:create_random_name("multi_exports_app2_"),
Vsn2 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_eunit_app(filename:join([AppDir,Name2]),
rebar_test_utils:create_eunit_app(filename:join([AppDir,"apps",Name2]),
Name2,
Vsn2,
[kernel, stdlib]),
@ -172,13 +172,13 @@ test_multi_defines(Config) ->
Name1 = rebar_test_utils:create_random_name("multi_app1_"),
Vsn1 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_eunit_app(filename:join([AppDir,Name1]),
rebar_test_utils:create_eunit_app(filename:join([AppDir,"apps",Name1]),
Name1,
Vsn1,
[kernel, stdlib]),
Name2 = rebar_test_utils:create_random_name("multi_app2_"),
Vsn2 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_eunit_app(filename:join([AppDir,Name2]),
rebar_test_utils:create_eunit_app(filename:join([AppDir,"apps",Name2]),
Name2,
Vsn2,
[kernel, stdlib]),
@ -208,13 +208,13 @@ test_single_app_flag(Config) ->
Name1 = rebar_test_utils:create_random_name("multi_exports_app1_"),
Vsn1 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_eunit_app(filename:join([AppDir,Name1]),
rebar_test_utils:create_eunit_app(filename:join([AppDir,"apps",Name1]),
Name1,
Vsn1,
[kernel, stdlib]),
Name2 = rebar_test_utils:create_random_name("multi_exports_app2_"),
Vsn2 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_eunit_app(filename:join([AppDir,Name2]),
rebar_test_utils:create_eunit_app(filename:join([AppDir,"apps",Name2]),
Name2,
Vsn2,
[kernel, stdlib]),
@ -245,13 +245,13 @@ test_multiple_app_flag(Config) ->
Name1 = rebar_test_utils:create_random_name("multi_exports_app1_"),
Vsn1 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_eunit_app(filename:join([AppDir,Name1]),
rebar_test_utils:create_eunit_app(filename:join([AppDir,"apps",Name1]),
Name1,
Vsn1,
[kernel, stdlib]),
Name2 = rebar_test_utils:create_random_name("multi_exports_app2_"),
Vsn2 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_eunit_app(filename:join([AppDir,Name2]),
rebar_test_utils:create_eunit_app(filename:join([AppDir,"apps",Name2]),
Name2,
Vsn2,
[kernel, stdlib]),
@ -288,7 +288,7 @@ test_nonexistent_app_flag(Config) ->
[kernel, stdlib]),
Name2 = rebar_test_utils:create_random_name("multi_exports_app2_"),
Vsn2 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_eunit_app(filename:join([AppDir,Name2]),
rebar_test_utils:create_eunit_app(filename:join([AppDir,"apps",Name2]),
Name2,
Vsn2,
[kernel, stdlib]),
@ -306,13 +306,13 @@ test_single_suite_flag(Config) ->
Name1 = rebar_test_utils:create_random_name("multi_exports_app1_"),
Vsn1 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_eunit_app(filename:join([AppDir,Name1]),
rebar_test_utils:create_eunit_app(filename:join([AppDir,"apps",Name1]),
Name1,
Vsn1,
[kernel, stdlib]),
Name2 = rebar_test_utils:create_random_name("multi_exports_app2_"),
Vsn2 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_eunit_app(filename:join([AppDir,Name2]),
rebar_test_utils:create_eunit_app(filename:join([AppDir,"apps",Name2]),
Name2,
Vsn2,
[kernel, stdlib]),
@ -331,13 +331,13 @@ test_suite_in_app_flag(Config) ->
Name1 = rebar_test_utils:create_random_name("multi_exports_app1_"),
Vsn1 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_eunit_app(filename:join([AppDir,Name1]),
rebar_test_utils:create_eunit_app(filename:join([AppDir,"apps",Name1]),
Name1,
Vsn1,
[kernel, stdlib]),
Name2 = rebar_test_utils:create_random_name("multi_exports_app2_"),
Vsn2 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_eunit_app(filename:join([AppDir,Name2]),
rebar_test_utils:create_eunit_app(filename:join([AppDir,"apps",Name2]),
Name2,
Vsn2,
[kernel, stdlib]),
@ -360,13 +360,13 @@ test_suite_in_wrong_app_flag(Config) ->
Name1 = rebar_test_utils:create_random_name("multi_exports_app1_"),
Vsn1 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_eunit_app(filename:join([AppDir,Name1]),
rebar_test_utils:create_eunit_app(filename:join([AppDir,"apps",Name1]),
Name1,
Vsn1,
[kernel, stdlib]),
Name2 = rebar_test_utils:create_random_name("multi_exports_app2_"),
Vsn2 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_eunit_app(filename:join([AppDir,Name2]),
rebar_test_utils:create_eunit_app(filename:join([AppDir,"apps",Name2]),
Name2,
Vsn2,
[kernel, stdlib]),
@ -388,13 +388,13 @@ test_nonexistent_suite_flag(Config) ->
Name1 = rebar_test_utils:create_random_name("multi_exports_app1_"),
Vsn1 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_eunit_app(filename:join([AppDir,Name1]),
rebar_test_utils:create_eunit_app(filename:join([AppDir,"apps",Name1]),
Name1,
Vsn1,
[kernel, stdlib]),
Name2 = rebar_test_utils:create_random_name("multi_exports_app2_"),
Vsn2 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_eunit_app(filename:join([AppDir,Name2]),
rebar_test_utils:create_eunit_app(filename:join([AppDir,"apps",Name2]),
Name2,
Vsn2,
[kernel, stdlib]),

+ 6
- 6
test/rebar_src_dirs_SUITE.erl View File

@ -153,17 +153,17 @@ build_multi_apps(Config) ->
Name1 = rebar_test_utils:create_random_name("app1_"),
Vsn1 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_app(filename:join([AppDir,Name1]), Name1, Vsn1, [kernel, stdlib]),
rebar_test_utils:create_app(filename:join([AppDir,"apps",Name1]), Name1, Vsn1, [kernel, stdlib]),
Name2 = rebar_test_utils:create_random_name("app2_"),
Vsn2 = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_app(filename:join([AppDir,Name2]), Name2, Vsn2, [kernel, stdlib]),
rebar_test_utils:create_app(filename:join([AppDir,"apps",Name2]), Name2, Vsn2, [kernel, stdlib]),
Extra1 = filename:join([AppDir, Name1, "extra", "extra1.erl"]),
Extra1 = filename:join([AppDir, "apps", Name1, "extra", "extra1.erl"]),
ok = filelib:ensure_dir(Extra1),
Src1 = io_lib:format("-module(extra1).~n-export([x/0]).~nx() -> ok.", []),
ok = ec_file:write(Extra1, Src1),
Extra2 = filename:join([AppDir, Name2, "extra", "extra2.erl"]),
Extra2 = filename:join([AppDir, "apps", Name2, "extra", "extra2.erl"]),
ok = filelib:ensure_dir(Extra2),
Src2 = io_lib:format("-module(extra2).~n-export([x/0]).~nx() -> ok.", []),
ok = ec_file:write(Extra2, Src2),
@ -178,7 +178,7 @@ build_multi_apps(Config) ->
%% check that `extraX.erl` was compiled to the `ebin` dir
Ebin1 = filename:join([AppDir, "_build", "default", "lib", Name1, "ebin"]),
true = filelib:is_file(filename:join([Ebin1, "extra1.beam"])),
Ebin2 = filename:join([AppDir, "_build", "default", "lib", Name2, "ebin"]),
true = filelib:is_file(filename:join([Ebin2, "extra2.beam"])),
@ -236,4 +236,4 @@ src_dir_takes_precedence_over_extra(Config) ->
Name ++ ".app"])),
[{application, _, KVs}] = App,
Mods = proplists:get_value(modules, KVs),
true = lists:member(extra, Mods).
true = lists:member(extra, Mods).

+ 4
- 4
test/rebar_test_utils.erl View File

@ -169,10 +169,10 @@ top_level_deps([{{Name, Vsn, Ref}, _} | Deps]) ->
%%% Helpers %%%
%%%%%%%%%%%%%%%
check_results(AppDir, Expected, ProfileRun) ->
BuildDirs = filelib:wildcard(filename:join([AppDir, "_build", ProfileRun, "lib"])),
PluginDirs = filelib:wildcard(filename:join([AppDir, "_build", ProfileRun, "plugins"])),
GlobalPluginDirs = filelib:wildcard(filename:join([AppDir, "global", "plugins"])),
CheckoutsDir = filename:join([AppDir, "_checkouts"]),
BuildDirs = filelib:wildcard(filename:join([AppDir, "_build", ProfileRun, "lib", "*"])),
PluginDirs = filelib:wildcard(filename:join([AppDir, "_build", ProfileRun, "plugins", "*"])),
GlobalPluginDirs = filelib:wildcard(filename:join([AppDir, "global", "plugins", "*"])),
CheckoutsDir = filename:join([AppDir, "_checkouts", "*"]),
LockFile = filename:join([AppDir, "rebar.lock"]),
Locks = lists:flatten(rebar_config:consult_lock_file(LockFile)),

Loading…
Cancel
Save