Skip to content

Commit

Permalink
tests: Use ARGS to choose which tests to run (#1108)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
cmcaine authored Apr 7, 2024
1 parent 7a913fb commit efd74ea
Showing 1 changed file with 33 additions and 29 deletions.
62 changes: 33 additions & 29 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,40 +1,44 @@
using Test, HTTP, JSON

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

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

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

include(joinpath(dir, "resources/TestRequest.jl"))
@testset "HTTP" begin
for f in [
"ascii.jl",
"chunking.jl",
"utils.jl",
"client.jl",
# "download.jl",
"multipart.jl",
"parsemultipart.jl",
"sniff.jl",
"cookies.jl",
"parser.jl",
"loopback.jl",
"websockets/deno_client/server.jl",
"messages.jl",
"handlers.jl",
"server.jl",
"async.jl",
"mwe.jl",
"httpversion.jl",
"websockets/autobahn.jl",
]
file = joinpath(dir, f)
println("Running $file tests...")
if isfile(file)
include(file)
else
@show readdir(dirname(file))
end
testfiles = [
"ascii.jl",
"chunking.jl",
"utils.jl",
"client.jl",
# "download.jl",
"multipart.jl",
"parsemultipart.jl",
"sniff.jl",
"cookies.jl",
"parser.jl",
"loopback.jl",
"websockets/deno_client/server.jl",
"messages.jl",
"handlers.jl",
"server.jl",
"async.jl",
"mwe.jl",
"httpversion.jl",
"websockets/autobahn.jl",
]
# ARGS can be most easily passed like this:
# import Pkg; Pkg.test("HTTP"; test_args=`ascii.jl parser.jl`)
if !isempty(ARGS)
filter!(in(ARGS), testfiles)
end
for filename in testfiles
println("Running $filename tests...")
include(joinpath(dir, filename))
end
end

0 comments on commit efd74ea

Please sign in to comment.