Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test engine links incorrect source location for check-expects in REPL #231

Open
shhyou opened this issue Oct 26, 2024 · 7 comments
Open
Labels
test engine topics related to the test engine

Comments

@shhyou
Copy link
Collaborator

shhyou commented Oct 26, 2024

The test engine source hyperlinks are not working for check-expects in REPL.

;; Unsaved editor
#lang htdp/isl+

;; -> Run
Welcome to DrRacket, version 8.15.0.2 [cs].
Language: htdp/isl+, with debugging; memory limit: 128 MB.
> (check-expect (+ 2 3) 6)
Ran 1 test.
0 tests passed.

Check failures:
        Actual value 5 differs from 6, the expected value.
at line 3, column 2

;; -> Click on "at line 3, column 2"

Expected behavior: highlight the failing check-expect
Actual behavior:

  • In a saved editor: nothing happened also got the error message
  • In an unsaved editor: got error message:
send: no such method
  method name: get-tab
  class name: test-interactions-text%-mixin175
  context...:
   <collects>/racket/private/class-internal.rkt:4730:0: obj-error
   <pkgs>/framework/private/srcloc-snip.rkt:36:2: show-editor
   <pkgs>/framework/private/srcloc-snip.rkt:20:4: frame-loop
   <pkgs>/mred/private/wxme/text.rkt:537:2: on-default-event method in text%
   <pkgs>/mred/private/wxme/editor-canvas.rkt:412:2: on-event method in editor-canvas%
   <collects>/racket/private/more-scheme.rkt:148:2: call-with-break-parameterization
   <collects>/racket/private/more-scheme.rkt:266:2: call-with-exception-handler
   <pkgs>/mred/private/wx/cocoa/window.rkt:899:4: dispatch-on-event method in window%
   <pkgs>/mred/private/wx/common/queue.rkt:436:6
   <pkgs>/mred/private/wx/common/queue.rkt:487:32
   <pkgs>/mred/private/wx/common/queue.rkt:639:3
@shhyou shhyou added the test engine topics related to the test engine label Oct 26, 2024
@mfelleisen
Copy link
Contributor

@rfindler

i know this investigation but the meta-error message about get-tab seems to suggest this is a miscommunication among some drracke comments.

@rfindler
Copy link
Member

I'm having trouble reproducing the error. It seems like, when I create a new frame and don't hit Run the button (but because the language was already set I'll have a REPL) and then I evaluate a failing check-expect, I get a nearby error, but it seems to happen on the line after the one in @shhyou 's report (below).

Is it possible I'm missing a step to reproduce?

send: target is not an object
  target: #f
  method name: get-frame
  context...:
   /Users/robby/git/plt/racket/collects/racket/private/class-internal.rkt:4730:0: obj-error
   /Users/robby/git/plt/extra-pkgs/gui/gui-lib/framework/private/srcloc-snip.rkt:36:2: show-editor
   /Users/robby/git/plt/extra-pkgs/gui/gui-lib/framework/private/srcloc-snip.rkt:20:4: frame-loop
   /Users/robby/git/plt/extra-pkgs/gui/gui-lib/mred/private/wxme/text.rkt:537:2: on-default-event method in text%
   /Users/robby/git/plt/extra-pkgs/gui/gui-lib/mred/private/wxme/editor-canvas.rkt:412:2: on-event method in editor-canvas%
   /Users/robby/git/plt/racket/collects/racket/private/more-scheme.rkt:148:2: call-with-break-parameterization
   /Users/robby/git/plt/racket/collects/racket/private/more-scheme.rkt:266:2: call-with-exception-handler
   /Users/robby/git/plt/extra-pkgs/gui/gui-lib/mred/private/wx/cocoa/window.rkt:899:4: dispatch-on-event method in window%
   /Users/robby/git/plt/extra-pkgs/gui/gui-lib/mred/private/wx/common/queue.rkt:436:6
   /Users/robby/git/plt/extra-pkgs/gui/gui-lib/mred/private/wx/common/queue.rkt:487:32
   /Users/robby/git/plt/extra-pkgs/gui/gui-lib/mred/private/wx/common/queue.rkt:639:3

@rfindler
Copy link
Member

Does this change make a difference?

diff --git a/gui-lib/framework/private/srcloc-snip.rkt b/gui-lib/framework/private/srcloc-snip.rkt
index ee6cbd17..92ca4308 100644
--- a/gui-lib/framework/private/srcloc-snip.rkt
+++ b/gui-lib/framework/private/srcloc-snip.rkt
@@ -33,7 +33,11 @@
             [else
              (frame-loop (cdr frames))])))))
 
-  (define (show-editor frame editor)
+  (define (show-editor frame _editor)
+    (define editor
+      (if (method-in-interface? 'get-definitions-text (object-interface _editor))
+          (send _editor get-definitions-text)
+          _editor))
     (let* ([current-tab (send editor get-tab)]
            [frame (send current-tab get-frame)])
       (let loop ([tabs (send frame get-tabs)] [i 0])

@rfindler
Copy link
Member

Also, as I'm looking at this code, it does seem a little weird. It definitely expects that DrRacket-specific methods are existing on the frame but it is part of the framework. So probably it should either move into DrRacket somehow, or it should change to use only framework functionality (and check for that functionality's existence).

The latter option can't be done entirely, tho, because the framework doesn't have an equivalent of the highlight-error method on the interactions window. It may be possible to abstract over that functionality and pass in a function to the constructor of a srcloc snip that defaults to just, say, setting the position or something.

@shhyou
Copy link
Collaborator Author

shhyou commented Oct 27, 2024

I'm having trouble reproducing the error. It seems like, when I create a new frame and don't hit Run the button (but because the language was already set I'll have a REPL) and then I evaluate a failing check-expect, I get a nearby error, but it seems to happen on the line after the one in @shhyou 's report (below).

Is it possible I'm missing a step to reproduce?

I am using #lang based SLs. Menu-based SLs don't have this issue.

The latter option can't be done entirely, tho, because the framework doesn't have an equivalent of the highlight-error method on the interactions window. It may be possible to abstract over that functionality and pass in a function to the constructor of a srcloc snip that defaults to just, say, setting the position or something.

Meanwhile, highlighting after clicking the hyperlink is currently working in menu-based SLs. Can #lang based SLs use the same mechanism?

@shhyou
Copy link
Collaborator Author

shhyou commented Oct 29, 2024

So here's the configuration to reproduce the error:

  1. Language -> Choose Language -> Automatic #lang line:
    • Select _Always use the same #lang line: #lang racket/base
  2. TURN OFF the Graphical Debugger PLUGIN

The dependency on step 2 is totally unexpected!

rfindler added a commit to racket/gui that referenced this issue Oct 29, 2024
and then use that generalization inside srcloc-snip

related to racket/htdp#231
rfindler added a commit to racket/drracket that referenced this issue Oct 29, 2024
@rfindler
Copy link
Member

I pushed some changes that should help the situation here.

One difference: the highlights are now based on the selection, not using pink highlighting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test engine topics related to the test engine
Projects
None yet
Development

No branches or pull requests

3 participants