Skip to content

Commit

Permalink
Improve dynamic require of requires analysis
Browse files Browse the repository at this point in the history
Skip tests when unavailable.

Issue error, if any, on the command thread so message is reflected up
to Emacs for users to see.
  • Loading branch information
greghendershott committed Jan 21, 2025
1 parent 3fc47b3 commit 7ce568d
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions racket/commands/requires.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -61,36 +61,39 @@
;; derivation-parser: error on token #2: <local-value,
;;#<syntax:/usr/share/racket/collects/syntax/parse/private/lib.rkt:63:55
;;-string>>
(when (version<=? "8.14" (version))
(check-equal?
(requires/trim p)
'((delete 174 17)
(replace
129
44
"(require net/url\n (combine-in net/url\n racket/format))")
(replace 39 42 "(require net/uri-codec\n net/url)")))
(check-equal?
(requires/base p)
'((delete 174 17)
(replace
129
44
"(require (for-syntax racket/base)\n net/url\n (combine-in net/url\n racket/format)\n racket/list\n racket/match)")
(replace 39 42 "(require net/uri-codec\n net/url)"))))))
(cond
[(and show-requires
(version<=? "8.14" (version)))
(check-equal?
(requires/trim p)
'((delete 174 17)
(replace
129
44
"(require net/url\n (combine-in net/url\n racket/format))")
(replace 39 42 "(require net/uri-codec\n net/url)")))
(check-equal?
(requires/base p)
'((delete 174 17)
(replace
129
44
"(require (for-syntax racket/base)\n net/url\n (combine-in net/url\n racket/format)\n racket/list\n racket/match)")
(replace 39 42 "(require net/uri-codec\n net/url)")))]
[else
(displayln "Skipping requires analysis tests")])))

;;; analysis by macro-debugger/analysis/check-requires

(define (error-thunk)
(error 'requires
"Cannot work until you `raco pkg install macro-debugger-lib`"))

(define show-requires
(safe-dynamic-require 'macro-debugger/analysis/check-requires
'show-requires
error-thunk))
(λ () #f)))

(define (analyze path-str)
(unless show-requires
(error 'analyze-requires
"Cannot work until you `raco pkg install macro-debugger-text-lib`"))
(define-values (base name _) (split-path (string->path path-str)))
(parameterize ([current-load-relative-directory base]
[current-directory base])
Expand Down

0 comments on commit 7ce568d

Please sign in to comment.