Skip to content

Commit efd74ea

Browse files
authored
tests: Use ARGS to choose which tests to run (#1108)
* tests: Use ARGS to choose which tests to run ARGS can be specified like this: Pkg.test("HTTP"; test_args=`ascii.jl parser.jl`) # or Pkg.test("HTTP"; test_args=["ascii.jl", "parser.jl"]) This is useful because the whole test suite takes ages to run. * Clean up a few other things while we're here * Define const dir again
1 parent 7a913fb commit efd74ea

File tree

1 file changed

+33
-29
lines changed

1 file changed

+33
-29
lines changed

test/runtests.jl

+33-29
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,44 @@
11
using Test, HTTP, JSON
22

3+
# Using this rather than @__DIR__ because then it's easier to run parts of the
4+
# file at the REPL, which is convenient when developing the package.
35
const dir = joinpath(dirname(pathof(HTTP)), "..", "test")
46

7+
# See https://httpbingo.julialang.org/
58
const httpbin = get(ENV, "JULIA_TEST_HTTPBINGO_SERVER", "httpbingo.julialang.org")
69

10+
# A convenient test helper used in a few test files.
711
isok(r) = r.status == 200
812

9-
include(joinpath(dir, "resources/TestRequest.jl"))
1013
@testset "HTTP" begin
11-
for f in [
12-
"ascii.jl",
13-
"chunking.jl",
14-
"utils.jl",
15-
"client.jl",
16-
# "download.jl",
17-
"multipart.jl",
18-
"parsemultipart.jl",
19-
"sniff.jl",
20-
"cookies.jl",
21-
"parser.jl",
22-
"loopback.jl",
23-
"websockets/deno_client/server.jl",
24-
"messages.jl",
25-
"handlers.jl",
26-
"server.jl",
27-
"async.jl",
28-
"mwe.jl",
29-
"httpversion.jl",
30-
"websockets/autobahn.jl",
31-
]
32-
file = joinpath(dir, f)
33-
println("Running $file tests...")
34-
if isfile(file)
35-
include(file)
36-
else
37-
@show readdir(dirname(file))
38-
end
14+
testfiles = [
15+
"ascii.jl",
16+
"chunking.jl",
17+
"utils.jl",
18+
"client.jl",
19+
# "download.jl",
20+
"multipart.jl",
21+
"parsemultipart.jl",
22+
"sniff.jl",
23+
"cookies.jl",
24+
"parser.jl",
25+
"loopback.jl",
26+
"websockets/deno_client/server.jl",
27+
"messages.jl",
28+
"handlers.jl",
29+
"server.jl",
30+
"async.jl",
31+
"mwe.jl",
32+
"httpversion.jl",
33+
"websockets/autobahn.jl",
34+
]
35+
# ARGS can be most easily passed like this:
36+
# import Pkg; Pkg.test("HTTP"; test_args=`ascii.jl parser.jl`)
37+
if !isempty(ARGS)
38+
filter!(in(ARGS), testfiles)
39+
end
40+
for filename in testfiles
41+
println("Running $filename tests...")
42+
include(joinpath(dir, filename))
3943
end
4044
end

0 commit comments

Comments
 (0)