-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
1 changed file
with
33 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |