~statik/ubuntu/maverick/erlang/erlang-merge-testing

« back to all changes in this revision

Viewing changes to lib/et/test/ett.erl

  • Committer: Elliot Murphy
  • Date: 2010-06-08 03:55:44 UTC
  • mfrom: (3.5.6 squeeze)
  • Revision ID: elliot@elliotmurphy.com-20100608035544-dd8zh2swk7jr5rz2
* Merge with Debian unstable; remaining Ubuntu changes:
  - Drop libwxgtk2.8-dev build dependency. Wx isn't in main, and not
    supposed to. (LP #438365)
  - Drop erlang-wx binary.
  - Drop erlang-wx dependency from -megaco, -common-test, and -reltool, they
    do not really need wx. Also drop it from -debugger; the GUI needs wx,
    but it apparently has CLI bits as well, and is also needed by -megaco,
    so let's keep the package for now.
* Added missing symlinks to /usr/include for a few new header files.
* Fixed generation of ${erlang-base:Depends} and ${erlang-x11:Depends}
  substitution variables.
* Added a fix for a re:compile/2 crash on a long regular expression.
* Changed urgency to medium as the change fixes a security bug.
* Manpages in section 1 are needed even if only arch-dependent packages are
  built. So, re-enabled them.
* Fixed HiPE architecture recognition for powerpc Debian architecture.
* Moved xsltproc and fop to build-depends-indep and do not build
  documentation if only architecture-specific packages are built.
* Refreshed all patches.
* Made Emacs look in man5 and man7 for Erlang manpages and added code
  skeleton files to erlang-mode package.
* New upstream release.
* Moved manpages from incorrect sections 4 and 6 to correct 5 and 7
  (closes: #498492).
* Made manpages regexp in Emacs mode match only 3erl pages in section 3.
* Removed docb_gen script which is no longer needed to build manpages.
* Added erlang-doc package which contains documentation in HTML and PDF
  formats. This package replaces erlang-doc-html package and it's easier
  to synchronize it with the main Erlang packages as it's built from
  a single source package (closes: #558451).
* Removed RPATH from ssl and crypto application binaries as required by
  Debian policy.
* Added libwxgtk2.4-dev and libwxgtk2.6-dev to build conflicts.
* Added a few dpendencies for erlang-dialyzer, erlang-et, erlang-observer
  and erlang-examples packages which now call functions from more modules
  than in 1:13.b.3.
* Added a workaround which disables vfork() for hppa architecture
  (closes: #562218).
* Strictened check for JDK 1.5 adding a call to String(int[], int, int)
  because GCJ 4.4 doesn't implement it and OpenJDK isn't available for all
  architectures.
* Fixed erlang-manpages package section.
* Made erlang-depends add only substvars which are requested in
  debian/control file. This minimizes number of warnings from dh_gencontrol.
  Also, improved descriptions of the functions in erlang-depends escript.
* Added erlang-erl-docgen package to erlang-nox dependencies.
* Made dummy packages erlang-nox and erlang-x11 architecture all.
* Cleaned up working with custom substitution variables in debian/rules.
* Reorganized debian/rules to ensure that manpages arent built twice, and
  aren't built at all if only architecture-dependent packages are requested.
* Fixed project links in README.Debian.
* Added a new package erlang-jinterface which provides tools for
  communication of Java programs with Erlang processes. This adds build
  depandency on default-jdk and as a result enables Java module for IDL
  compiler.
* Bumped standards version to 3.8.4.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%%
 
2
%% %CopyrightBegin%
 
3
%%
 
4
%% Copyright Ericsson AB 2009-2010. All Rights Reserved.
 
5
%%
 
6
%% The contents of this file are subject to the Erlang Public License,
 
7
%% Version 1.1, (the "License"); you may not use this file except in
 
8
%% compliance with the License. You should have received a copy of the
 
9
%% Erlang Public License along with this software. If not, it can be
 
10
%% retrieved online at http://www.erlang.org/.
 
11
%%
 
12
%% Software distributed under the License is distributed on an "AS IS"
 
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 
14
%% the License for the specific language governing rights and limitations
 
15
%% under the License.
 
16
%%
 
17
%% %CopyrightEnd%
 
18
 
 
19
-module(ett).
 
20
-compile(export_all).
 
21
 
 
22
%%  Modules or suites can be shortcuts, for example wx expands to et_wx_SUITE.
 
23
%%  
 
24
%%  t(Tests) run et testcases.
 
25
%%    Tests can be module, {module, test_case} or [module|{module,test_case}]
 
26
 
 
27
t() ->
 
28
    t(read_test_case()).
 
29
t(Test) ->
 
30
    t(Test, []).
 
31
 
 
32
t(Mod, TC) when is_atom(Mod), is_atom(TC) ->
 
33
    t({Mod,TC}, []);
 
34
t(all, Config) when is_list(Config) ->
 
35
    Fs = filelib:wildcard("et_*_SUITE.erl"),
 
36
    t([list_to_atom(filename:rootname(File)) || File <- Fs], Config);
 
37
t(Test,Config) when is_list(Config) ->
 
38
    Tests = resolve(Test),
 
39
    write_test_case(Test),
 
40
    Res = et_test_lib:run_test(Tests, Config),    
 
41
    append_test_case_info(Test, Res).
 
42
 
 
43
user() ->
 
44
    user(read_test_case()). 
 
45
user(Mod) ->
 
46
    t(Mod, [{user,step}]).
 
47
user(Mod,Tc) when is_atom(Tc) ->
 
48
    t({Mod,Tc}, [{user,step}]).
 
49
    
 
50
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
51
%% Resolves the name of test suites and test cases
 
52
%% according to the alias definitions. Single atoms
 
53
%% are assumed to be the name of a test suite. 
 
54
 
 
55
resolve(Suite0) when is_atom(Suite0) ->
 
56
    case alias(Suite0) of
 
57
        Suite when is_atom(Suite) ->
 
58
            {Suite, all};
 
59
        {Suite, Case} ->
 
60
            {Suite, Case}
 
61
    end;
 
62
resolve({Suite0, Case}) when is_atom(Suite0), is_atom(Case) ->
 
63
    case alias(Suite0) of
 
64
        Suite when is_atom(Suite) ->
 
65
            {Suite, Case};
 
66
        {Suite, Case2} ->
 
67
            {Suite, Case2}
 
68
    end;
 
69
resolve(List) when is_list(List) ->
 
70
    [resolve(Case) || Case <- List].
 
71
 
 
72
alias(Suite) when is_atom(Suite) ->
 
73
    Str = atom_to_list(Suite),
 
74
    case {Str, lists:reverse(Str)} of
 
75
        {"et" ++ _, "ETIUS" ++ _} ->
 
76
            Suite;
 
77
        _ -> 
 
78
            list_to_atom("et_" ++ Str ++ "_SUITE")
 
79
    end.
 
80
 
 
81
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
82
 
 
83
config_fname() ->
 
84
    "et_test_case_config".
 
85
 
 
86
%% Read default config file
 
87
read_config() ->
 
88
    Fname = config_fname(),
 
89
    et_test_lib:log("Consulting file ~s...~n", [Fname]),
 
90
    case file:consult(Fname) of
 
91
        {ok, Config} ->
 
92
            et_test_lib:log("Read config ~w~n", [Config]),
 
93
            Config;
 
94
        _Error ->
 
95
            Config = et_test_lib:default_config(),
 
96
            et_test_lib:log("<>WARNING<> Using default config: ~w~n", [Config]),
 
97
            Config
 
98
    end.
 
99
 
 
100
%% Write new default config file
 
101
write_config(Config) when is_list(Config) ->
 
102
    Fname = config_fname(),
 
103
    {ok, Fd} = file:open(Fname, write),
 
104
    write_list(Fd, Config),
 
105
    file:close(Fd).
 
106
 
 
107
write_list(Fd, [H | T]) ->
 
108
    ok = io:format(Fd, "~p.~n",[H]),
 
109
    write_list(Fd, T);
 
110
write_list(_, []) ->
 
111
    ok.
 
112
 
 
113
test_case_fname() ->
 
114
    "et_test_case_info".
 
115
 
 
116
%% Read name of test case
 
117
read_test_case() ->
 
118
    Fname = test_case_fname(),
 
119
    case file:open(Fname, [read]) of
 
120
        {ok, Fd} ->
 
121
            Res = io:read(Fd, []),
 
122
            file:close(Fd),
 
123
            case Res of
 
124
                {ok, TestCase} ->
 
125
                    et_test_lib:log("Using test case ~w from file ~s~n",
 
126
                                         [TestCase, Fname]),
 
127
                    TestCase;
 
128
                {error, _} ->
 
129
                    default_test_case(Fname)
 
130
            end;
 
131
        {error, _} ->
 
132
            default_test_case(Fname)
 
133
    end.
 
134
 
 
135
default_test_case(Fname) ->
 
136
    TestCase = all, 
 
137
    et_test_lib:log("<>WARNING<> Cannot read file ~s, "
 
138
                    "using default test case: ~w~n",
 
139
                         [Fname, TestCase]),
 
140
    TestCase.
 
141
 
 
142
write_test_case(TestCase) ->
 
143
    Fname = test_case_fname(),
 
144
    {ok, Fd} = file:open(Fname, write),
 
145
    ok = io:format(Fd, "~p.~n",[TestCase]),
 
146
    file:close(Fd).
 
147
 
 
148
append_test_case_info(TestCase, TestCaseInfo) ->
 
149
    Fname = test_case_fname(),
 
150
    {ok, Fd} = file:open(Fname, [read, write]),
 
151
    ok = io:format(Fd, "~p.~n",[TestCase]),
 
152
    ok = io:format(Fd, "~p.~n",[TestCaseInfo]),
 
153
    file:close(Fd),
 
154
    TestCaseInfo.