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

Differences when running check-error tests in DrRacket IDE vs raco test #242

Open
muzimuzhi opened this issue Feb 10, 2025 · 1 comment
Open
Labels
bug test engine topics related to the test engine

Comments

@muzimuzhi
Copy link
Contributor

muzimuzhi commented Feb 10, 2025

For check-error-tests.rkt consisting of 5 check-error tests

; This is check-error-tests.rkt
#lang htdp/bsl

(check-error (* (5) 3)
             "function call: expected a function after the open parenthesis, but found a number")

(check-error (+ (* 2 4))
             "+: expects at least 2 arguments, but found only 1")

(check-error (5 * 14)
             "function call: expected a function after the open parenthesis, but found a number")

(check-error (* + 3 5 2)
             "+: expected a function call, but there is no open parenthesis before this function")

(check-error (/ 25 0)
             "/: division by zero")

(The 5 erroneous expression are taken from A Functional Introduction To Computer Science (Part I) by Prabhakar Ragde, sec. 2.2, Exercise 0.)

Running it in DrRacket, "All 5 tests passed!".

But if executing raco test check-error-tests.rkt, the 1st, 3rd, and the 4th tests failed.

Full command-line output

$ raco test check-error-tests.rkt
raco test: (submod (file "check-error-tests.rkt") test)
Ran 5 tests.
3 of the 5 tests failed.
Check failures:
        check-error encountered the following error instead of the expected function call: expected a function after the open parenthesis, but found a number
              check-error-tests.rkt:3:17: function call: expected a function after the open parenthesis, but found a number
                at: 5
                in: (#%app 5)
                location...:
                 check-error-tests.rkt:3:17
                context...:
                 /Applications/Racket v8.15/share/pkgs/htdp-lib/test-engine/syntax.rkt:65:25
                 /Applications/Racket v8.15/share/pkgs/htdp-lib/test-engine/racket-tests.rkt:247:5
           ::    /Applications/Racket v8.15/share/pkgs/htdp-lib/test-engine/syntax.rkt:91:17
                 /Applications/Racket v8.15/share/pkgs/htdp-lib/test-engine/syntax.rkt:89:0: execute-test
                 /Applications/Racket v8.15/collects/racket/contract/private/arrow-higher-order.rkt:379:33
                 /Applications/Racket v8.15/share/pkgs/htdp-lib/test-engine/test-engine.rkt:182:14
                 /Applications/Racket v8.15/share/pkgs/htdp-lib/test-engine/test-engine.rkt:175:0: run-tests!
                 /Applications/Racket v8.15/collects/racket/contract/private/arrow-val-first.rkt:486:18
                 /Applications/Racket v8.15/share/pkgs/htdp-lib/test-engine/syntax.rkt:128:0: test*
                 body of (submod "/path/to/file/check-error-tests.rkt" test)
                 /Applications/Racket v8.15/share/pkgs/compiler-lib/compiler/commands/test.rkt:209:16
in check-error-tests.rkt, line 3, column 0
        check-error encountered the following error instead of the expected function call: expected a function after the open parenthesis, but found a number
              check-error-tests.rkt:9:14: function call: expected a function after the open parenthesis, but found a number
                at: 5
                in: (#%app 5 * 14)
                location...:
                 check-error-tests.rkt:9:14
                context...:
                 /Applications/Racket v8.15/share/pkgs/htdp-lib/test-engine/syntax.rkt:65:25
                 /Applications/Racket v8.15/share/pkgs/htdp-lib/test-engine/racket-tests.rkt:247:5
           ::    /Applications/Racket v8.15/share/pkgs/htdp-lib/test-engine/syntax.rkt:91:17
                 /Applications/Racket v8.15/share/pkgs/htdp-lib/test-engine/syntax.rkt:89:0: execute-test
                 /Applications/Racket v8.15/collects/racket/contract/private/arrow-higher-order.rkt:379:33
                 /Applications/Racket v8.15/share/pkgs/htdp-lib/test-engine/test-engine.rkt:182:14
                 /Applications/Racket v8.15/share/pkgs/htdp-lib/test-engine/test-engine.rkt:175:0: run-tests!
                 /Applications/Racket v8.15/collects/racket/contract/private/arrow-val-first.rkt:486:18
                 /Applications/Racket v8.15/share/pkgs/htdp-lib/test-engine/syntax.rkt:128:0: test*
                 body of (submod "/path/to/file/check-error-tests.rkt" test)
                 /Applications/Racket v8.15/share/pkgs/compiler-lib/compiler/commands/test.rkt:209:16
in check-error-tests.rkt, line 9, column 0
        check-error encountered the following error instead of the expected +: expected a function call, but there is no open parenthesis before this function
              check-error-tests.rkt:12:16: +: expected a function call, but there is no open parenthesis before this function
                in: +
                location...:
                 check-error-tests.rkt:12:16
                context...:
                 /Applications/Racket v8.15/share/pkgs/htdp-lib/test-engine/syntax.rkt:65:25
                 /Applications/Racket v8.15/share/pkgs/htdp-lib/test-engine/racket-tests.rkt:247:5
           ::    /Applications/Racket v8.15/share/pkgs/htdp-lib/test-engine/syntax.rkt:91:17
                 /Applications/Racket v8.15/share/pkgs/htdp-lib/test-engine/syntax.rkt:89:0: execute-test
                 /Applications/Racket v8.15/collects/racket/contract/private/arrow-higher-order.rkt:379:33
                 /Applications/Racket v8.15/share/pkgs/htdp-lib/test-engine/test-engine.rkt:182:14
                 /Applications/Racket v8.15/share/pkgs/htdp-lib/test-engine/test-engine.rkt:175:0: run-tests!
                 /Applications/Racket v8.15/collects/racket/contract/private/arrow-val-first.rkt:486:18
                 /Applications/Racket v8.15/share/pkgs/htdp-lib/test-engine/syntax.rkt:128:0: test*
                 body of (submod "/path/to/file/check-error-tests.rkt" test)
                 /Applications/Racket v8.15/share/pkgs/compiler-lib/compiler/commands/test.rkt:209:16
in check-error-tests.rkt, line 12, column 0

@muzimuzhi muzimuzhi changed the title Differences when running check-error test in DrRacket IDE vs raco test Differences when running check-error tests in DrRacket IDE vs raco test Feb 10, 2025
@shhyou shhyou added bug test engine topics related to the test engine labels Feb 11, 2025
@shhyou
Copy link
Collaborator

shhyou commented Feb 12, 2025

Not sure whether it's related to DrRacket having a different error-display-handler.

Here is a minimal example. It works in DrRacket and fails from command line.

; This is stxerr.rkt
#lang htdp/bsl
(check-error define "define: expected an open parenthesis before define, but found none")

Here is an alternative example that FAILS in DrRacket and WORKS from the command line.

; This is stxerr.rkt
#lang htdp/bsl
(check-error define "stxerr.rkt:3:13: define: expected an open parenthesis before define, but found none\n  in: define")

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

No branches or pull requests

2 participants