diff options
author | Björn Gustavsson <[email protected]> | 2016-03-10 09:57:37 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2016-03-10 09:57:37 +0100 |
commit | e42208ce5d5e76056f9c199d52512275c98b50c1 (patch) | |
tree | 016d43ebe0fa7f0fb7dd2bcab9398dc418a4b665 /lib/stdlib/test/c_SUITE.erl | |
parent | 104cca3be8852070cb3c6d5b12ea74fe1591ba9b (diff) | |
parent | 25e64aaf1df1ea5c712075a9236367de4cc81359 (diff) | |
download | otp-e42208ce5d5e76056f9c199d52512275c98b50c1.tar.gz otp-e42208ce5d5e76056f9c199d52512275c98b50c1.tar.bz2 otp-e42208ce5d5e76056f9c199d52512275c98b50c1.zip |
Merge branch 'bjorn/stdlib/modernize-tests'
* bjorn/stdlib/modernize-tests:
Eliminate use of ?config() macro
Remove ?line macros
Replace "%" with "%%" at the beginning of a line
Eliminate 'suite' and 'doc' clauses
gen_server_SUITE: Eliminate use of test_server:timecall/3
Use 'test_server' instead of ?t macro
Eliminate use of test_server:messages_get/0
sys_SUITE: Replace test_server:capture*/0 with ct:capture*/0
sys_SUITE: Mend test cases that didn't test what they should
Replace calls to test_server:sleep/1 with ct:sleep/1 or timer:sleep/1
Eliminate use of test_server:do_times()
Replace use of test_server:format/2 with io:format/2
Eliminate use of test_server:fail/0,1
Modernize use of timetraps
Diffstat (limited to 'lib/stdlib/test/c_SUITE.erl')
-rw-r--r-- | lib/stdlib/test/c_SUITE.erl | 181 |
1 files changed, 77 insertions, 104 deletions
diff --git a/lib/stdlib/test/c_SUITE.erl b/lib/stdlib/test/c_SUITE.erl index 47dd95f86b..266918581b 100644 --- a/lib/stdlib/test/c_SUITE.erl +++ b/lib/stdlib/test/c_SUITE.erl @@ -50,144 +50,117 @@ end_per_group(_GroupName, Config) -> %%% Write output to a directory other than current directory: -c_1(doc) -> - ["Checks that c:c works also with option 'outdir' [ticket OTP-1209]."]; -c_1(suite) -> - []; +%% OTP-1209: Check that c:c/2 works also with option 'outdir'. c_1(Config) when is_list(Config) -> - ?line R = filename:join(?config(data_dir, Config), "m.erl"), - ?line W = ?config(priv_dir, Config), - ?line Result = c(R,[{outdir,W}]), - ?line {ok, m} = Result. - -c_2(doc) -> - ["Checks that c:c works also with option 'outdir' [ticket OTP-1209]."]; -c_2(suite) -> - []; + R = filename:join(proplists:get_value(data_dir, Config), "m.erl"), + W = proplists:get_value(priv_dir, Config), + Result = c(R,[{outdir,W}]), + {ok, m} = Result. + +%% OTP-1209: Check that c:c/2 works also with option 'outdir'. c_2(Config) when is_list(Config) -> - ?line R = filename:join(?config(data_dir, Config), "m"), - ?line W = ?config(priv_dir, Config), - ?line Result = c(R,[{outdir,W}]), - ?line {ok, m} = Result. + R = filename:join(proplists:get_value(data_dir, Config), "m"), + W = proplists:get_value(priv_dir, Config), + Result = c(R,[{outdir,W}]), + {ok, m} = Result. %%% Put results in current directory (or rather, change current dir %%% to the output dir): -c_3(doc) -> - ["Checks that c:c works also with option 'outdir' (same as current" - "directory). [ticket OTP-1209]."]; -c_3(suite) -> - []; +%% OTP-1209: Check that c:c/2 works also with option 'outdir' +%% (same as current directory). c_3(Config) when is_list(Config) -> - ?line R = filename:join(?config(data_dir, Config), "m.erl"), - ?line W = ?config(priv_dir, Config), - ?line file:set_cwd(W), - ?line Result = c(R,[{outdir,W}]), - ?line {ok, m} = Result. - -c_4(doc) -> - ["Checks that c:c works also with option 'outdir' (same as current" - "directory). [ticket OTP-1209]."]; -c_4(suite) -> - []; + R = filename:join(proplists:get_value(data_dir, Config), "m.erl"), + W = proplists:get_value(priv_dir, Config), + file:set_cwd(W), + Result = c(R,[{outdir,W}]), + {ok, m} = Result. + +%% OTP-1209: Check that c:c/2 works also with option 'outdir' +%% (same as current directory). c_4(Config) when is_list(Config) -> - ?line R = filename:join(?config(data_dir, Config), "m"), - ?line W = ?config(priv_dir, Config), - ?line file:set_cwd(W), - ?line Result = c(R,[{outdir,W}]), - ?line {ok, m} = Result. + R = filename:join(proplists:get_value(data_dir, Config), "m"), + W = proplists:get_value(priv_dir, Config), + file:set_cwd(W), + Result = c(R,[{outdir,W}]), + {ok, m} = Result. %%% Write output to a directory other than current directory: -nc_1(doc) -> - ["Checks that c:nc works also with option 'outdir'."]; -nc_1(suite) -> - []; +%% Check that c:nc/2 works also with option 'outdir'. nc_1(Config) when is_list(Config) -> - ?line R = filename:join(?config(data_dir, Config), "m.erl"), - ?line W = ?config(priv_dir, Config), - ?line Result = nc(R,[{outdir,W}]), - ?line {ok, m} = Result. - -nc_2(doc) -> - ["Checks that c:nc works also with option 'outdir'."]; -nc_2(suite) -> - []; + R = filename:join(proplists:get_value(data_dir, Config), "m.erl"), + W = proplists:get_value(priv_dir, Config), + Result = nc(R,[{outdir,W}]), + {ok, m} = Result. + +%% Check that c:nc/2 works also with option 'outdir'. nc_2(Config) when is_list(Config) -> - ?line R = filename:join(?config(data_dir, Config), "m"), - ?line W = ?config(priv_dir, Config), - ?line Result = nc(R,[{outdir,W}]), - ?line {ok, m} = Result. + R = filename:join(proplists:get_value(data_dir, Config), "m"), + W = proplists:get_value(priv_dir, Config), + Result = nc(R,[{outdir,W}]), + {ok, m} = Result. %%% Put results in current directory (or rather, change current dir %%% to the output dir): -nc_3(doc) -> - ["Checks that c:nc works also with option 'outdir' (same as current" - "directory)."]; -nc_3(suite) -> - []; +%% Check that c:nc/2 works also with option 'outdir' +%% (same as current directory). nc_3(Config) when is_list(Config) -> - ?line R = filename:join(?config(data_dir, Config), "m.erl"), - ?line W = ?config(priv_dir, Config), - ?line file:set_cwd(W), - ?line Result = nc(R,[{outdir,W}]), - ?line {ok, m} = Result. - -nc_4(doc) -> - ["Checks that c:nc works also with option 'outdir' (same as current" - "directory)."]; -nc_4(suite) -> - []; + R = filename:join(proplists:get_value(data_dir, Config), "m.erl"), + W = proplists:get_value(priv_dir, Config), + file:set_cwd(W), + Result = nc(R,[{outdir,W}]), + {ok, m} = Result. + +%% Check that c:nc/2 works also with option 'outdir' +%% (same as current directory). nc_4(Config) when is_list(Config) -> - ?line R = filename:join(?config(data_dir, Config), "m"), - ?line W = ?config(priv_dir, Config), - ?line file:set_cwd(W), - ?line Result = nc(R,[{outdir,W}]), - ?line {ok, m} = Result. + R = filename:join(proplists:get_value(data_dir, Config), "m"), + W = proplists:get_value(priv_dir, Config), + file:set_cwd(W), + Result = nc(R,[{outdir,W}]), + {ok, m} = Result. ls(Config) when is_list(Config) -> - Directory = ?config(data_dir, Config), + Directory = proplists:get_value(data_dir, Config), ok = c:ls(Directory), File = filename:join(Directory, "m.erl"), ok = c:ls(File), ok = c:ls("no_such_file"). -memory(doc) -> - ["Checks that c:memory/[0,1] returns consistent results."]; -memory(suite) -> - []; +%% Check that c:memory/[0,1] returns consistent results. memory(Config) when is_list(Config) -> try - ?line ML = c:memory(), - ?line T = mget(total, ML), - ?line P = mget(processes, ML), - ?line S = mget(system, ML), - ?line A = mget(atom, ML), - ?line AU = mget(atom_used, ML), - ?line B = mget(binary, ML), - ?line C = mget(code, ML), - ?line E = mget(ets, ML), - ?line T = P + S, - ?line if S >= A + B + C + E -> ok end, - ?line if A >= AU -> ok end, - ?line ok + ML = c:memory(), + T = mget(total, ML), + P = mget(processes, ML), + S = mget(system, ML), + A = mget(atom, ML), + AU = mget(atom_used, ML), + B = mget(binary, ML), + C = mget(code, ML), + E = mget(ets, ML), + T = P + S, + if S >= A + B + C + E -> ok end, + if A >= AU -> ok end, + ok catch error:notsup -> - ?line {skipped, - "erlang:memory/[0,1] and c:memory/[0,1] not supported"} + {skipped, + "erlang:memory/[0,1] and c:memory/[0,1] not supported"} end. -% Help function for c_SUITE:memory/1 +%% Help function for c_SUITE:memory/1 mget(K, L) -> - ?line {value,{K,V}} = lists:keysearch(K, 1, L), - ?line test_v(c:memory(K)), % Check that c:memory/1 also accept this - % argument and returns an integer (usally - % *not* the same as V). - ?line test_v(V). + {value,{K,V}} = lists:keysearch(K, 1, L), + test_v(c:memory(K)), % Check that c:memory/1 also accept this + % argument and returns an integer (usally + % *not* the same as V). + test_v(V). -% Help function for c_SUITE:memory/1 +%% Help function for c_SUITE:memory/1 test_v(V) when is_integer(V) -> - ?line V. + V. |