From 49b1796d32162214086c1f7a11c58cb0a62f84ca Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Wed, 19 Oct 2022 20:25:58 +0200 Subject: peer: Fix ssh testcase on windows --- lib/stdlib/test/peer_SUITE.erl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'lib/stdlib/test') diff --git a/lib/stdlib/test/peer_SUITE.erl b/lib/stdlib/test/peer_SUITE.erl index 9db03fe596..e5372416ee 100644 --- a/lib/stdlib/test/peer_SUITE.erl +++ b/lib/stdlib/test/peer_SUITE.erl @@ -518,8 +518,20 @@ ssh(Config) when is_list(Config) -> {skip, "erl not found"}; {ErlPath, SshPath} -> Name = peer:random_name(?FUNCTION_NAME), - {ok, Peer, _Node} = peer:start_link(#{exec => {SshPath, ["localhost", ErlPath]}, - connection => standard_io, name => Name, host => "localhost"}), + {OsName, _} = os:type(), + Options = #{exec => {SshPath, ["localhost", ErlPath]}, + connection => standard_io, name => Name, host => "localhost"}, + {ok, Peer, _Node} = + try peer:start_link(Options) of + Result -> Result + catch error:{boot_failed, normal} when OsName =:= win32 -> + %% If the boot fails on windows, ssh may have ended up + %% in wsl, so we try to boot using a wsl path + WslPath = string:trim(os:cmd("wsl wslpath -u " ++ ErlPath)), + peer:start_link( + Options#{ exec => {SshPath, ["localhost", WslPath]}}) + end, + %% TODO: how to check it really goes over SSH? %% ssh-ed node is not distributed ?assertEqual(list_to_atom(Name ++ "@localhost"), peer:call(Peer, erlang, node, [])), -- cgit v1.2.1