-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4403 from esl/rerun-failed-tests
Enable 'rerun failed tests' for big tests in CircleCI
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
%% Escript used to filter the test spec according to a list of allowed suites | ||
%% This is used to rerun failed tests on CircleCI | ||
%% | ||
%% Arguments: TEST_SPEC SUITE1 SUITE2 .. | ||
%% Example arguments: default.spec muc_SUITE rdbms_SUITE | ||
|
||
-module(select_suites_to_run). | ||
-export([main/1]). | ||
|
||
main([SpecFile | SuiteStrings]) -> | ||
Suites = [list_to_atom(Str) || Str <- SuiteStrings], | ||
io:format("Allowed suites: ~p~n", [Suites]), | ||
{ok, OldTerms} = file:consult(SpecFile), | ||
NewTerms = lists:filter(fun(Term) -> filter_term(Term, Suites) end, OldTerms), | ||
write_terms(SpecFile, NewTerms), | ||
ok. | ||
|
||
filter_term(Term, Suites) when element(1, Term) == suites; | ||
element(1, Term) == groups; | ||
element(1, Term) == cases -> | ||
lists:member(element(3, Term), Suites); | ||
filter_term(_Term, _Suites) -> | ||
true. | ||
|
||
write_terms(Filename, List) -> | ||
Format = fun(Term) -> io_lib:format("~tp.~n", [Term]) end, | ||
Text = lists:map(Format, List), | ||
file:write_file(Filename, Text). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters