Skip to content

Commit 672deb8

Browse files
authored
Fix provider descend tests to be independent of user preferences (#699)
The `test_descend_for_provider` function relied on the global `Cthulhu.CONFIG`, which is populated from `LocalPreferences.toml` via `read_config!()` at init. User preferences (e.g. `remarks=true`) leaked into the test environment through `LOAD_PATH`, causing the expected warning log pattern to not match. Pass a splatted default `CthulhuConfig()` to `descend()` so the test always starts with known default state regardless of user preferences.
1 parent f4581e8 commit 672deb8

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

test/provider_utils.jl

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
using Core.IR
22
using Test
3-
using Cthulhu: descend, get_inference_world, find_method_instance, generate_code_instance, lookup, get_ci, get_override, find_callsites, Command, menu_commands, is_command_enabled, show_command, CthulhuState, get_pc_effects, get_pc_remarks, get_pc_excts, get_inlining_costs, show_parameters
4-
using .CompilerIntegration: DefaultProvider, PC2Effects, PC2Remarks, PC2Excts, LookupResult
5-
using Cthulhu.Testing: VirtualTerminal, TestHarness, @run, wait_for, read_next, end_terminal_session
6-
using Logging: with_logger, NullLogger
3+
using Cthulhu: Command, CthulhuConfig, CthulhuState, descend, find_callsites,
4+
find_method_instance, generate_code_instance, get_ci, get_inference_world,
5+
get_inlining_costs, get_override, get_pc_effects, get_pc_excts, get_pc_remarks,
6+
is_command_enabled, lookup, menu_commands, show_command, show_parameters
7+
using .CompilerIntegration: DefaultProvider, LookupResult, PC2Effects, PC2Excts, PC2Remarks
8+
using Cthulhu.Testing: @run, TestHarness, VirtualTerminal, end_terminal_session, read_next,
9+
wait_for
10+
using Logging: NullLogger, with_logger
711

812
function test_provider_api(provider, args...)
913
world = get_inference_world(provider)
@@ -59,9 +63,14 @@ function test_provider_api(provider, args...)
5963
end
6064
end
6165

66+
function default_config_kwargs()
67+
config = CthulhuConfig()
68+
return NamedTuple(name => getfield(config, name) for name in propertynames(config))
69+
end
70+
6271
function test_descend_for_provider(provider, args...; show = false)
6372
terminal = VirtualTerminal()
64-
harness = @run terminal descend(args...; terminal, provider)
73+
harness = @run terminal descend(args...; terminal, provider, default_config_kwargs()...)
6574
write(terminal, 'T')
6675
write(terminal, 'o') # optimize: on
6776
write(terminal, 'L')

0 commit comments

Comments
 (0)