From ca93ccf62e91c55345eb1e67e6ea107ba72e5a1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Thu, 25 Feb 2016 15:01:29 +0100 Subject: Eliminate use of ?config() macro ?config is ugly and not recommended. Use proplists:get_value/2 instead. --- lib/compiler/test/beam_disasm_SUITE.erl | 2 +- lib/compiler/test/beam_validator_SUITE.erl | 4 ++-- lib/compiler/test/compilation_SUITE.erl | 34 +++++++++++++++++------------- lib/compiler/test/compile_SUITE.erl | 30 +++++++++++++------------- lib/compiler/test/core_SUITE.erl | 3 ++- lib/compiler/test/core_fold_SUITE.erl | 4 ++-- lib/compiler/test/error_SUITE.erl | 6 +++--- lib/compiler/test/guard_SUITE.erl | 2 +- lib/compiler/test/inline_SUITE.erl | 15 +++++++------ lib/compiler/test/misc_SUITE.erl | 2 +- lib/compiler/test/receive_SUITE.erl | 4 ++-- lib/compiler/test/record_SUITE.erl | 2 +- lib/compiler/test/regressions_SUITE.erl | 2 +- lib/compiler/test/test_lib.erl | 2 +- lib/compiler/test/warnings_SUITE.erl | 4 ++-- 15 files changed, 61 insertions(+), 55 deletions(-) diff --git a/lib/compiler/test/beam_disasm_SUITE.erl b/lib/compiler/test/beam_disasm_SUITE.erl index 4268729e75..75bc720596 100644 --- a/lib/compiler/test/beam_disasm_SUITE.erl +++ b/lib/compiler/test/beam_disasm_SUITE.erl @@ -49,7 +49,7 @@ end_per_group(_GroupName, Config) -> stripped(doc) -> ["Check that stripped beam files can be disassembled"]; stripped(Config) when is_list(Config) -> - ?line PrivDir = ?config(priv_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), ?line SrcName = filename:join(PrivDir, "tmp.erl"), ?line BeamName = filename:join(PrivDir, "tmp.beam"), Prog = <<"-module(tmp).\n-export([tmp/0]).\ntmp()->ok.\n">>, diff --git a/lib/compiler/test/beam_validator_SUITE.erl b/lib/compiler/test/beam_validator_SUITE.erl index e759a75ede..2024b6ab77 100644 --- a/lib/compiler/test/beam_validator_SUITE.erl +++ b/lib/compiler/test/beam_validator_SUITE.erl @@ -77,7 +77,7 @@ end_per_group(_GroupName, Config) -> compiler_bug(Config) when is_list(Config) -> %% Check that the compiler returns an error if we try to %% assemble one of the bad '.S' files. - Data = ?config(data_dir, Config), + Data = proplists:get_value(data_dir, Config), File = filename:join(Data, "compiler_bug"), error = compile:file(File, [from_asm,report_errors,time]), @@ -420,7 +420,7 @@ map_field_lists(Config) -> %%%------------------------------------------------------------------------- do_val(Mod, Config) -> - Data = ?config(data_dir, Config), + Data = proplists:get_value(data_dir, Config), Base = atom_to_list(Mod), File = filename:join(Data, Base), case compile:file(File, [from_asm,no_postopt,return_errors]) of diff --git a/lib/compiler/test/compilation_SUITE.erl b/lib/compiler/test/compilation_SUITE.erl index 68bc3d9985..8745e0d129 100644 --- a/lib/compiler/test/compilation_SUITE.erl +++ b/lib/compiler/test/compilation_SUITE.erl @@ -196,8 +196,9 @@ redundant_case_1(4) -> d; redundant_case_1(_) -> d. failure(Module, Conf) -> - ?line Src = filename:join(?config(data_dir, Conf), atom_to_list(Module)), - ?line Out = ?config(priv_dir,Conf), + Src = filename:join(proplists:get_value(data_dir, Conf), + atom_to_list(Module)), + Out = proplists:get_value(priv_dir, Conf), ?line io:format("Compiling: ~ts\n", [Src]), ?line CompRc = compile:file(Src, [{outdir,Out},return,time]), ?line io:format("Result: ~p\n",[CompRc]), @@ -242,8 +243,9 @@ try_it(StartNode, Module, Conf) -> try_it(StartNode, Module, Timetrap, Conf) -> ?line OtherOpts = [], %Can be changed to [time] if needed - ?line Src = filename:join(?config(data_dir, Conf), atom_to_list(Module)), - ?line Out = ?config(priv_dir,Conf), + Src = filename:join(proplists:get_value(data_dir, Conf), + atom_to_list(Module)), + Out = proplists:get_value(priv_dir,Conf), ?line io:format("Compiling: ~s\n", [Src]), ?line CompRc0 = compile:file(Src, [clint,{outdir,Out},report, bin_opt_info|OtherOpts]), @@ -343,15 +345,16 @@ vsn_1(suite) -> []; vsn_1(Conf) when is_list(Conf) -> ?line M = vsn_1, - ?line compile_load(M, ?config(data_dir, Conf), Conf), + compile_load(M, proplists:get_value(data_dir, Conf), Conf), ?line Vsn1 = get_vsn(M), ?line timer:sleep(1000), - ?line compile_load(M, ?config(data_dir, Conf), Conf), + compile_load(M, proplists:get_value(data_dir, Conf), Conf), ?line Vsn2 = get_vsn(M), - ?line compile_load(M, filename:join(?config(data_dir, Conf), "other"), - Conf), + compile_load(M, filename:join(proplists:get_value(data_dir, Conf), + "other"), + Conf), ?line Vsn3 = get_vsn(M), ?line if Vsn1 == Vsn2, Vsn2 == Vsn3 -> @@ -367,7 +370,7 @@ vsn_2(suite) -> []; vsn_2(Conf) when is_list(Conf) -> ?line M = vsn_2, - ?line compile_load(M, ?config(data_dir, Conf), Conf), + compile_load(M, proplists:get_value(data_dir, Conf), Conf), ?line Vsn = get_vsn(M), ?line case Vsn of [34] -> @@ -383,11 +386,12 @@ vsn_3(suite) -> []; vsn_3(Conf) when is_list(Conf) -> ?line M = vsn_3, - ?line compile_load(M, ?config(data_dir, Conf), Conf), + compile_load(M, proplists:get_value(data_dir, Conf), Conf), ?line Vsn1 = get_vsn(M), - ?line compile_load(M, filename:join(?config(data_dir, Conf), "other"), - Conf), + compile_load(M, filename:join(proplists:get_value(data_dir, Conf), + "other"), + Conf), ?line Vsn2 = get_vsn(M), ?line if Vsn1 /= Vsn2 -> @@ -408,7 +412,7 @@ long_string(Config) when is_list(Config) -> compile_load(Module, Dir, Conf) -> ?line Src = filename:join(Dir, atom_to_list(Module)), - ?line Out = ?config(priv_dir,Conf), + Out = proplists:get_value(priv_dir,Conf), ?line CompRc = compile:file(Src, [{outdir,Out}]), ?line {ok, Module} = CompRc, ?line code:purge(Module), @@ -427,7 +431,7 @@ self_compile_old_inliner(Config) when is_list(Config) -> self_compile_1(Config, Prefix, Opts) -> ct:timetrap({minutes,40}), - Priv = ?config(priv_dir,Config), + Priv = proplists:get_value(priv_dir,Config), Version = compiler_version(), %% Compile the compiler. (In this node to get better coverage.) @@ -615,7 +619,7 @@ otp_7345(ObjRef, _RdEnv, Args) -> %% Check the generation of the string table. string_table(Config) when is_list(Config) -> - ?line DataDir = ?config(data_dir, Config), + DataDir = proplists:get_value(data_dir, Config), ?line File = filename:join(DataDir, "string_table.erl"), ?line {ok,string_table,Beam,[]} = compile:file(File, [return, binary]), ?line {ok,{string_table,[StringTableChunk]}} = beam_lib:chunks(Beam, ["StrT"]), diff --git a/lib/compiler/test/compile_SUITE.erl b/lib/compiler/test/compile_SUITE.erl index d2f6a983aa..548abacc08 100644 --- a/lib/compiler/test/compile_SUITE.erl +++ b/lib/compiler/test/compile_SUITE.erl @@ -143,7 +143,7 @@ forms_2(Config) when is_list(Config) -> ok. module_mismatch(Config) when is_list(Config) -> - ?line DataDir = ?config(data_dir, Config), + DataDir = proplists:get_value(data_dir, Config), ?line File = filename:join(DataDir, "wrong_module_name.erl"), {error,[{"wrong_module_name.beam", [{none,compile,{module_name,arne,"wrong_module_name"}}]}], @@ -193,7 +193,7 @@ binary(Config) when is_list(Config) -> makedep(Config) when is_list(Config) -> {Simple,Target} = get_files(Config, simple, "makedep"), - ?line DataDir = ?config(data_dir, Config), + DataDir = proplists:get_value(data_dir, Config), ?line SimpleRootname = filename:rootname(Simple), ?line IncludeDir = filename:join(filename:dirname(Simple), "include"), ?line IncludeOptions = [ @@ -279,8 +279,8 @@ cond_and_ifdef(Config) when is_list(Config) -> ok. listings(Config) when is_list(Config) -> - DataDir = ?config(data_dir, Config), - PrivDir = ?config(priv_dir, Config), + DataDir = proplists:get_value(data_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), ok = do_file_listings(DataDir, PrivDir, [ "simple", "small", @@ -553,8 +553,8 @@ do_listing(Source, TargetDir, Type, Ext) -> get_files(Config, Module, OutputName) -> code:delete(Module), code:purge(Module), - DataDir = ?config(data_dir, Config), - PrivDir = ?config(priv_dir, Config), + DataDir = proplists:get_value(data_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), Src = filename:join(DataDir, atom_to_list(Module)), TargetDir = filename:join(PrivDir, OutputName), ok = file:make_dir(TargetDir), @@ -578,8 +578,8 @@ exists(Name) -> strict_record(Config) when is_list(Config) -> - ?line Priv = ?config(priv_dir, Config), - ?line file:set_cwd(?config(data_dir, Config)), + Priv = proplists:get_value(priv_dir, Config), + ok = file:set_cwd(proplists:get_value(data_dir, Config)), ?line Opts = [{outdir,Priv},report_errors], M = record_access, @@ -621,8 +621,8 @@ test_sloppy() -> Turtle. missing_testheap(Config) when is_list(Config) -> - DataDir = ?config(data_dir, Config), - PrivDir = ?config(priv_dir, Config), + DataDir = proplists:get_value(data_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), Opts = [{outdir,PrivDir}], OldPath = code:get_path(), try @@ -702,7 +702,7 @@ env_1(Simple, Target) -> %% compile the generated Core Erlang files. core(Config) when is_list(Config) -> - PrivDir = ?config(priv_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), Outdir = filename:join(PrivDir, "core"), ok = file:make_dir(Outdir), @@ -765,7 +765,7 @@ compile_forms(Forms, Opts) -> %% run .S through the compiler again. asm(Config) when is_list(Config) -> - ?line PrivDir = ?config(priv_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), ?line Outdir = filename:join(PrivDir, "asm"), ?line ok = file:make_dir(Outdir), @@ -799,7 +799,7 @@ do_asm(Beam, Outdir) -> end. sys_pre_attributes(Config) -> - DataDir = ?config(data_dir, Config), + DataDir = proplists:get_value(data_dir, Config), File = filename:join(DataDir, "attributes.erl"), Mod = attributes, CommonOpts = [binary,report,verbose, @@ -831,8 +831,8 @@ sys_pre_attributes(Config) -> %% Test the dialyzer option to cover more code. dialyzer(Config) -> - Priv = ?config(priv_dir, Config), - file:set_cwd(?config(data_dir, Config)), + Priv = proplists:get_value(priv_dir, Config), + ok = file:set_cwd(proplists:get_value(data_dir, Config)), Opts = [{outdir,Priv},report_errors], M = dialyzer_test, {ok,M} = c:c(M, [dialyzer|Opts]), diff --git a/lib/compiler/test/core_SUITE.erl b/lib/compiler/test/core_SUITE.erl index 3f8bb91e51..22f6443a77 100644 --- a/lib/compiler/test/core_SUITE.erl +++ b/lib/compiler/test/core_SUITE.erl @@ -85,7 +85,8 @@ end_per_group(_GroupName, Config) -> try_it(Mod, Conf) -> - Src = filename:join(?config(data_dir, Conf), atom_to_list(Mod)), + Src = filename:join(proplists:get_value(data_dir, Conf), + atom_to_list(Mod)), compile_and_load(Src, []), compile_and_load(Src, [no_copt]). diff --git a/lib/compiler/test/core_fold_SUITE.erl b/lib/compiler/test/core_fold_SUITE.erl index 36faea1363..f8bde832b0 100644 --- a/lib/compiler/test/core_fold_SUITE.erl +++ b/lib/compiler/test/core_fold_SUITE.erl @@ -232,7 +232,7 @@ eq(Config) when is_list(Config) -> %% OTP-7117. nested_call_in_case(Config) when is_list(Config) -> - PrivDir = ?config(priv_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), Dir = test_lib:get_data_dir(Config), Core = filename:join(Dir, "nested_call_in_case"), Opts = [from_core,{outdir,PrivDir}|test_lib:opt_opts(?MODULE)], @@ -347,7 +347,7 @@ bsm_an_inlined(<<_:8>>, _) -> ok; bsm_an_inlined(_, _) -> error. unused_multiple_values_error(Config) when is_list(Config) -> - PrivDir = ?config(priv_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), Dir = test_lib:get_data_dir(Config), Core = filename:join(Dir, "unused_multiple_values_error"), Opts = [no_copt,clint,return,from_core,{outdir,PrivDir} diff --git a/lib/compiler/test/error_SUITE.erl b/lib/compiler/test/error_SUITE.erl index f4662ec7b2..86377b9f34 100644 --- a/lib/compiler/test/error_SUITE.erl +++ b/lib/compiler/test/error_SUITE.erl @@ -183,7 +183,7 @@ head_mismatch_line(Config) when is_list(Config) -> %% Compiles a test file and returns the list of errors. get_compilation_errors(Config, Filename) -> - ?line DataDir = ?config(data_dir, Config), + DataDir = proplists:get_value(data_dir, Config), ?line File = filename:join(DataDir, Filename), ?line {error, [{_Name, E}|_], []} = compile:file(File, [return_errors]), E. @@ -191,7 +191,7 @@ get_compilation_errors(Config, Filename) -> warnings_as_errors(Config) when is_list(Config) -> ?line TestFile = test_filename(Config), ?line BeamFile = filename:rootname(TestFile, ".erl") ++ ".beam", - ?line OutDir = ?config(priv_dir, Config), + OutDir = proplists:get_value(priv_dir, Config), Ts1 = [{warnings_as_errors, <<" @@ -338,7 +338,7 @@ filter(X) -> test_filename(Conf) -> Filename = ["errors_test_",test_lib:uniq(),".erl"], - DataDir = ?config(priv_dir, Conf), + DataDir = proplists:get_value(priv_dir, Conf), filename:join(DataDir, Filename). run_test(Test0, File, Warnings, WriteBeam) -> diff --git a/lib/compiler/test/guard_SUITE.erl b/lib/compiler/test/guard_SUITE.erl index 5391771dad..8d1baef63d 100644 --- a/lib/compiler/test/guard_SUITE.erl +++ b/lib/compiler/test/guard_SUITE.erl @@ -1427,7 +1427,7 @@ test(T, L1, L2) -> {match,Anno,{atom,Anno,Val},hd(E)}. smoke_disasm(Config, Mod, Bin) -> - Priv = ?config(priv_dir, Config), + Priv = proplists:get_value(priv_dir, Config), File = filename:join(Priv, atom_to_list(Mod)++".beam"), ok = file:write_file(File, Bin), test_lib:smoke_disasm(File). diff --git a/lib/compiler/test/inline_SUITE.erl b/lib/compiler/test/inline_SUITE.erl index 77a58dff34..efe5ad3162 100644 --- a/lib/compiler/test/inline_SUITE.erl +++ b/lib/compiler/test/inline_SUITE.erl @@ -47,7 +47,7 @@ init_per_suite(Config) -> [{testing_node,Node}|Config]. end_per_suite(Config) -> - Node = ?config(testing_node, Config), + Node = proplists:get_value(testing_node, Config), ?t:stop_node(Node), ok. @@ -60,8 +60,8 @@ end_per_group(_GroupName, Config) -> attribute(Config) when is_list(Config) -> Name = "attribute", - ?line Src = filename:join(?config(data_dir, Config), Name), - ?line Out = ?config(priv_dir,Config), + Src = filename:join(proplists:get_value(data_dir, Config), Name), + Out = proplists:get_value(priv_dir,Config), ?line {ok,attribute=Mod} = compile:file(Src, [{outdir,Out},report,time]), ?line Outfile = filename:join(Out, Name++".beam"), @@ -89,9 +89,10 @@ attribute(Config) when is_list(Config) -> ?comp(maps_inline_test). try_inline(Mod, Config) -> - Node = ?config(testing_node, Config), - ?line Src = filename:join(?config(data_dir, Config), atom_to_list(Mod)), - ?line Out = ?config(priv_dir,Config), + Node = proplists:get_value(testing_node, Config), + Src = filename:join(proplists:get_value(data_dir, Config), + atom_to_list(Mod)), + Out = proplists:get_value(priv_dir,Config), %% Normal compilation. ?line io:format("Compiling: ~s\n", [Src]), @@ -340,7 +341,7 @@ otp_7223_2({a}) -> coverage(Config) when is_list(Config) -> Mod = bsdecode, - Src = filename:join(?config(data_dir, Config), Mod), + Src = filename:join(proplists:get_value(data_dir, Config), Mod), {ok,Mod,_} = compile:file(Src, [binary,report,{inline,0},clint]), {ok,Mod,_} = compile:file(Src, [binary,report,{inline,20}, verbose,clint]), diff --git a/lib/compiler/test/misc_SUITE.erl b/lib/compiler/test/misc_SUITE.erl index 9c027bdc6b..ce6c21ed76 100644 --- a/lib/compiler/test/misc_SUITE.erl +++ b/lib/compiler/test/misc_SUITE.erl @@ -341,7 +341,7 @@ integer_encoding(Config) when is_list(Config) -> end. integer_encoding_1(Config) -> - ?line PrivDir = ?config(priv_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), ?line SrcFile = filename:join(PrivDir, "misc_SUITE_integer_encoding.erl"), ?line DataFile = filename:join(PrivDir, "integer_encoding.data"), Mod = misc_SUITE_integer_encoding, diff --git a/lib/compiler/test/receive_SUITE.erl b/lib/compiler/test/receive_SUITE.erl index df5df68015..a01672f46d 100644 --- a/lib/compiler/test/receive_SUITE.erl +++ b/lib/compiler/test/receive_SUITE.erl @@ -187,8 +187,8 @@ ref_opt(Config) when is_list(Config) -> end. ref_opt_1(Config) -> - DataDir = ?config(data_dir, Config), - PrivDir = ?config(priv_dir, Config), + DataDir = proplists:get_value(data_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), Sources = filelib:wildcard(filename:join([DataDir,"ref_opt","*.{erl,S}"])), test_lib:p_run(fun(Src) -> do_ref_opt(Src, PrivDir) diff --git a/lib/compiler/test/record_SUITE.erl b/lib/compiler/test/record_SUITE.erl index 9f5d09216e..cc2ea5d20a 100644 --- a/lib/compiler/test/record_SUITE.erl +++ b/lib/compiler/test/record_SUITE.erl @@ -388,7 +388,7 @@ record_test_3(Config) when is_list(Config) -> ok. record_access_in_guards(Config) when is_list(Config) -> - ?line Priv = ?config(priv_dir, Config), + Priv = proplists:get_value(priv_dir, Config), ?line file:set_cwd(test_lib:get_data_dir(Config)), ?line Opts0 = [{outdir,Priv},report_errors|test_lib:opt_opts(?MODULE)], M = record_access_in_guards, diff --git a/lib/compiler/test/regressions_SUITE.erl b/lib/compiler/test/regressions_SUITE.erl index 0131a2bdbd..0e641fcd71 100644 --- a/lib/compiler/test/regressions_SUITE.erl +++ b/lib/compiler/test/regressions_SUITE.erl @@ -70,7 +70,7 @@ run(Config, Tests) -> run_test(Conf, Test0) -> Module = "regressions_"++test_lib:uniq(), Filename = Module ++ ".erl", - DataDir = ?config(priv_dir, Conf), + DataDir = proplists:get_value(priv_dir, Conf), Test = ["-module(", Module, "). ", Test0], File = filename:join(DataDir, Filename), Def = [binary,export_all,return], diff --git a/lib/compiler/test/test_lib.erl b/lib/compiler/test/test_lib.erl index e4b6a2fa9c..5768b67a56 100644 --- a/lib/compiler/test/test_lib.erl +++ b/lib/compiler/test/test_lib.erl @@ -85,7 +85,7 @@ opt_opts(Mod) -> %% This function retrieves the path to the original data directory. get_data_dir(Config) -> - Data0 = ?config(data_dir, Config), + Data0 = proplists:get_value(data_dir, Config), Opts = [{return,list}], Data1 = re:replace(Data0, "_no_opt_SUITE", "_SUITE", Opts), Data = re:replace(Data1, "_post_opt_SUITE", "_SUITE", Opts), diff --git a/lib/compiler/test/warnings_SUITE.erl b/lib/compiler/test/warnings_SUITE.erl index 32cdc4ed94..1d62496044 100644 --- a/lib/compiler/test/warnings_SUITE.erl +++ b/lib/compiler/test/warnings_SUITE.erl @@ -28,8 +28,8 @@ -define(t, test_server). -else. -include_lib("common_test/include/ct.hrl"). --define(datadir, ?config(data_dir, Conf)). --define(privdir, ?config(priv_dir, Conf)). +-define(datadir, proplists:get_value(data_dir, Conf)). +-define(privdir, proplists:get_value(priv_dir, Conf)). -endif. -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, -- cgit v1.2.3