Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
0156-escript_SUITE-permit-order-of-Actual-lines...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0156-escript_SUITE-permit-order-of-Actual-lines-to-differ.patch of Package erlang
From 71acb9a50f1455109d0aa79faca3aa68da7ca6f2 Mon Sep 17 00:00:00 2001 From: Mikael Pettersson <mikpelinux@gmail.com> Date: Sun, 20 Sep 2020 15:32:01 +0200 Subject: [PATCH 6/9] escript_SUITE: permit order of Actual lines to differ from Expected --- lib/stdlib/test/escript_SUITE.erl | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/lib/stdlib/test/escript_SUITE.erl b/lib/stdlib/test/escript_SUITE.erl index c9758009a8..251d449d94 100644 --- a/lib/stdlib/test/escript_SUITE.erl +++ b/lib/stdlib/test/escript_SUITE.erl @@ -986,16 +986,37 @@ do_run(Dir, Cmd, Expected0) -> Res = get_data(Port, []), receive {Port,{exit_status,ExitCode}} -> - case iolist_to_binary([Res,"ExitCode:"++integer_to_list(ExitCode)]) of - Expected -> + Actual = iolist_to_binary([Res,"ExitCode:"++integer_to_list(ExitCode)]), + case matches(Expected, Actual) of + true -> ok; - Actual -> + false -> io:format("Expected: ~p\n", [Expected]), io:format("Actual: ~p\n", [Actual]), ct:fail(failed) end end. +%% Check if Expected and Actual contain the same lines. +%% The lines may occur in different order. +matches(Expected, Actual) -> + ExpectedLines = string:split(Expected, "\n", all), + ActualLines = string:split(Actual, "\n", all), + matches_1(ExpectedLines, ActualLines). + +matches_1([], []) -> true; +matches_1([Line | Expected], Actual0) -> + case delete_first(Line, Actual0) of + false -> false; + Actual -> matches_1(Expected, Actual) + end. + +delete_first(X, L) -> delete_first(X, L, []). + +delete_first(_X, [], _Acc) -> false; +delete_first(X, [X | Tail], Acc) -> lists:reverse(Acc, Tail); +delete_first(X, [Y | Tail], Acc) -> delete_first(X, Tail, [Y | Acc]). + get_data(Port, SoFar) -> receive {Port,{data,Bytes}} -> -- 2.26.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor