diff options
author | Peter Andersson <[email protected]> | 2013-01-11 13:13:32 +0100 |
---|---|---|
committer | Peter Andersson <[email protected]> | 2013-01-24 10:51:51 +0100 |
commit | adc50b681c3d3bd6d98f6c3f88dad4a306d3a239 (patch) | |
tree | 08546daf9bf06b8d0dd2777e40422ebef26b14a9 /lib/common_test/src/ct_testspec.erl | |
parent | 1df90a0d2ae0260b878071c896127f0ce7dcb3d5 (diff) | |
download | otp-adc50b681c3d3bd6d98f6c3f88dad4a306d3a239.tar.gz otp-adc50b681c3d3bd6d98f6c3f88dad4a306d3a239.tar.bz2 otp-adc50b681c3d3bd6d98f6c3f88dad4a306d3a239.zip |
Make it possible to execute one test run per test specification
OTP-9881
Diffstat (limited to 'lib/common_test/src/ct_testspec.erl')
-rw-r--r-- | lib/common_test/src/ct_testspec.erl | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/lib/common_test/src/ct_testspec.erl b/lib/common_test/src/ct_testspec.erl index 202d8f9373..9a7a384ebb 100644 --- a/lib/common_test/src/ct_testspec.erl +++ b/lib/common_test/src/ct_testspec.erl @@ -246,22 +246,40 @@ collect_tests_from_file(Specs, Relaxed) -> collect_tests_from_file(Specs,Nodes,Relaxed) when is_list(Nodes) -> NodeRefs = lists:map(fun(N) -> {undefined,N} end, Nodes), - catch collect_tests_from_file1(Specs,#testspec{nodes=NodeRefs},Relaxed). - -collect_tests_from_file1([Spec|Specs],TestSpec,Relaxed) -> + %% [Spec1,Spec2,...] means create one testpec record per Spec file + %% [[Spec1,Spec2,...]] means merge all specs into one testspec record + {MergeSpecs,Specs1} = if is_list(hd(hd(Specs))) -> {true,hd(Specs)}; + true -> {false,Specs} + end, + catch create_specs(Specs1,Specs1,#testspec{nodes=NodeRefs}, + Relaxed,MergeSpecs,[]). + +create_specs([Spec|Ss],Specs,TestSpec,Relaxed,MergeSpecs,Saved) -> SpecDir = filename:dirname(filename:absname(Spec)), case file:consult(Spec) of {ok,Terms} -> case collect_tests(Terms, TestSpec#testspec{spec_dir=SpecDir}, Relaxed) of - TS = #testspec{tests=Tests, logdir=LogDirs} when Specs == [] -> + TS = #testspec{tests=Tests, logdir=LogDirs} when + Ss == [], MergeSpecs == true -> + LogDirs1 = lists:delete(".",LogDirs) ++ ["."], + [{Specs,TS#testspec{tests=lists:flatten(Tests), + logdir=LogDirs1}}]; + TS = #testspec{tests=Tests, logdir=LogDirs} when + Ss == [], MergeSpecs == false -> LogDirs1 = lists:delete(".",LogDirs) ++ ["."], - TS#testspec{tests=lists:flatten(Tests), logdir=LogDirs1}; - TS = #testspec{alias = As, nodes = Ns} -> + TSRet = {[Spec],TS#testspec{tests=lists:flatten(Tests), + logdir=LogDirs1}}, + lists:reverse([TSRet|Saved]); + TS = #testspec{alias = As, nodes = Ns} when + MergeSpecs == true -> TS1 = TS#testspec{alias = lists:reverse(As), nodes = lists:reverse(Ns)}, - collect_tests_from_file1(Specs,TS1,Relaxed) + create_specs(Ss,Specs,TS1,Relaxed,MergeSpecs,[]); + TS when MergeSpecs == false -> + create_specs(Ss,Specs,TestSpec,Relaxed,MergeSpecs, + [{[Spec],TS}|Saved]) end; {error,Reason} -> ReasonStr = |