From 146dfa9ddc3b31649ef581d65f3cb00ef95af10f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Wed, 6 Apr 2016 18:30:53 +0200 Subject: Remove ?line macros --- lib/tools/test/make_SUITE.erl | 195 +++++++++++++++++++++--------------------- 1 file changed, 97 insertions(+), 98 deletions(-) (limited to 'lib/tools/test/make_SUITE.erl') diff --git a/lib/tools/test/make_SUITE.erl b/lib/tools/test/make_SUITE.erl index fdcc310df1..7580f77568 100644 --- a/lib/tools/test/make_SUITE.erl +++ b/lib/tools/test/make_SUITE.erl @@ -20,10 +20,10 @@ -module(make_SUITE). -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, - init_per_group/2,end_per_group/2, make_all/1, make_files/1]). + init_per_group/2,end_per_group/2, make_all/1, make_files/1]). -export([otp_6057_init/1, - otp_6057_a/1, otp_6057_b/1, otp_6057_c/1, - otp_6057_end/1]). + otp_6057_a/1, otp_6057_b/1, otp_6057_c/1, + otp_6057_end/1]). -include_lib("common_test/include/ct.hrl"). @@ -44,7 +44,7 @@ all() -> groups() -> [{otp_6057,[],[otp_6057_a, otp_6057_b, - otp_6057_c]}]. + otp_6057_c]}]. init_per_suite(Config) -> Config. @@ -63,50 +63,50 @@ test_files() -> ["test1", "test2", "test3", "test4"]. make_all(suite) -> []; make_all(Config) when is_list(Config) -> - ?line Current = prepare_data_dir(Config), - ?line up_to_date = make:all(), - ?line ok = ensure_exists(test_files()), - ?line ok = ensure_exists(["test5"],".S"), % Emakefile: [{test5,['S']} - ?line file:set_cwd(Current), - ?line ensure_no_messages(), + Current = prepare_data_dir(Config), + up_to_date = make:all(), + ok = ensure_exists(test_files()), + ok = ensure_exists(["test5"],".S"), % Emakefile: [{test5,['S']} + file:set_cwd(Current), + ensure_no_messages(), ok. make_files(suite) -> []; make_files(Config) when is_list(Config) -> - ?line Current = prepare_data_dir(Config), + Current = prepare_data_dir(Config), %% Make files that exist. - ?line Files = [test1, test2], - ?line up_to_date = make:files(Files), % ok files - ?line ok = ensure_exists(Files), + Files = [test1, test2], + up_to_date = make:files(Files), % ok files + ok = ensure_exists(Files), - ?line error = make:files([test1,test7]), % non existing file - ?line up_to_date = make:files([test1,test2],[debug_info]), % with option + error = make:files([test1,test7]), % non existing file + up_to_date = make:files([test1,test2],[debug_info]), % with option - ?line file:set_cwd(Current), - ?line ensure_no_messages(), + file:set_cwd(Current), + ensure_no_messages(), ok. %% Moves to the data directory of this suite, clean it from any object %% files (*.jam for a JAM emulator). Returns the previous directory. prepare_data_dir(Config) -> - ?line {ok, Current} = file:get_cwd(), - ?line {value, {data_dir, Dir}} = lists:keysearch(data_dir, 1, Config), - ?line file:set_cwd(Dir), - ?line {ok, Files} = file:list_dir("."), - ?line delete_obj(Files, code:objfile_extension()), - ?line ensure_no_messages(), + {ok, Current} = file:get_cwd(), + {value, {data_dir, Dir}} = lists:keysearch(data_dir, 1, Config), + file:set_cwd(Dir), + {ok, Files} = file:list_dir("."), + delete_obj(Files, code:objfile_extension()), + ensure_no_messages(), Current. delete_obj([File|Rest], ObjExt) -> - ?line case filename:extension(File) of - ObjExt -> file:delete(File); - ".S" -> file:delete(File); - _ -> ok - end, - ?line delete_obj(Rest, ObjExt); + case filename:extension(File) of + ObjExt -> file:delete(File); + ".S" -> file:delete(File); + _ -> ok + end, + delete_obj(Rest, ObjExt); delete_obj([], _) -> ok. @@ -120,26 +120,26 @@ ensure_exists([Name|Rest], ObjExt) when is_atom(Name) -> ensure_exists([atom_to_list(Name)|Rest], ObjExt); ensure_exists([Name|Rest], ObjExt) -> case filelib:is_regular(Name++ObjExt) of - true -> - ensure_exists(Rest, ObjExt); - false -> - Name++ObjExt + true -> + ensure_exists(Rest, ObjExt); + false -> + Name++ObjExt end; ensure_exists([], _) -> ok. otp_6057_init(Config) when is_list(Config) -> - ?line DataDir = ?config(data_dir, Config), - ?line PrivDir = ?config(priv_dir, Config), + DataDir = ?config(data_dir, Config), + PrivDir = ?config(priv_dir, Config), %% Create the directories PrivDir/otp_6057/src1, /src2 and /ebin Src1 = filename:join([PrivDir, otp_6057, src1]), Src2 = filename:join([PrivDir, otp_6057, src2]), Ebin = filename:join([PrivDir, otp_6057, ebin]), - ?line ok = file:make_dir(filename:join(PrivDir, otp_6057)), - ?line ok = file:make_dir(Src1), - ?line ok = file:make_dir(Src2), - ?line ok = file:make_dir(Ebin), + ok = file:make_dir(filename:join(PrivDir, otp_6057)), + ok = file:make_dir(Src1), + ok = file:make_dir(Src2), + ok = file:make_dir(Ebin), %% Copy test1.erl and test2.erl to src1, and test3.erl to src2 Test1orig = filename:join(DataDir, "test1.erl"), @@ -148,19 +148,19 @@ otp_6057_init(Config) when is_list(Config) -> Test1 = filename:join(Src1, "test1.erl"), Test2 = filename:join(Src1, "test2.erl"), Test3 = filename:join(Src2, "test3.erl"), - ?line {ok, _} = file:copy(Test1orig, Test1), - ?line {ok, _} = file:copy(Test2orig, Test2), - ?line {ok, _} = file:copy(Test3orig, Test3), + {ok, _} = file:copy(Test1orig, Test1), + {ok, _} = file:copy(Test2orig, Test2), + {ok, _} = file:copy(Test3orig, Test3), %% Create an Emakefile in src1 Emakefile = filename:join(Src1, "Emakefile"), - ?line {ok, Fd} = file:open(Emakefile, write), - ?line ok = io:write(Fd, {["test1.erl","test2","../src2/test3"], - [{outdir,"../ebin"}]}), - ?line ok = io:fwrite(Fd, ".~n", []), - ?line ok = file:close(Fd), + {ok, Fd} = file:open(Emakefile, write), + ok = io:write(Fd, {["test1.erl","test2","../src2/test3"], + [{outdir,"../ebin"}]}), + ok = io:fwrite(Fd, ".~n", []), + ok = file:close(Fd), - ?line ensure_no_messages(), + ensure_no_messages(), Config. otp_6057_a(suite) -> @@ -168,15 +168,15 @@ otp_6057_a(suite) -> otp_6057_a(doc) -> ["Test that make:all/0, suite/0 looks for object file in correct place"]; otp_6057_a(Config) when is_list(Config) -> - ?line PrivDir = ?config(priv_dir, Config), + PrivDir = ?config(priv_dir, Config), %% Go to src1, saving old CWD - ?line {ok, CWD} = file:get_cwd(), + {ok, CWD} = file:get_cwd(), Src1 = filename:join([PrivDir, otp_6057, src1]), - ?line ok = file:set_cwd(Src1), + ok = file:set_cwd(Src1), %% Call make:all() - ?line up_to_date = make:all(), + up_to_date = make:all(), %% Ensure that all beam files are created in the ebin directory Ebin = filename:join([PrivDir, otp_6057, ebin]), @@ -184,34 +184,34 @@ otp_6057_a(Config) when is_list(Config) -> Test2 = filename:join(Ebin, test2), Test3 = filename:join(Ebin, test3), case ensure_exists([Test1, Test2, Test3]) of - ok -> ok; - Missing -> - ?line ?t:fail({"missing beam file", Missing}) + ok -> ok; + Missing -> + ?t:fail({"missing beam file", Missing}) end, %% Check creation date of test1.beam and make sure it is not %% recompiled if make:all() is called again. %% (Sleep a while, if the file is recompiled within a second then %% mtime will be the same). - ?line {ok, FileInfo1} = file:read_file_info(Test1++".beam"), + {ok, FileInfo1} = file:read_file_info(Test1++".beam"), Date1 = FileInfo1#file_info.mtime, ?t:sleep(?t:seconds(2)), - ?line up_to_date = make:all(), - ?line {ok, FileInfo2} = file:read_file_info(Test1++".beam"), + up_to_date = make:all(), + {ok, FileInfo2} = file:read_file_info(Test1++".beam"), case FileInfo2#file_info.mtime of - Date1 -> ok; - _Date2 -> - ?line ?t:fail({"recompiled beam file", Test1++".beam"}) + Date1 -> ok; + _Date2 -> + ?t:fail({"recompiled beam file", Test1++".beam"}) end, %% Remove the beam files - ?line ok = - ensure_removed([Test1++".beam",Test2++".beam",Test2++".beam"]), + ok = + ensure_removed([Test1++".beam",Test2++".beam",Test2++".beam"]), %% Return to original CWD - ?line ok = file:set_cwd(CWD), + ok = file:set_cwd(CWD), - ?line ensure_no_messages(), + ensure_no_messages(), ok. otp_6057_b(suite) -> @@ -219,35 +219,35 @@ otp_6057_b(suite) -> otp_6057_b(doc) -> ["Test that make:files/1 can handle a file in another directory"]; otp_6057_b(Config) when is_list(Config) -> - ?line PrivDir = ?config(priv_dir, Config), + PrivDir = ?config(priv_dir, Config), %% Go to src1, saving old CWD - ?line {ok, CWD} = file:get_cwd(), + {ok, CWD} = file:get_cwd(), Src1 = filename:join([PrivDir, otp_6057, src1]), - ?line ok = file:set_cwd(Src1), + ok = file:set_cwd(Src1), %% Ensure there is no beam file already Ebin = filename:join([PrivDir, otp_6057, ebin]), Test3 = filename:join(Ebin, "test3"), - ?line ok = ensure_removed([Test3++".beam"]), + ok = ensure_removed([Test3++".beam"]), %% Call make:files/1 - ?line up_to_date = make:files(["../src2/test3"]), - + up_to_date = make:files(["../src2/test3"]), + %% Ensure that the beam file is created in the ebin directory case ensure_exists([Test3]) of - ok -> ok; - Missing -> - ?line ?t:fail({"missing beam file", Missing}) + ok -> ok; + Missing -> + ?t:fail({"missing beam file", Missing}) end, %% Remove the beam file - ?line ok = ensure_removed([Test3++".beam"]), + ok = ensure_removed([Test3++".beam"]), %% Return to original CWD - ?line ok = file:set_cwd(CWD), + ok = file:set_cwd(CWD), - ?line ensure_no_messages(), + ensure_no_messages(), ok. otp_6057_c(suite) -> @@ -256,37 +256,37 @@ otp_6057_c(doc) -> ["Test that make:files/1 find options in Emakefile if a file is " "given with the .erl extension there"]; otp_6057_c(Config) when is_list(Config) -> - ?line PrivDir = ?config(priv_dir, Config), + PrivDir = ?config(priv_dir, Config), %% Go to src1, saving old CWD - ?line {ok, CWD} = file:get_cwd(), + {ok, CWD} = file:get_cwd(), Src1 = filename:join([PrivDir, otp_6057, src1]), - ?line ok = file:set_cwd(Src1), + ok = file:set_cwd(Src1), %% Ensure there are no beam files already Ebin = filename:join([PrivDir, otp_6057, ebin]), Test1 = filename:join(Ebin, "test1"), Test2 = filename:join(Ebin, "test2"), - ?line ok = ensure_removed([Test1++".beam",Test2++".beam"]), + ok = ensure_removed([Test1++".beam",Test2++".beam"]), %% Call make:files/1 - ?line up_to_date = make:files([test1, test2]), - + up_to_date = make:files([test1, test2]), + %% Ensure that the beam files are created in the ebin directory Ebin = filename:join([PrivDir, otp_6057, ebin]), case ensure_exists([Test1, Test2]) of - ok -> ok; - Missing -> - ?line ?t:fail({"missing beam file", Missing}) + ok -> ok; + Missing -> + ?t:fail({"missing beam file", Missing}) end, %% Remove the beam files - ?line ok = ensure_removed([Test1++".beam", Test2++".beam"]), + ok = ensure_removed([Test1++".beam", Test2++".beam"]), %% Return to original CWD - ?line ok = file:set_cwd(CWD), + ok = file:set_cwd(CWD), - ?line ensure_no_messages(), + ensure_no_messages(), ok. otp_6057_end(Config) when is_list(Config) -> @@ -303,13 +303,12 @@ ensure_no_messages() -> ensure_no_messages(N) -> receive - Any -> - io:format("Unexpected message: ~p", [Any]), - ensure_no_messages(N+1) + Any -> + io:format("Unexpected message: ~p", [Any]), + ensure_no_messages(N+1) after 0 -> - case N of - 0 -> ok; - N -> ?t:fail() - end + case N of + 0 -> ok; + N -> ?t:fail() + end end. - -- cgit v1.2.3 From 8ccea1c2c756d8bc548ee6ba3e10f5a583aca7e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Wed, 6 Apr 2016 19:46:34 +0200 Subject: Modernize use of timetraps --- lib/tools/test/make_SUITE.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/tools/test/make_SUITE.erl') diff --git a/lib/tools/test/make_SUITE.erl b/lib/tools/test/make_SUITE.erl index 7580f77568..5e3b3772fc 100644 --- a/lib/tools/test/make_SUITE.erl +++ b/lib/tools/test/make_SUITE.erl @@ -195,7 +195,7 @@ otp_6057_a(Config) when is_list(Config) -> %% mtime will be the same). {ok, FileInfo1} = file:read_file_info(Test1++".beam"), Date1 = FileInfo1#file_info.mtime, - ?t:sleep(?t:seconds(2)), + timer:sleep(2000), up_to_date = make:all(), {ok, FileInfo2} = file:read_file_info(Test1++".beam"), case FileInfo2#file_info.mtime of -- cgit v1.2.3 From c9f6f5b9c20ada3dfa1e682cf49c09e3311db248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Wed, 6 Apr 2016 20:18:57 +0200 Subject: Eliminate use of test_server:fail/0,1 --- lib/tools/test/make_SUITE.erl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/tools/test/make_SUITE.erl') diff --git a/lib/tools/test/make_SUITE.erl b/lib/tools/test/make_SUITE.erl index 5e3b3772fc..c277d8c9ce 100644 --- a/lib/tools/test/make_SUITE.erl +++ b/lib/tools/test/make_SUITE.erl @@ -186,7 +186,7 @@ otp_6057_a(Config) when is_list(Config) -> case ensure_exists([Test1, Test2, Test3]) of ok -> ok; Missing -> - ?t:fail({"missing beam file", Missing}) + ct:fail({"missing beam file", Missing}) end, %% Check creation date of test1.beam and make sure it is not @@ -201,7 +201,7 @@ otp_6057_a(Config) when is_list(Config) -> case FileInfo2#file_info.mtime of Date1 -> ok; _Date2 -> - ?t:fail({"recompiled beam file", Test1++".beam"}) + ct:fail({"recompiled beam file", Test1++".beam"}) end, %% Remove the beam files @@ -238,7 +238,7 @@ otp_6057_b(Config) when is_list(Config) -> case ensure_exists([Test3]) of ok -> ok; Missing -> - ?t:fail({"missing beam file", Missing}) + ct:fail({"missing beam file", Missing}) end, %% Remove the beam file @@ -277,7 +277,7 @@ otp_6057_c(Config) when is_list(Config) -> case ensure_exists([Test1, Test2]) of ok -> ok; Missing -> - ?t:fail({"missing beam file", Missing}) + ct:fail({"missing beam file", Missing}) end, %% Remove the beam files @@ -309,6 +309,6 @@ ensure_no_messages(N) -> after 0 -> case N of 0 -> ok; - N -> ?t:fail() + N -> ct:fail(failed) end end. -- cgit v1.2.3 From d6dfdeb9fd9ccf985840fa6e5e5e44f6c5fa644b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Thu, 7 Apr 2016 12:19:05 +0200 Subject: Eliminate use of ?config() macro --- lib/tools/test/make_SUITE.erl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/tools/test/make_SUITE.erl') diff --git a/lib/tools/test/make_SUITE.erl b/lib/tools/test/make_SUITE.erl index c277d8c9ce..9c6141528e 100644 --- a/lib/tools/test/make_SUITE.erl +++ b/lib/tools/test/make_SUITE.erl @@ -129,8 +129,8 @@ ensure_exists([], _) -> ok. otp_6057_init(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), %% Create the directories PrivDir/otp_6057/src1, /src2 and /ebin Src1 = filename:join([PrivDir, otp_6057, src1]), @@ -168,7 +168,7 @@ otp_6057_a(suite) -> otp_6057_a(doc) -> ["Test that make:all/0, suite/0 looks for object file in correct place"]; otp_6057_a(Config) when is_list(Config) -> - PrivDir = ?config(priv_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), %% Go to src1, saving old CWD {ok, CWD} = file:get_cwd(), @@ -219,7 +219,7 @@ otp_6057_b(suite) -> otp_6057_b(doc) -> ["Test that make:files/1 can handle a file in another directory"]; otp_6057_b(Config) when is_list(Config) -> - PrivDir = ?config(priv_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), %% Go to src1, saving old CWD {ok, CWD} = file:get_cwd(), @@ -256,7 +256,7 @@ otp_6057_c(doc) -> ["Test that make:files/1 find options in Emakefile if a file is " "given with the .erl extension there"]; otp_6057_c(Config) when is_list(Config) -> - PrivDir = ?config(priv_dir, Config), + PrivDir = proplists:get_value(priv_dir, Config), %% Go to src1, saving old CWD {ok, CWD} = file:get_cwd(), -- cgit v1.2.3 From e660be75fdaa3d7e98da94194063494ac92ab807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Thu, 7 Apr 2016 16:20:53 +0200 Subject: Eliminate use of doc and suite clauses Those clause are obsolete and never used by common_test. --- lib/tools/test/make_SUITE.erl | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'lib/tools/test/make_SUITE.erl') diff --git a/lib/tools/test/make_SUITE.erl b/lib/tools/test/make_SUITE.erl index 9c6141528e..df6d9a8d72 100644 --- a/lib/tools/test/make_SUITE.erl +++ b/lib/tools/test/make_SUITE.erl @@ -61,7 +61,6 @@ end_per_group(_GroupName, Config) -> test_files() -> ["test1", "test2", "test3", "test4"]. -make_all(suite) -> []; make_all(Config) when is_list(Config) -> Current = prepare_data_dir(Config), up_to_date = make:all(), @@ -71,7 +70,6 @@ make_all(Config) when is_list(Config) -> ensure_no_messages(), ok. -make_files(suite) -> []; make_files(Config) when is_list(Config) -> Current = prepare_data_dir(Config), @@ -163,10 +161,7 @@ otp_6057_init(Config) when is_list(Config) -> ensure_no_messages(), Config. -otp_6057_a(suite) -> - []; -otp_6057_a(doc) -> - ["Test that make:all/0, suite/0 looks for object file in correct place"]; +%% Test that make:all/0, suite/0 looks for object file in correct place otp_6057_a(Config) when is_list(Config) -> PrivDir = proplists:get_value(priv_dir, Config), @@ -214,10 +209,7 @@ otp_6057_a(Config) when is_list(Config) -> ensure_no_messages(), ok. -otp_6057_b(suite) -> - []; -otp_6057_b(doc) -> - ["Test that make:files/1 can handle a file in another directory"]; +%% Test that make:files/1 can handle a file in another directory otp_6057_b(Config) when is_list(Config) -> PrivDir = proplists:get_value(priv_dir, Config), @@ -250,11 +242,8 @@ otp_6057_b(Config) when is_list(Config) -> ensure_no_messages(), ok. -otp_6057_c(suite) -> - []; -otp_6057_c(doc) -> - ["Test that make:files/1 find options in Emakefile if a file is " - "given with the .erl extension there"]; +%% Test that make:files/1 find options in Emakefile if a file is +%% given with the .erl extension there otp_6057_c(Config) when is_list(Config) -> PrivDir = proplists:get_value(priv_dir, Config), -- cgit v1.2.3