20
20
close (io)
21
21
include (tmppath)
22
22
23
- using JuliaInterpreter, CodeTracking, Test
23
+ # Don't move these to the top, because line numbers matter for the tests below
24
+ using JuliaInterpreter, CodeTracking, Test, Logging
24
25
25
26
function stacklength (frame)
26
27
n = 1
@@ -215,7 +216,7 @@ struct Squarer end
215
216
end
216
217
fr, bp = @interpret f_outer_bp (3 )
217
218
@test leaf (fr). framecode. scope. name === :g_inner_bp
218
- @test bp. stmtidx == (@static VERSION >= v " 1.11-" ? 4 : 3 )
219
+ @test bp. stmtidx == (@static VERSION >= v " 1.12- " ? 5 : VERSION >= v " 1. 11-" ? 4 : 3 )
219
220
220
221
# Breakpoints on types
221
222
remove ()
@@ -247,25 +248,25 @@ mktemp() do path, io
247
248
include (path)
248
249
frame, bp = @interpret somefunc (2 , 3 )
249
250
@test bp isa BreakpointRef
250
- @test JuliaInterpreter . whereis (frame) == (path, 3 )
251
+ @test whereis (frame) == (path, 3 )
251
252
breakpoint (path, 2 )
252
253
frame, bp = @interpret somefunc (2 , 3 )
253
254
@test bp isa BreakpointRef
254
- @test JuliaInterpreter . whereis (frame) == (path, 2 )
255
+ @test whereis (frame) == (path, 2 )
255
256
remove ()
256
257
# Test relative paths
257
258
mktempdir (dirname (path)) do tmp
258
259
cd (tmp) do
259
260
breakpoint (joinpath (" .." , basename (path)), 3 )
260
261
frame, bp = @interpret somefunc (2 , 3 )
261
262
@test bp isa BreakpointRef
262
- @test JuliaInterpreter . whereis (frame) == (path, 3 )
263
+ @test whereis (frame) == (path, 3 )
263
264
remove ()
264
265
breakpoint (joinpath (" .." , basename (path)), 3 )
265
266
cd (homedir ()) do
266
267
frame, bp = @interpret somefunc (2 , 3 )
267
268
@test bp isa BreakpointRef
268
- @test JuliaInterpreter . whereis (frame) == (path, 3 )
269
+ @test whereis (frame) == (path, 3 )
269
270
end
270
271
end
271
272
end
@@ -302,7 +303,7 @@ using Dates
302
303
breakpoint (f, l)
303
304
frame, bp = @interpret now () - Month (2 )
304
305
@test bp isa BreakpointRef
305
- @test JuliaInterpreter . whereis (frame)[2 ] == l
306
+ @test whereis (frame)[2 ] == l
306
307
end
307
308
end
308
309
315
316
breakpoint (f, l)
316
317
frame, bp = @interpret sin (2.0 )
317
318
@test bp isa BreakpointRef
318
- @test JuliaInterpreter . whereis (frame)[2 ] == l
319
+ @test whereis (frame)[2 ] == l
319
320
end
320
321
end
321
322
499
500
bp = breakpoint (@__FILE__ , ln + 4 )
500
501
frame, bpref = @interpret f_emptylines ()
501
502
@test bpref isa BreakpointRef
502
- @test JuliaInterpreter . whereis (frame) == (@__FILE__ , ln + 6 )
503
+ @test whereis (frame) == (@__FILE__ , ln + 6 )
503
504
remove (bp)
504
505
505
506
# Don't break if the line is outside the function
@@ -518,23 +519,27 @@ end
518
519
frame = JuliaInterpreter. enter_call (f_macro)
519
520
file_logging = String (only (methods (var"@info" )). file)
520
521
line_logging = 0
521
- for entry in frame. framecode. src. linetable
522
- if entry. file === Symbol (file_logging)
523
- line_logging = entry. line
524
- break
522
+ lts = CodeTracking. linetable_scopes (JuliaInterpreter. scopeof (frame))
523
+ for lt in lts
524
+ for entry in lt
525
+ if entry. file === Symbol (file_logging)
526
+ line_logging = entry. line
527
+ break
528
+ end
525
529
end
530
+ line_logging > 0 && break
526
531
end
532
+ @assert line_logging > 0
527
533
bp_log = breakpoint (file_logging, line_logging)
528
534
with_logger (NullLogger ()) do
529
535
frame, bp = @interpret f_macro ()
530
536
@test bp isa BreakpointRef
531
- file, ln = JuliaInterpreter . whereis (frame)
537
+ file, ln = whereis (frame)
532
538
@test ln == line_logging
533
539
@test basename (file) == basename (file_logging)
534
540
bp = JuliaInterpreter. finish_stack! (frame)
535
541
@test bp isa BreakpointRef
536
- frame = leaf (frame)
537
- ret = JuliaInterpreter. finish_stack! (frame)
542
+ ret = JuliaInterpreter. finish_stack! (leaf (frame))
538
543
@test ret == 2
539
544
end
540
545
@@ -565,14 +570,14 @@ end
565
570
566
571
with_logger (NullLogger ()) do
567
572
frame, bp = @interpret f_check (1 )
568
- file, ln = JuliaInterpreter . whereis (frame)
573
+ file, ln = whereis (frame)
569
574
@test file == path # Should not have stopped in logging.jl at line `line_logging`
570
575
@test ln == line_logging
571
576
remove (bp_f)
572
577
@test (@interpret f_check (1 )) == 1
573
578
breakpoint (f_check, line_logging)
574
579
frame, bp = @interpret f_check (1 )
575
- file, ln = JuliaInterpreter . whereis (frame)
580
+ file, ln = whereis (frame)
576
581
@test file == path # Should not have stopped in logging.jl at line `line_logging`
577
582
@test ln == line_logging
578
583
end
0 commit comments