aboutsummaryrefslogtreecommitdiffstats
path: root/lib/test_server
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2010-04-07 09:05:06 +0000
committerErlang/OTP <[email protected]>2010-04-07 09:05:06 +0000
commit6fd69d6ca5cea3aae4afce7544ba6b729221885c (patch)
tree3259bba75d7eeaa31ef74c195b50fc9d5b6b1876 /lib/test_server
parent1443a8648abdd49a653a984289e4bf6d7f062310 (diff)
parentb42442e6523da6013fdd742f41a5d1455498b0b3 (diff)
downloadotp-6fd69d6ca5cea3aae4afce7544ba6b729221885c.tar.gz
otp-6fd69d6ca5cea3aae4afce7544ba6b729221885c.tar.bz2
otp-6fd69d6ca5cea3aae4afce7544ba6b729221885c.zip
Merge branch 'bg/ts_run' into dev
* bg/ts_run: ts_run: Don't run make:all/1 without a good reason OTP-8556 bg/ts_run
Diffstat (limited to 'lib/test_server')
-rw-r--r--lib/test_server/src/ts_run.erl60
1 files changed, 54 insertions, 6 deletions
diff --git a/lib/test_server/src/ts_run.erl b/lib/test_server/src/ts_run.erl
index 3461e1383c..1d611f501c 100644
--- a/lib/test_server/src/ts_run.erl
+++ b/lib/test_server/src/ts_run.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1997-2010. 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%
%%
@@ -392,7 +392,7 @@ make_test_suite(Vars, _Spec, State) ->
{ok, Cwd} = file:get_cwd(),
ok = file:set_cwd(TestDir),
- Result = (catch make:all(Erl_flags)),
+ Result = (catch make_all(Erl_flags)),
ok = file:set_cwd(Cwd),
case Result of
up_to_date ->
@@ -743,4 +743,52 @@ split_one(Path) ->
split_path(Path) ->
string:tokens(Path,";").
+%%
+%% Run make:all/1 if the test suite seems to be designed
+%% to be built/re-built by ts.
+%%
+make_all(Flags) ->
+ case filelib:is_regular("Emakefile") of
+ false ->
+ make_all_no_emakefile(Flags);
+ true ->
+ make:all(Flags)
+ end.
+
+make_all_no_emakefile(Flags) ->
+ case filelib:wildcard("*.beam") of
+ [] ->
+ %% Since there are no *.beam files, we will assume
+ %% that this test suite was designed to be built and
+ %% re-built by ts. Create an Emakefile so that
+ %% make:all/1 will be run the next time too
+ %% (in case a test suite is being interactively
+ %% developed).
+ create_emakefile(Flags, "*.erl");
+ [_|_] ->
+ %% There is no Emakefile and there already are
+ %% some *.beam files here. Assume that this test
+ %% suite was not designed to be re-built by ts.
+ %% Only create a Emakefile that will compile
+ %% generated *_SUITE_make files (if any).
+ create_emakefile(Flags, "*_SUITE_make.erl")
+ end.
+create_emakefile(Flags, Wc) ->
+ case filelib:wildcard(Wc) of
+ [] ->
+ %% There are no files to be built (i.e. not even any
+ %% generated *_SUITE_make.erl files). We must handle
+ %% this case specially, because make:all/1 will crash
+ %% on Emakefile with an empty list of modules.
+ io:put_chars("No Emakefile found - not running make:all/1\n"),
+ up_to_date;
+ [_|_]=Ms0 ->
+ io:format("Creating an Emakefile for compiling files matching ~s\n",
+ [Wc]),
+ Ms = [list_to_atom(filename:rootname(M, ".erl")) || M <- Ms0],
+ Make0 = {Ms,Flags},
+ Make = io_lib:format("~p. \n", [Make0]),
+ ok = file:write_file("Emakefile", Make),
+ make:all(Flags)
+ end.