File 1204-Fix-tests-on-ts.patch of Package erlang

From 0fd2ae984f27afe8928d5be57aea952bc96b88cb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Eric=20Meadows-J=C3=B6nsson?=
 <eric.meadows.jonsson@gmail.com>
Date: Mon, 27 Jan 2025 14:47:14 +0100
Subject: [PATCH 4/6] Fix tests on ts

Co-authored-by: Rin Kuryloski <rin.kuryloski@mechanical-orchard.com>
---
 erts/test/erlexec_SUITE.erl | 38 ++++++++++++++++++++++++-------------
 1 file changed, 25 insertions(+), 13 deletions(-)

diff --git a/erts/test/erlexec_SUITE.erl b/erts/test/erlexec_SUITE.erl
index 0c9933cb7b..07f5eeaa9f 100644
--- a/erts/test/erlexec_SUITE.erl
+++ b/erts/test/erlexec_SUITE.erl
@@ -35,6 +35,7 @@
          zdbbl_dist_buf_busy_limit/1, long_path_env/1]).
 
 -include_lib("common_test/include/ct.hrl").
+-include_lib("eunit/include/eunit.hrl").
 
 suite() ->
     [{ct_hooks,[ts_install_cth]},
@@ -445,26 +446,37 @@ zdbbl_dist_buf_busy_limit(Config) when is_list(Config) ->
     ok.
 
 long_path_env(Config) when is_list(Config) ->
-    OriginalPath = os:getenv("PATH"),
-    [BinPath, RestPath] = string:split(OriginalPath, ":"),
+    BinPath = os:getenv("BINDIR"),
+    ActualPath = os:getenv("PATH"),
+    ct:log("BINDIR: ~ts", [BinPath]),
+    ct:log("PATH: ~ts", [ActualPath]),
+
     LongPath = lists:duplicate(10240, "x"),
-    ExpectedPath = OriginalPath ++ ":" ++ LongPath,
     {ok, [[PName]]} = init:get_argument(progname),
     Cmd = PName ++ " -noshell -eval 'io:format(\"~ts\", [os:getenv(\"PATH\")]),erlang:halt()'",
 
-    os:putenv("PATH", OriginalPath ++ ":" ++ LongPath ++ ":" ++ BinPath),
-    Output1 = os:cmd(Cmd),
-    true = string:equal(ExpectedPath, Output1),
+    compare_erl_path(Cmd, BinPath, ActualPath),
+    compare_erl_path(Cmd, BinPath, pathjoin([ActualPath, LongPath])),
+    compare_erl_path(Cmd, BinPath, pathjoin([ActualPath, LongPath, BinPath])),
+    compare_erl_path(Cmd, BinPath, pathjoin([BinPath, ActualPath, LongPath])),
+    compare_erl_path(Cmd, BinPath, pathjoin([BinPath, ActualPath, LongPath, BinPath])),
+    ok.
 
-    os:putenv("PATH", ExpectedPath),
-    Output2 = os:cmd(Cmd),
-    true = string:equal(ExpectedPath, Output2),
+compare_erl_path(Cmd, BinPath, Path) ->
+    os:putenv("PATH", Path),
+    Output = os:cmd(Cmd),
+    % BinPath is at the front of PATH and nowhere else
+    ?assertEqual(string:find(Output, BinPath ++ ":"), Output),
+    ?assertEqual(string:find(Output, ":" ++ BinPath), nomatch).
 
-    os:putenv("PATH", RestPath ++ ":" ++ LongPath),
-    Output3 = os:cmd(Cmd),
-    true = string:equal(ExpectedPath, Output3),
+pathsep() ->
+    case os:type() of
+        {win32, _} -> ";";
+        _ -> ":"
+    end.
 
-    ok.
+pathjoin(Components) ->
+    lists:concat(lists:join(pathsep(), Components)).
 
 
 %%
-- 
2.43.0

openSUSE Build Service is sponsored by