Skip to content

Commit c0dc08f

Browse files
committed
Adapt to testset handling on Julia 1.13
1 parent cbfd87e commit c0dc08f

File tree

1 file changed

+55
-44
lines changed

1 file changed

+55
-44
lines changed

testprocess/TestItemServer/src/TestItemServer.jl

Lines changed: 55 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -333,68 +333,79 @@ function run_testitem(endpoint, params::TestItemServerProtocol.RunTestItem, mode
333333

334334
code = string('\n'^(params.line-1), ' '^(params.column-1), params.code)
335335

336-
ts = Test.DefaultTestSet("$filepath:$(params.name)")
337-
338-
Test.push_testset(ts)
339336

340337
elapsed_time = UInt64(0)
341338

342-
t0 = time_ns()
343-
try
344-
withpath(filepath) do
339+
const inner_test_function = () -> begin
340+
t0 = time_ns()
341+
try
342+
withpath(filepath) do
345343

346-
if mode == "Debug"
347-
debug_session = wait_for_debug_session()
348-
DebugAdapter.debug_code(debug_session, mod, code, filepath)
349-
else
350-
mode == "Coverage" && clear_coverage_data()
351-
try
352-
Base.invokelatest(include_string, mod, code, filepath)
353-
finally
354-
mode == "Coverage" && collect_coverage_data!(coverage_results, coverage_root_uris)
344+
if mode == "Debug"
345+
debug_session = wait_for_debug_session()
346+
DebugAdapter.debug_code(debug_session, mod, code, filepath)
347+
else
348+
mode == "Coverage" && clear_coverage_data()
349+
try
350+
Base.invokelatest(include_string, mod, code, filepath)
351+
finally
352+
mode == "Coverage" && collect_coverage_data!(coverage_results, coverage_root_uris)
353+
end
355354
end
355+
elapsed_time = (time_ns() - t0) / 1e6 # Convert to milliseconds
356356
end
357+
catch err
357358
elapsed_time = (time_ns() - t0) / 1e6 # Convert to milliseconds
358-
end
359-
catch err
360-
elapsed_time = (time_ns() - t0) / 1e6 # Convert to milliseconds
361359

362-
Test.pop_testset()
360+
Test.pop_testset()
363361

364-
bt = catch_backtrace()
365-
st = stacktrace(bt)
362+
bt = catch_backtrace()
363+
st = stacktrace(bt)
366364

367-
error_message = format_error_message(err, bt)
365+
error_message = format_error_message(err, bt)
368366

369367

370368

371-
if err isa LoadError
372-
error_filepath = err.file
373-
error_line = err.line
374-
else
375-
error_filepath = string(st[1].file)
376-
error_line = st[1].line
377-
end
369+
if err isa LoadError
370+
error_filepath = err.file
371+
error_line = err.line
372+
else
373+
error_filepath = string(st[1].file)
374+
error_line = st[1].line
375+
end
378376

379-
return (
380-
TestItemServerProtocol.errored_notification_type,
381-
TestItemServerProtocol.ErroredParams(
382-
testItemId = params.id,
383-
messages = [
384-
TestItemServerProtocol.TestMessage(
385-
error_message,
386-
TestItemServerProtocol.Location(
387-
isabspath(error_filepath) ? filepath2uri(error_filepath) : "",
388-
TestItemServerProtocol.Position(max(1, error_line), 1)
377+
return (
378+
TestItemServerProtocol.errored_notification_type,
379+
TestItemServerProtocol.ErroredParams(
380+
testItemId = params.id,
381+
messages = [
382+
TestItemServerProtocol.TestMessage(
383+
error_message,
384+
TestItemServerProtocol.Location(
385+
isabspath(error_filepath) ? filepath2uri(error_filepath) : "",
386+
TestItemServerProtocol.Position(max(1, error_line), 1)
387+
)
389388
)
390-
)
391-
],
392-
duration = missing
389+
],
390+
duration = missing
391+
)
393392
)
394-
)
393+
end
395394
end
396395

397-
ts = Test.pop_testset()
396+
ts = Test.DefaultTestSet("$filepath:$(params.name)")
397+
398+
@static if VERSION < v"1.13.0-"
399+
Test.push_testset(ts)
400+
401+
inner_test_function()
402+
403+
ts = Test.pop_testset()
404+
else
405+
Test.@with_testset ts begin
406+
inner_test_function()
407+
end
408+
end
398409

399410
try
400411
Test.finish(ts)

0 commit comments

Comments
 (0)