Skip to content

Commit

Permalink
[Distributed] add some unit tests for managers.jl (#34963)
Browse files Browse the repository at this point in the history
It finds a bug.
  • Loading branch information
ssikdar1 authored May 9, 2022
1 parent cd7678c commit cfd801d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/managers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ function parse_machine(machine::AbstractString)
if machine[begin] == '[' # ipv6 bracket notation (RFC 2732)
ipv6_end = findlast(']', machine)
if ipv6_end === nothing
throw(ArgumentError("invalid machine definition format string: invalid port format \"$machine_def\""))
throw(ArgumentError("invalid machine definition format string: invalid port format \"$machine\""))
end
hoststr = machine[begin+1 : prevind(machine,ipv6_end)]
machine_def = split(machine[ipv6_end : end] , ':')
Expand Down
4 changes: 4 additions & 0 deletions test/managers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ using Distributed: parse_machine, SSHManager, LocalManager
@test parse_machine("127.0.0.1:90") == ("127.0.0.1", 90)
@test parse_machine("127.0.0.1:1") == ("127.0.0.1", 1)
@test parse_machine("127.0.0.1:65535") == ("127.0.0.1", 65535)

@test_throws ArgumentError parse_machine("127.0.0.1:-1")
@test_throws ArgumentError parse_machine("127.0.0.1:0")
@test_throws ArgumentError parse_machine("127.0.0.1:65536")
@test_throws ArgumentError parse_machine("[2001:db8::1]:443:888")
@test_throws ArgumentError parse_machine("[2001:db8::1")
@test_throws ArgumentError parse_machine("[2001:db8::1]:aaa")

@test occursin(r"^SSHManager\(machines=.*\)$",
sprint((t,x) -> show(t, "text/plain", x), SSHManager("127.0.0.1")))
Expand Down

0 comments on commit cfd801d

Please sign in to comment.