@@ -54,7 +54,32 @@ function serve_tgz(req)
54
54
HTTP. Response (200 , libfoo_tarball_data)
55
55
end
56
56
HTTP. @register (r, " GET" , " /*/source.tar.gz" , serve_tgz)
57
- @async HTTP. serve (r, Sockets. localhost, 14444 ; verbose= false )
57
+ port = - 1
58
+ server = Sockets. TCPServer ()
59
+ # Try to connect to different ports, in case one is busy. Important in case we
60
+ # have multiple parallel builds.
61
+ available_ports = 14444 : 14544
62
+ for i in available_ports
63
+ try
64
+ # Update the global server to shut it down when we are done with it.
65
+ global server = Sockets. listen (Sockets. InetAddr (Sockets. localhost, i))
66
+ catch e
67
+ if e isa Base. IOError
68
+ if i == last (available_ports)
69
+ # Oh no, this was our last attempt
70
+ error (" No more ports available for the HTTP server" )
71
+ end
72
+ # If the port is busy, try the next one
73
+ continue
74
+ else
75
+ rethrow (e)
76
+ end
77
+ end
78
+ # All looks good, update the global `port` and start the server
79
+ global port = i
80
+ @async HTTP. serve (r, Sockets. localhost, port; server= server, verbose= false )
81
+ break
82
+ end
58
83
59
84
function readuntil_sift (io:: IO , needle)
60
85
needle = codeunits (needle)
127
152
@testset " Wizard - Downloading" begin
128
153
state = step2_state ()
129
154
with_wizard_output (state, Wizard. step2) do ins, outs
130
- call_response (ins, outs, " Please enter a URL" , " http://127.0.0.1:14444 /a/source.tar.gz" )
155
+ call_response (ins, outs, " Please enter a URL" , " http://127.0.0.1:$(port) /a/source.tar.gz" )
131
156
call_response (ins, outs, " Would you like to download additional sources" , " N" )
132
157
call_response (ins, outs, " Do you require any (binary) dependencies" , " N" )
133
158
144
169
call_response (ins, outs, " Select the preferred LLVM version" , " \e [B\e [B\e [B\r " )
145
170
end
146
171
# Check that the state is modified appropriately
147
- @test state. source_urls == [" http://127.0.0.1:14444 /a/source.tar.gz" ]
172
+ @test state. source_urls == [" http://127.0.0.1:$(port) /a/source.tar.gz" ]
148
173
@test getfield .(state. source_files, :hash ) == [libfoo_tarball_hash]
149
174
@test Set (state. compilers) == Set ([:c , :rust , :go ])
150
175
@test state. preferred_gcc_version == getversion (available_gcc_builds[1 ])
155
180
# Test two tar.gz download
156
181
state = step2_state ()
157
182
with_wizard_output (state, Wizard. step2) do ins, outs
158
- call_response (ins, outs, " Please enter a URL" , " http://127.0.0.1:14444 /a/source.tar.gz" )
183
+ call_response (ins, outs, " Please enter a URL" , " http://127.0.0.1:$(port) /a/source.tar.gz" )
159
184
call_response (ins, outs, " Would you like to download additional sources" , " Y" )
160
- call_response (ins, outs, " Please enter a URL" , " http://127.0.0.1:14444 /b/source.tar.gz" )
185
+ call_response (ins, outs, " Please enter a URL" , " http://127.0.0.1:$(port) /b/source.tar.gz" )
161
186
call_response (ins, outs, " Would you like to download additional sources" , " N" )
162
187
call_response (ins, outs, " Do you require any (binary) dependencies" , " N" )
163
188
168
193
end
169
194
# Check that the state is modified appropriately
170
195
@test state. source_urls == [
171
- " http://127.0.0.1:14444 /a/source.tar.gz" ,
172
- " http://127.0.0.1:14444 /b/source.tar.gz" ,
196
+ " http://127.0.0.1:$(port) /a/source.tar.gz" ,
197
+ " http://127.0.0.1:$(port) /b/source.tar.gz" ,
173
198
]
174
199
@test getfield .(state. source_files, :hash ) == [
175
200
libfoo_tarball_hash,
193
218
# Test failure to resolve a dependency
194
219
state = step2_state ()
195
220
@test_logs (:warn , r" Unable to resolve iso_codez_jll" ) match_mode= :any with_wizard_output (state, Wizard. step2) do ins, outs
196
- call_response (ins, outs, " Please enter a URL" , " http://127.0.0.1:14444 /a/source.tar.gz" )
221
+ call_response (ins, outs, " Please enter a URL" , " http://127.0.0.1:$(port) /a/source.tar.gz" )
197
222
call_response (ins, outs, " Would you like to download additional sources" , " N" )
198
223
call_response (ins, outs, " Do you require any (binary) dependencies" , " Y" )
199
224
@@ -231,7 +256,7 @@ function step3_state()
231
256
state = Wizard. WizardState ()
232
257
state. step = :step34
233
258
state. platforms = [Platform (" x86_64" , " linux" )]
234
- state. source_urls = [" http://127.0.0.1:14444 /a/source.tar.gz" ]
259
+ state. source_urls = [" http://127.0.0.1:$(port) /a/source.tar.gz" ]
235
260
state. source_files = [BinaryBuilder. SetupSource {ArchiveSource} (libfoo_tarball_path, libfoo_tarball_hash, " " )]
236
261
state. name = " libfoo"
237
262
state. version = v " 1.0.0"
425
450
end
426
451
end
427
452
453
+ close (server)
428
454
429
455
@testset " GitHub - authentication" begin
430
456
withenv (" GITHUB_TOKEN" => " " ) do
0 commit comments