diff options
author | Björn Gustavsson <[email protected]> | 2013-08-20 15:51:25 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2013-08-20 15:51:25 +0200 |
commit | 50cb91788d39a69bac34eba847a6b5439a6568de (patch) | |
tree | bd89dcb59d62a0f2ce77f941097fe6e02f5675a2 | |
parent | 627f658bb7a53cdbfe862ca3aa5d66259bbaead7 (diff) | |
parent | 68cbc7315be2db64622f2cb4a168ad60efb90259 (diff) | |
download | otp-50cb91788d39a69bac34eba847a6b5439a6568de.tar.gz otp-50cb91788d39a69bac34eba847a6b5439a6568de.tar.bz2 otp-50cb91788d39a69bac34eba847a6b5439a6568de.zip |
Merge branch 'maint'
* maint:
erlc_SUITE: Test the -M* options
-rw-r--r-- | erts/test/erlc_SUITE.erl | 83 | ||||
-rw-r--r-- | erts/test/erlc_SUITE_data/src/erl_test_missing_header.erl | 22 |
2 files changed, 102 insertions, 3 deletions
diff --git a/erts/test/erlc_SUITE.erl b/erts/test/erlc_SUITE.erl index ab774dbc4f..ed7a43c7e7 100644 --- a/erts/test/erlc_SUITE.erl +++ b/erts/test/erlc_SUITE.erl @@ -23,7 +23,8 @@ -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, init_per_group/2,end_per_group/2, compile_erl/1, compile_yecc/1, compile_script/1, - compile_mib/1, good_citizen/1, deep_cwd/1, arg_overflow/1]). + compile_mib/1, good_citizen/1, deep_cwd/1, arg_overflow/1, + make_dep_options/1]). -include_lib("test_server/include/test_server.hrl"). @@ -31,7 +32,7 @@ suite() -> [{ct_hooks,[ts_install_cth]}]. all() -> [compile_erl, compile_yecc, compile_script, compile_mib, - good_citizen, deep_cwd, arg_overflow]. + good_citizen, deep_cwd, arg_overflow, make_dep_options]. groups() -> []. @@ -255,13 +256,89 @@ erlc() -> Erlc -> "\"" ++ Erlc ++ "\"" end. - + +make_dep_options(Config) -> + {SrcDir,OutDir,Cmd} = get_cmd(Config), + FileName = filename:join(SrcDir, "erl_test_ok.erl"), + + + DepRE = ["/erl_test_ok[.]beam: \\\\$", + "/system_test/erlc_SUITE_data/src/erl_test_ok[.]erl \\\\$", + "/system_test/erlc_SUITE_data/include/erl_test[.]hrl$", + "_OK_"], + + DepRETarget = + ["^target: \\\\$", + "/system_test/erlc_SUITE_data/src/erl_test_ok[.]erl \\\\$", + "/system_test/erlc_SUITE_data/include/erl_test[.]hrl$", + "_OK_"], + + DepREMP = + ["/erl_test_ok[.]beam: \\\\$", + "/system_test/erlc_SUITE_data/src/erl_test_ok[.]erl \\\\$", + "/system_test/erlc_SUITE_data/include/erl_test[.]hrl$", + [], + "/system_test/erlc_SUITE_data/include/erl_test.hrl:$", + "_OK_"], + + DepREMissing = + ["/erl_test_missing_header[.]beam: \\\\$", + "/system_test/erlc_SUITE_data/src/erl_test_missing_header[.]erl \\\\$", + "/system_test/erlc_SUITE_data/include/erl_test[.]hrl \\\\$", + "missing.hrl$", + "_OK_"], + + %% Test plain -M + run(Config, Cmd, FileName, "-M", DepRE), + + %% Test -MF File + DepFile = filename:join(OutDir, "my.deps"), + run(Config, Cmd, FileName, "-MF "++DepFile, ["_OK_"]), + {ok,MFBin} = file:read_file(DepFile), + verify_result(binary_to_list(MFBin)++["_OK_"], DepRE), + + %% Test -MD + run(Config, Cmd, FileName, "-MD", ["_OK_"]), + MDFile = filename:join(OutDir, "erl_test_ok.Pbeam"), + {ok,MFBin} = file:read_file(MDFile), + + %% Test -M -MT Target + run(Config, Cmd, FileName, "-M -MT target", DepRETarget), + + %% Test -MF File -MT Target + TargetDepFile = filename:join(OutDir, "target.deps"), + run(Config, Cmd, FileName, "-MF "++TargetDepFile++" -MT target", + ["_OK_"]), + {ok,TargetBin} = file:read_file(TargetDepFile), + verify_result(binary_to_list(TargetBin)++["_OK_"], DepRETarget), + + %% Test -MD -MT Target + run(Config, Cmd, FileName, "-MD -MT target", ["_OK_"]), + TargetMDFile = filename:join(OutDir, "erl_test_ok.Pbeam"), + {ok,TargetBin} = file:read_file(TargetMDFile), + + %% Test -M -MQ Target. (Note: Passing a $ on the command line + %% portably for Unix and Windows is tricky, so we will just test + %% that MQ works at all.) + run(Config, Cmd, FileName, "-M -MQ target", DepRETarget), + + %% Test -M -MP + run(Config, Cmd, FileName, "-M -MP", DepREMP), + + %% Test -M -MG + MissingHeader = filename:join(SrcDir, "erl_test_missing_header.erl"), + run(Config, Cmd, MissingHeader, "-M -MG", DepREMissing), + ok. + %% Runs a command. run(Config, Cmd0, Name, Options, Expect) -> Cmd = Cmd0 ++ " " ++ Options ++ " " ++ Name, io:format("~s", [Cmd]), Result = run_command(Config, Cmd), + verify_result(Result, Expect). + +verify_result(Result, Expect) -> Messages = split(Result, [], []), io:format("Result: ~p", [Messages]), io:format("Expected: ~p", [Expect]), diff --git a/erts/test/erlc_SUITE_data/src/erl_test_missing_header.erl b/erts/test/erlc_SUITE_data/src/erl_test_missing_header.erl new file mode 100644 index 0000000000..4d6c42c803 --- /dev/null +++ b/erts/test/erlc_SUITE_data/src/erl_test_missing_header.erl @@ -0,0 +1,22 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2013. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% + +-module(erl_test_missing_header). +-include("erl_test.hrl"). +-include("missing.hrl"). |