Weird test failures

21 views
Skip to first unread message

Joel Dueck

unread,
Oct 24, 2021, 12:09:29 PM10/24/21
to Racket Users
This is driving me a little batty. I have a package on the package server, and the package server shows that it is failing some tests[1].

Here is the first test that fails:

FAILURE
name:       check-equal?
location:   dust.rkt:101:2
actual:
  '(div (div ((type "text"))
     "Judy's friend \"George\""
     (div "Judy's friend \"George\"")))
expected:
  '(div (div ((type "text"))
     "Judy%amp%apos;s friend %amp%quot;George%amp%quot;"
     (div "Judy's friend \"George\"")))

The check in question can be seen in dust.rkt on the Github repo [2]. 

Here’s the weird part. This check does not fail on my local machine (Racket 8.2 CS on Mac OS 11.6). Well…not true! It *usually* doesn’t fail on my computer BUT sometimes checks in my tests.rkt which are dependent on this one will start failing. When that happens, all I need to do is re-save dust.rkt with no changes (to invalidate the compile cache) and re-run tests.rkt and the checks all pass again.

Of what known gotcha have I run afoul here? Or is it an unknown gotcha?

The function which is the subject of the test is not complicated:

;; Recursively pre-escape any string entities in an x-expression that
;; are direct children of an element whose ‘type’ attribute is “text”
(define (pre-escape x)
  (cond 
    [(and (txexpr? x) (eq? "text" (attr-ref x 'type #f)))
     (txexpr
      (car x)
      (get-attrs x)
      (map (λ (c) (if (string? c) (pre-escape-entities c) (pre-escape c))) (get-elements x)))]
    [(txexpr? x) (txexpr (car x) (get-attrs x) (map pre-escape (get-elements x)))]
    [else x]))


Sage Gerard

unread,
Oct 24, 2021, 2:04:03 PM10/24/21
to racket...@googlegroups.com
I got all tests to pass by updating the first clause of pre-escape to use equal?

> (and (txexpr? x) (equal? "text" (attr-ref x 'type #f)))

My hypothesis is that when you didn't have bytecode, the reference to the literal string "text" just happened to be eq?. I couldn't say why.

--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/10b7621b-c366-4c78-ac86-f011d46a954fn%40googlegroups.com.

Joel Dueck

unread,
Oct 24, 2021, 2:34:38 PM10/24/21
to Racket Users
Dang it, I think you’re right. Known gotcha it is, and a rookie one at that. Thanks for taking time to look at it!
Reply all
Reply to author
Forward
0 new messages