Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Use ARGS to choose which tests to run #1108

Merged
merged 3 commits into from
Apr 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we keep this please? I don't mind moving it down to the for loop, but it's really handy because I often have to step through the test files one by one and @__DIR__ doesnt' work when run at the REPL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!


# 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
Loading