diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/rebar_compile_SUITE.erl | 35 | ||||
-rw-r--r-- | test/rebar_ct_SUITE.erl | 2 | ||||
-rw-r--r-- | test/rebar_dialyzer_SUITE.erl | 2 | ||||
-rw-r--r-- | test/rebar_install_deps_SUITE.erl | 8 | ||||
-rw-r--r-- | test/rebar_profiles_SUITE.erl | 28 | ||||
-rw-r--r-- | test/rebar_test_utils.erl | 8 | ||||
-rw-r--r-- | test/rebar_unlock_SUITE.erl | 4 |
7 files changed, 74 insertions, 13 deletions
diff --git a/test/rebar_compile_SUITE.erl b/test/rebar_compile_SUITE.erl index 0b62cbe..62df7aa 100644 --- a/test/rebar_compile_SUITE.erl +++ b/test/rebar_compile_SUITE.erl @@ -46,6 +46,7 @@ include_file_in_src/1, include_file_relative_to_working_directory_test/1, include_file_in_src_test/1, + include_file_in_src_test_multiapp/1, dont_recompile_when_erl_compiler_options_env_does_not_change/1, recompile_when_erl_compiler_options_env_changes/1, always_recompile_when_erl_compiler_options_set/1, @@ -79,6 +80,7 @@ all() -> profile_override_deps, profile_deps, deps_build_in_prod, include_file_relative_to_working_directory, include_file_in_src, include_file_relative_to_working_directory_test, include_file_in_src_test, + include_file_in_src_test_multiapp, recompile_when_parse_transform_as_opt_changes, recompile_when_parse_transform_inline_changes, regex_filter_skip, regex_filter_regression, @@ -1475,6 +1477,39 @@ include_file_in_src_test(Config) -> ["as", "test", "compile"], {ok, [{app, Name}]}). +%% Same as `include_file_in_src_test/1' but using multiple top-level +%% apps as dependencies. +include_file_in_src_test_multiapp(Config) -> + + Name1 = rebar_test_utils:create_random_name("app2_"), + Name2 = rebar_test_utils:create_random_name("app1_"), + AppDir1 = filename:join([?config(apps, Config), "lib", Name1]), + AppDir2 = filename:join([?config(apps, Config), "lib", Name2]), + Vsn = rebar_test_utils:create_random_vsn(), + rebar_test_utils:create_app(AppDir1, Name1, Vsn, [kernel, stdlib]), + rebar_test_utils:create_app(AppDir2, Name2, Vsn, [kernel, stdlib]), + + Src = "-module(test).\n" +"\n" +"-include_lib(\"" ++ Name2 ++ "/include/test.hrl\").\n" +"\n" +"test() -> ?TEST_MACRO.\n" +"\n", + Include = <<"-define(TEST_MACRO, test).\n">>, + + ok = filelib:ensure_dir(filename:join([AppDir1, "src", "dummy"])), + ok = filelib:ensure_dir(filename:join([AppDir1, "test", "dummy"])), + ok = filelib:ensure_dir(filename:join([AppDir2, "src", "dummy"])), + ok = filelib:ensure_dir(filename:join([AppDir2, "include", "dummy"])), + ok = file:write_file(filename:join([AppDir1, "test", "test.erl"]), Src), + + ok = file:write_file(filename:join([AppDir2, "include", "test.hrl"]), Include), + + RebarConfig = [], + rebar_test_utils:run_and_check(Config, RebarConfig, + ["as", "test", "compile"], + {ok, [{app, Name1}]}). + %% this test sets the env var, compiles, records the file last modified timestamp, %% recompiles and compares the file last modified timestamp to ensure it hasn't %% changed. this test should run on 19.x+ diff --git a/test/rebar_ct_SUITE.erl b/test/rebar_ct_SUITE.erl index f009930..d7094ec 100644 --- a/test/rebar_ct_SUITE.erl +++ b/test/rebar_ct_SUITE.erl @@ -1407,7 +1407,7 @@ testspec_at_root(Config) -> CommandProvider = providers:get_provider(ct, Providers, Namespace), GetOptSpec = providers:opts(CommandProvider), - SpecArg1 = string:join([Spec1,Spec2,Spec3],","), + SpecArg1 = rebar_string:join([Spec1,Spec2,Spec3],","), {ok, GetOptResult1} = getopt:parse(GetOptSpec, ["--spec",SpecArg1]), State1 = rebar_state:command_parsed_args(State, GetOptResult1), Tests1 = rebar_prv_common_test:prepare_tests(State1), diff --git a/test/rebar_dialyzer_SUITE.erl b/test/rebar_dialyzer_SUITE.erl index d0a3611..6579afb 100644 --- a/test/rebar_dialyzer_SUITE.erl +++ b/test/rebar_dialyzer_SUITE.erl @@ -362,6 +362,6 @@ get_apps_from_beam_files(BeamFiles) -> lists:usort( [begin AppNameVsn = filename:basename(filename:dirname(filename:dirname(File))), - [AppName | _] = string:tokens(AppNameVsn ++ "-", "-"), + [AppName | _] = rebar_string:lexemes(AppNameVsn ++ "-", "-"), ec_cnv:to_atom(AppName) end || File <- BeamFiles]). diff --git a/test/rebar_install_deps_SUITE.erl b/test/rebar_install_deps_SUITE.erl index 9ff28c7..3dbbf63 100644 --- a/test/rebar_install_deps_SUITE.erl +++ b/test/rebar_install_deps_SUITE.erl @@ -82,12 +82,12 @@ format_expected_mdeps(Deps) -> lists:append([ case Dep of {N,V} when hd(N) >= $a, hd(N) =< $z -> - UN = string:to_upper(N), + UN = rebar_string:uppercase(N), [{dep, UN, V}, {lock, pkg, UN, V}]; {N,V} when hd(N) >= $A, hd(N) =< $Z -> [{dep, N, V}, {lock, src, N, V}]; N when hd(N) >= $a, hd(N) =< $z -> - UN = string:to_upper(N), + UN = rebar_string:uppercase(N), [{dep, UN}, {lock, pkg, UN, "0.0.0"}]; N when hd(N) >= $A, hd(N) =< $Z -> [{dep, N}, {lock, src, N, "0.0.0"}] @@ -95,9 +95,9 @@ format_expected_mdeps(Deps) -> format_expected_mixed_warnings(Warnings) -> [case W of - {N, Vsn} when hd(N) >= $a, hd(N) =< $z -> {pkg, string:to_upper(N), Vsn}; + {N, Vsn} when hd(N) >= $a, hd(N) =< $z -> {pkg, rebar_string:uppercase(N), Vsn}; {N, Vsn} when hd(N) >= $A, hd(N) =< $Z -> {git, N, Vsn}; - N when hd(N) >= $a, hd(N) =< $z -> {pkg, string:to_upper(N), "0.0.0"}; + N when hd(N) >= $a, hd(N) =< $z -> {pkg, rebar_string:uppercase(N), "0.0.0"}; N when hd(N) >= $A, hd(N) =< $Z -> {git, N, "0.0.0"} end || W <- Warnings]. diff --git a/test/rebar_profiles_SUITE.erl b/test/rebar_profiles_SUITE.erl index 11aca6a..6afdc39 100644 --- a/test/rebar_profiles_SUITE.erl +++ b/test/rebar_profiles_SUITE.erl @@ -27,6 +27,7 @@ test_profile_erl_opts_order_3/1, test_profile_erl_opts_order_4/1, test_profile_erl_opts_order_5/1, + test_erl_opts_debug_info/1, first_files_exception/1]). -include_lib("common_test/include/ct.hrl"). @@ -50,6 +51,7 @@ all() -> test_profile_erl_opts_order_3, test_profile_erl_opts_order_4, test_profile_erl_opts_order_5, + test_erl_opts_debug_info, first_files_exception]. init_per_suite(Config) -> @@ -501,6 +503,30 @@ test_profile_erl_opts_order_5(Config) -> Opt = last_erl_opt(Opts, [warn_export_all, nowarn_export_all], undefined), warn_export_all = Opt. +test_erl_opts_debug_info(_Config) -> + ToOpts = fun(List) -> rebar_opts:erl_opts(dict:from_list([{erl_opts, List}])) end, + ?assertEqual([debug_info,a,b,c], + ToOpts([a,b,c])), + ?assertEqual([{debug_info,{mod,123}},a,b,c,debug_info], + ToOpts([{debug_info,{mod,123}},a,b,c,debug_info])), + ?assertEqual([a,b,debug_info,c], + ToOpts([no_debug_info,a,b,debug_info,c])), + ?assertEqual([a,b,c], + ToOpts([debug_info,a,b,no_debug_info,c])), + ?assertEqual([a,b,c,debug_info], + ToOpts([{debug_info_key, "12345"},a,b, + no_debug_info,c,debug_info])), + ?assertEqual([a,b,c], + ToOpts([{debug_info,{mod,123}},{debug_info_key, "12345"}, + a,no_debug_info,b,c,debug_info,no_debug_info])), + ?assertEqual([a,b,c,{debug_info_key,"123"}], + ToOpts([{debug_info_key, "12345"},a,b,no_debug_info,debug_info, + c,{debug_info_key, "123"}])), + ?assertEqual([{debug_info_key,"12345"},a,b,c,{debug_info,{mod,"123"}}], + ToOpts([debug_info,{debug_info_key,"12345"},a, + no_debug_info,b,c,{debug_info,{mod,"123"}}])), + ok. + first_files_exception(_Config) -> RebarConfig = [{erl_first_files, ["c","a","b"]}, {mib_first_files, ["c","a","b"]}, @@ -542,7 +568,7 @@ get_compiled_profile_erl_opts(Profiles, Config) -> [default] -> ["compile"]; _ -> - ["as", string:join(PStrs, ","), "compile"] + ["as", rebar_string:join(PStrs, ","), "compile"] end, {ok, State} = rebar_test_utils:run_and_check( Config, RebarConfig, Command, {ok, [{app, Name}]}), diff --git a/test/rebar_test_utils.erl b/test/rebar_test_utils.erl index 0ccec56..c1e8b62 100644 --- a/test/rebar_test_utils.erl +++ b/test/rebar_test_utils.erl @@ -167,14 +167,14 @@ expand_deps(pkg, [{Name, Vsn, Deps} | Rest]) -> [{Dep, expand_deps(pkg, Deps)} | expand_deps(pkg, Rest)]; expand_deps(mixed, [{Name, Deps} | Rest]) -> Dep = if hd(Name) >= $a, hd(Name) =< $z -> - {pkg, string:to_upper(Name), "0.0.0", undefined} + {pkg, rebar_string:uppercase(Name), "0.0.0", undefined} ; hd(Name) >= $A, hd(Name) =< $Z -> {Name, ".*", {git, "https://example.org/user/"++Name++".git", "master"}} end, [{Dep, expand_deps(mixed, Deps)} | expand_deps(mixed, Rest)]; expand_deps(mixed, [{Name, Vsn, Deps} | Rest]) -> Dep = if hd(Name) >= $a, hd(Name) =< $z -> - {pkg, string:to_upper(Name), Vsn, undefined} + {pkg, rebar_string:uppercase(Name), Vsn, undefined} ; hd(Name) >= $A, hd(Name) =< $Z -> {Name, Vsn, {git, "https://example.org/user/"++Name++".git", {tag, Vsn}}} end, @@ -477,7 +477,7 @@ package_app(AppDir, DestDir, PkgName) -> {ok, Contents} = file:read_file(filename:join(DestDir, "contents.tar.gz")), Blob = <<"3who cares", Contents/binary>>, <<X:256/big-unsigned>> = crypto:hash(sha256, Blob), - BinChecksum = list_to_binary(string:to_upper(lists:flatten(io_lib:format("~64.16.0b", [X])))), + BinChecksum = list_to_binary(rebar_string:uppercase(lists:flatten(io_lib:format("~64.16.0b", [X])))), ok = file:write_file(filename:join(DestDir, "CHECKSUM"), BinChecksum), PkgFiles = ["contents.tar.gz", "VERSION", "metadata.config", "CHECKSUM"], Archive = filename:join(DestDir, Name), @@ -485,5 +485,5 @@ package_app(AppDir, DestDir, PkgName) -> lists:zip(PkgFiles, [filename:join(DestDir,F) || F <- PkgFiles])), {ok, BinFull} = file:read_file(Archive), <<E:128/big-unsigned-integer>> = crypto:hash(md5, BinFull), - Etag = string:to_lower(lists:flatten(io_lib:format("~32.16.0b", [E]))), + Etag = rebar_string:lowercase(lists:flatten(io_lib:format("~32.16.0b", [E]))), {BinChecksum, Etag}. diff --git a/test/rebar_unlock_SUITE.erl b/test/rebar_unlock_SUITE.erl index b2c0205..a8d1400 100644 --- a/test/rebar_unlock_SUITE.erl +++ b/test/rebar_unlock_SUITE.erl @@ -33,7 +33,7 @@ pkgunlock(Config) -> rebar_test_utils:run_and_check(Config, [], ["unlock", "cf,certifi"], {ok, []}), ?assertEqual(Locks -- ["bbmustache","cf","certifi"], read_locks(Config)), ?assertEqual(Hashes -- ["bbmustache","cf","certifi"], read_hashes(Config)), - rebar_test_utils:run_and_check(Config, [], ["unlock", string:join(Locks,",")], {ok, []}), + rebar_test_utils:run_and_check(Config, [], ["unlock", rebar_string:join(Locks,",")], {ok, []}), ?assertEqual({error, enoent}, read_locks(Config)), ?assertEqual({error, enoent}, read_hashes(Config)), ok. @@ -48,7 +48,7 @@ unlock(Config) -> ?assert(false =/= lists:keyfind(<<"itc">>, 1, rebar_state:get(State, {locks, default}))), rebar_test_utils:run_and_check(Config, [], ["unlock", "gproc,itc"], {ok, []}), ?assertEqual(Locks -- ["uuid","gproc","itc"], read_locks(Config)), - rebar_test_utils:run_and_check(Config, [], ["unlock", string:join(Locks,",")], {ok, []}), + rebar_test_utils:run_and_check(Config, [], ["unlock", rebar_string:join(Locks,",")], {ok, []}), ?assertEqual({error, enoent}, read_locks(Config)), ok. |