diff options
author | Peter Andersson <[email protected]> | 2015-12-11 09:33:21 +0100 |
---|---|---|
committer | Peter Andersson <[email protected]> | 2015-12-11 09:33:21 +0100 |
commit | 75bf5a71b5fdac521430fb0205702079b14ab5b3 (patch) | |
tree | 6bc72309aee401183f36691aeaedf962a5f2b339 /lib | |
parent | 4598a8e0b8a318e0541f607897fb6cda1739bdaf (diff) | |
parent | 6d2bac38720ec27763a0cea2ae48060d501fce62 (diff) | |
download | otp-75bf5a71b5fdac521430fb0205702079b14ab5b3.tar.gz otp-75bf5a71b5fdac521430fb0205702079b14ab5b3.tar.bz2 otp-75bf5a71b5fdac521430fb0205702079b14ab5b3.zip |
Merge branch 'peppe/common_test/exit_status_when_missing_suites' into maint
* peppe/common_test/exit_status_when_missing_suites:
Let missing suites affect ct:run_test/1 return and ct_run exit status
Make abort_if_missing_suites option work in all io modes
OTP-13173
Diffstat (limited to 'lib')
-rw-r--r-- | lib/common_test/doc/src/run_test_chapter.xml | 16 | ||||
-rw-r--r-- | lib/common_test/src/ct_run.erl | 20 |
2 files changed, 24 insertions, 12 deletions
diff --git a/lib/common_test/doc/src/run_test_chapter.xml b/lib/common_test/doc/src/run_test_chapter.xml index d80453fc98..082a587c8d 100644 --- a/lib/common_test/doc/src/run_test_chapter.xml +++ b/lib/common_test/doc/src/run_test_chapter.xml @@ -60,15 +60,15 @@ <p>If compilation should fail for one or more suites, the compilation errors are printed to tty and the operator is asked if the test run should proceed without the missing suites, or be aborted. If the operator chooses to proceed, - it is noted in the HTML log which tests have missing suites. If Common Test is - unable to prompt the user after compilation failure (if Common Test doesn't - control stdin), the test run will proceed automatically without the missing - suites. This behaviour can however be modified with the - <c><![CDATA[ct_run]]></c> flag <c><![CDATA[-abort_if_missing_suites]]></c>, + it is noted in the HTML log which tests have missing suites. Also, for each failed + compilation, the failed tests counter in the return value of + <c><![CDATA[ct:run_test/1]]></c> is incremented. If Common Test is unable to prompt + the user after compilation failure (if Common Test doesn't control stdin), the test + run will proceed automatically without the missing suites. In order to always + abort the test run (without operator interaction) if one or more suites fail + to compile, the <c><![CDATA[ct_run]]></c> flag <c><![CDATA[-abort_if_missing_suites]]></c>, or the <c><![CDATA[ct:run_test/1]]></c> option - <c><![CDATA[{abort_if_missing_suites,TrueOrFalse}]]></c>. If - <c><![CDATA[abort_if_missing_suites]]></c> is set (to true), the test run - will stop immediately if some suites fail to compile.</p> + <c><![CDATA[{abort_if_missing_suites,true}]]></c> should be set.</p> <p>Any help module (i.e. regular Erlang module with name not ending with "_SUITE") that resides in the same test object directory as a suite diff --git a/lib/common_test/src/ct_run.erl b/lib/common_test/src/ct_run.erl index ae91601f67..0b646ffd07 100644 --- a/lib/common_test/src/ct_run.erl +++ b/lib/common_test/src/ct_run.erl @@ -1771,7 +1771,18 @@ compile_and_run(Tests, Skip, Opts, Args) -> {Tests1,Skip1} -> ReleaseSh = proplists:get_value(release_shell, Args), ct_util:set_testdata({release_shell,ReleaseSh}), - possibly_spawn(ReleaseSh == true, Tests1, Skip1, Opts) + TestResult = + possibly_spawn(ReleaseSh == true, Tests1, Skip1, Opts), + case TestResult of + {Ok,Errors,Skipped} -> + NoOfMakeErrors = + lists:foldl(fun({_,BadMods}, X) -> + X + length(BadMods) + end, 0, SuiteMakeErrors), + {Ok,Errors+NoOfMakeErrors,Skipped}; + ErrorResult -> + ErrorResult + end catch _:BadFormat -> {error,BadFormat} @@ -2073,7 +2084,9 @@ final_skip([], Final) -> continue([], _) -> true; -continue(_MakeErrors, AbortIfMissingSuites) -> +continue(_MakeErrors, true) -> + false; +continue(_MakeErrors, _AbortIfMissingSuites) -> io:nl(), OldGl = group_leader(), case set_group_leader_same_as_shell() of @@ -2101,11 +2114,10 @@ continue(_MakeErrors, AbortIfMissingSuites) -> true end; false -> % no shell process to use - not AbortIfMissingSuites + true end. set_group_leader_same_as_shell() -> - %%! Locate the shell process... UGLY!!! GS2or3 = fun(P) -> case process_info(P,initial_call) of {initial_call,{group,server,X}} when X == 2 ; X == 3 -> |