Skip to content

Commit ced3232

Browse files
authored
Merge pull request #495 from control-toolbox/test/filter-jet-lcu-warnings
test(meta): filter LoweredCodeUtils' benign JET-scan warnings
2 parents 5a75658 + c889773 commit ced3232

2 files changed

Lines changed: 55 additions & 1 deletion

File tree

Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
3232
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3333
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
3434
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
35+
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
3536
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
3637
MarkdownAST = "d0879d2d-cac2-40c8-9cee-1863dc0c7391"
3738
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
@@ -46,6 +47,7 @@ test = [
4647
"Documenter",
4748
"ForwardDiff",
4849
"JET",
50+
"Logging",
4951
"Markdown",
5052
"MarkdownAST",
5153
"Plots",
@@ -62,6 +64,7 @@ DocStringExtensions = "0.9"
6264
Documenter = "1"
6365
ForwardDiff = "0.10, 1"
6466
JET = "0.11"
67+
Logging = "1"
6568
Markdown = "1"
6669
MarkdownAST = "0.1"
6770
Plots = "1"

test/suite/meta/test_code_quality.jl

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,57 @@ using Test: Test
44
using Aqua: Aqua
55
using JET: JET
66
using CTBase: CTBase
7+
using Logging: Logging
78

89
const VERBOSE = isdefined(Main, :TestData) ? Main.TestData.VERBOSE : true
910
const SHOWTIMING = isdefined(Main, :TestData) ? Main.TestData.SHOWTIMING : true
1011

12+
# ==============================================================================
13+
# Filter LoweredCodeUtils' benign "skipping callee ... UndefRefError()" warnings
14+
# ==============================================================================
15+
#
16+
# JET.test_package collects method signatures via Revise/LoweredCodeUtils without
17+
# calling anything. For keyword-argument functor methods (a callable struct with a
18+
# `; kwarg=default` in its call signature), Julia compiles a hidden body function
19+
# named `var"#_#N"`; LoweredCodeUtils cannot statically attribute that hidden body
20+
# to its parent method and emits a `@warn "skipping callee ..." ` before moving on.
21+
# It is a collector limitation, not a JET finding — the flagged body is simply
22+
# excluded from the static scan; everything else (including its runtime behavior,
23+
# covered by the normal test suite) is unaffected.
24+
#
25+
# Filtered precisely by message prefix + emitting module, so any other, unrelated
26+
# warning from LoweredCodeUtils still surfaces normally.
27+
struct _SkipBenignLoweredCodeUtilsWarnings <: Logging.AbstractLogger
28+
logger::Logging.AbstractLogger
29+
end
30+
31+
Logging.min_enabled_level(l::_SkipBenignLoweredCodeUtilsWarnings) =
32+
Logging.min_enabled_level(l.logger)
33+
34+
Logging.shouldlog(l::_SkipBenignLoweredCodeUtilsWarnings, level, _module, group, id) =
35+
Logging.shouldlog(l.logger, level, _module, group, id)
36+
37+
function Logging.handle_message(
38+
l::_SkipBenignLoweredCodeUtilsWarnings,
39+
level,
40+
message,
41+
_module,
42+
group,
43+
id,
44+
file,
45+
line;
46+
kwargs...,
47+
)
48+
if level == Logging.Warn &&
49+
nameof(_module) === :LoweredCodeUtils &&
50+
startswith(string(message), "skipping callee")
51+
return nothing
52+
end
53+
return Logging.handle_message(
54+
l.logger, level, message, _module, group, id, file, line; kwargs...
55+
)
56+
end
57+
1158
function test_code_quality()
1259
Test.@testset verbose = VERBOSE showtiming = SHOWTIMING "Code quality" begin
1360
Test.@testset verbose = VERBOSE showtiming = SHOWTIMING "Aqua" begin
@@ -23,7 +70,11 @@ function test_code_quality()
2370
end
2471

2572
Test.@testset "JET" begin
26-
JET.test_package(CTBase; target_modules=(CTBase,))
73+
Logging.with_logger(
74+
_SkipBenignLoweredCodeUtilsWarnings(Logging.current_logger())
75+
) do
76+
JET.test_package(CTBase; target_modules=(CTBase,))
77+
end
2778
end
2879

2980
# Test.@testset "JuliaFormatter" begin

0 commit comments

Comments
 (0)