Skip to content

Commit d124aa8

Browse files
committed
.
1 parent 60fea81 commit d124aa8

File tree

9 files changed

+188
-136
lines changed

9 files changed

+188
-136
lines changed

src/filtering.jl

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,7 @@ function filter_testitem(f, expr)
5252
@assert expr.head == :macrocall
5353
macro_name = expr.args[1]
5454
if macro_name === Symbol("@testitem")
55-
# `@testitem` have have at least: macro_name, line_number, name, body
56-
length(expr.args) < 4 && return expr
57-
name = try_get_name(expr)
58-
name === nothing && return expr
59-
tags = try_get_tags(expr)
60-
tags === nothing && return expr
61-
ti = TestItemMetadata(name, tags)
62-
return f(ti) ? expr : nothing
55+
return __filter_ti(f, expr)
6356
elseif macro_name === Symbol("@testsetup")
6457
return expr
6558
elseif macro_name === ___RAI_MACRO_NAME_DONT_USE # TODO: drop this branch when we can
@@ -98,6 +91,17 @@ function try_get_tags(expr::Expr)
9891
return tags
9992
end
10093

94+
function __filter_ti(f, expr)
95+
# `@testitem` have have at least: macro_name, line_number, name, body
96+
length(expr.args) < 4 && return expr
97+
name = try_get_name(expr)
98+
name === nothing && return expr
99+
tags = try_get_tags(expr)
100+
tags === nothing && return expr
101+
ti = TestItemMetadata(name, tags)
102+
return f(ti) ? expr : nothing
103+
end
104+
101105
# Macro used by RAI (corporate sponsor of this package)
102106
# TODO: drop support for this when RAI codebase is fully switched to ReTestItems.jl
103107
const ___RAI_MACRO_NAME_DONT_USE = Symbol("@test_rel")

src/include_test_file.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function include_test_file(ti_filter::TestItemFilter, path::String)
2424
else
2525
error("Test files must only include `@testitem` and `@testsetup` calls, got a $t at $(path)") # TODO
2626
end
27-
empty!(stream)
27+
empty!(stream) # TODO: SourceFile created on a reset stream always start line number at 1
2828
end
2929
finally
3030
delete!(tls, :SOURCE_PATH)
@@ -46,7 +46,8 @@ end
4646
function _eval_from_stream(stream, path, ti_filter::TestItemFilter)
4747
parse!(stream; rule=:statement)
4848
ast = build_tree(Expr, stream; filename=path)
49-
filtered = ti_filter(ast)::Union{Nothing, Expr}
49+
any_error(stream) && throw(ParseError(stream, filename=path))
50+
filtered = __filter_rai(ti_filter, ast)::Union{Nothing, Expr}
5051
filtered === nothing || Core.eval(Main, filtered::Expr)
5152
return nothing
5253
end
@@ -57,7 +58,8 @@ function _eval_from_stream(stream, path, ti_filter::TestItemFilter, bytes)
5758
if ti_filter.name isa Nothing
5859
parse!(stream; rule=:statement)
5960
ast = build_tree(Expr, stream; filename=path)
60-
filtered = ti_filter(ast)::Union{Nothing, Expr}
61+
any_error(stream) && throw(ParseError(stream, filename=path))
62+
filtered = __filter_ti(ti_filter, ast)::Union{Nothing, Expr}
6163
filtered === nothing || Core.eval(Main, filtered::Expr)
6264
return nothing
6365
end
@@ -67,7 +69,8 @@ function _eval_from_stream(stream, path, ti_filter::TestItemFilter, bytes)
6769
parse!(stream; rule=:statement)
6870
if _contains(name, ti_filter.name)
6971
ast = build_tree(Expr, stream; filename=path)
70-
filtered = ti_filter(ast)::Union{Nothing, Expr}
72+
any_error(stream) && throw(ParseError(stream, filename=path))
73+
filtered = __filter_ti(ti_filter, ast)::Union{Nothing, Expr}
7174
filtered === nothing || Core.eval(Main, filtered::Expr)
7275
end
7376
return nothing

test/integrationtests.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ end
816816
end
817817

818818
@testset "error on code outside `@testitem`/`@testsetup`" begin
819-
err_msg = "Test files must only include `@testitem` and `@testsetup` calls."
819+
err_msg = "Test files must only include `@testitem` and `@testsetup` calls"
820820
filter_func(ti) = false
821821
@test_throws err_msg runtests(joinpath(TEST_FILES_DIR, "_misuse_file1_test.jl"))
822822
@test_throws err_msg runtests(joinpath(TEST_FILES_DIR, "_misuse_file2_test.jl"))
@@ -868,9 +868,9 @@ end
868868
file = joinpath(TEST_FILES_DIR, "_duplicate_names_test.jl")
869869
relfpath = relpath(file, pkgdir(ReTestItems))
870870
expected_msg = if Base.Sys.iswindows()
871-
Regex("Duplicate test item name `dup` in file")
871+
"Duplicate test item name `dup` in file"
872872
else
873-
Regex("Duplicate test item name `dup` in file `$(relfpath)` at line 4")
873+
"Duplicate test item name `dup` in file `$(relfpath)` at line 4"
874874
end
875875
@test_throws expected_msg runtests(file; nworkers=0)
876876
@test_throws expected_msg runtests(file; nworkers=1)

test/packages/DontPass.jl/Manifest.toml

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is machine-generated - editing it directly is not advised
22

3-
julia_version = "1.8.2"
3+
julia_version = "1.10.10"
44
manifest_format = "2.0"
55
project_hash = "31dabfddf1e36ecf2dc5cff56cdddc361b29f16f"
66

@@ -30,58 +30,62 @@ uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"
3030
deps = ["Markdown"]
3131
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
3232

33+
[[deps.JuliaSyntax]]
34+
git-tree-sha1 = "0d4b3dab95018bcf3925204475693d9f09dc45b8"
35+
uuid = "70703baa-626e-46a2-a12c-08ffd08c73b4"
36+
version = "1.0.2"
37+
3338
[[deps.LibCURL]]
3439
deps = ["LibCURL_jll", "MozillaCACerts_jll"]
3540
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
36-
version = "0.6.3"
41+
version = "0.6.4"
3742

3843
[[deps.LibCURL_jll]]
3944
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"]
4045
uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
41-
version = "7.84.0+0"
46+
version = "8.4.0+0"
4247

4348
[[deps.LibGit2]]
44-
deps = ["Base64", "NetworkOptions", "Printf", "SHA"]
49+
deps = ["Base64", "LibGit2_jll", "NetworkOptions", "Printf", "SHA"]
4550
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
4651

52+
[[deps.LibGit2_jll]]
53+
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"]
54+
uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5"
55+
version = "1.6.4+0"
56+
4757
[[deps.LibSSH2_jll]]
4858
deps = ["Artifacts", "Libdl", "MbedTLS_jll"]
4959
uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"
50-
version = "1.10.2+0"
60+
version = "1.11.0+1"
5161

5262
[[deps.Libdl]]
5363
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
5464

5565
[[deps.Logging]]
5666
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
5767

58-
[[deps.LoggingExtras]]
59-
deps = ["Dates", "Logging"]
60-
git-tree-sha1 = "cedb76b37bc5a6c702ade66be44f831fa23c681e"
61-
uuid = "e6f89c97-d47a-5376-807f-9c37f3926c36"
62-
version = "1.0.0"
63-
6468
[[deps.Markdown]]
6569
deps = ["Base64"]
6670
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
6771

6872
[[deps.MbedTLS_jll]]
6973
deps = ["Artifacts", "Libdl"]
7074
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
71-
version = "2.28.0+0"
75+
version = "2.28.2+1"
7276

7377
[[deps.MozillaCACerts_jll]]
7478
uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
75-
version = "2022.2.1"
79+
version = "2023.1.10"
7680

7781
[[deps.NetworkOptions]]
7882
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
7983
version = "1.2.0"
8084

8185
[[deps.Pkg]]
82-
deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
86+
deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
8387
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
84-
version = "1.8.0"
88+
version = "1.10.0"
8589

8690
[[deps.Printf]]
8791
deps = ["Unicode"]
@@ -92,14 +96,14 @@ deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
9296
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
9397

9498
[[deps.Random]]
95-
deps = ["SHA", "Serialization"]
99+
deps = ["SHA"]
96100
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
97101

98102
[[deps.ReTestItems]]
99-
deps = ["Dates", "Logging", "LoggingExtras", "Pkg", "Serialization", "Sockets", "Test", "TestEnv"]
103+
deps = ["Dates", "JuliaSyntax", "Logging", "Pkg", "Serialization", "Sockets", "StringViews", "Test", "TestEnv"]
100104
path = "../../.."
101105
uuid = "817f1d60-ba6b-4fd5-9520-3cf149f6a823"
102-
version = "0.1.0"
106+
version = "1.34.0"
103107

104108
[[deps.SHA]]
105109
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
@@ -111,25 +115,30 @@ uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
111115
[[deps.Sockets]]
112116
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
113117

118+
[[deps.StringViews]]
119+
git-tree-sha1 = "d3c7a06c80622b8404b1105886c732abcb25cc2b"
120+
uuid = "354b36f9-a18e-4713-926e-db85100087ba"
121+
version = "1.3.5"
122+
114123
[[deps.TOML]]
115124
deps = ["Dates"]
116125
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
117-
version = "1.0.0"
126+
version = "1.0.3"
118127

119128
[[deps.Tar]]
120129
deps = ["ArgTools", "SHA"]
121130
uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
122-
version = "1.10.1"
131+
version = "1.10.0"
123132

124133
[[deps.Test]]
125134
deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
126135
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
127136

128137
[[deps.TestEnv]]
129138
deps = ["Pkg"]
130-
git-tree-sha1 = "b5a483bcc8c9f0df569101df166601e5e699f346"
139+
git-tree-sha1 = "aec63ef091b11d67040b8b35d2dcdfdc4567c4d0"
131140
uuid = "1e6cf692-eddd-4d53-88a5-2d735e33781b"
132-
version = "1.9.3"
141+
version = "1.102.2"
133142

134143
[[deps.UUIDs]]
135144
deps = ["Random", "SHA"]
@@ -141,14 +150,14 @@ uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
141150
[[deps.Zlib_jll]]
142151
deps = ["Libdl"]
143152
uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
144-
version = "1.2.12+3"
153+
version = "1.2.13+1"
145154

146155
[[deps.nghttp2_jll]]
147156
deps = ["Artifacts", "Libdl"]
148157
uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"
149-
version = "1.48.0+0"
158+
version = "1.52.0+1"
150159

151160
[[deps.p7zip_jll]]
152161
deps = ["Artifacts", "Libdl"]
153162
uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
154-
version = "17.4.0+0"
163+
version = "17.4.0+2"

0 commit comments

Comments
 (0)