debugging test-case

I thought it might be useful to do a stream-of-consciousness post about what a programmer does when he or she sees a bug and wants to fix it.

The bug in question is in DrScheme, and it’s triggered whenever one goes to the Special menu and runs an “Insert Test Case”. From that point on, the resulting program is uncompilable, with the following error message:

require: broken compiled code (phase 0, defn-phase 0): cannot find module |,/Users/dyoo/local/plt/collects/test-suite/private/test-case| in: test-case

The first thing I wanted to do was isolate the problem: what code is responsible? I knew the functionality in question had something to do with “Insert Test Case”, so let’s start there.

mithril:~ dyoo$ cd local/plt/collects/
mithril:~/local/plt/collects dyoo$ cd string-constants/
mithril:~/local/plt/collects/string-constants dyoo$ grep 'Insert Test Case' * (test-case-insert "Insert Test Case") (test-case-insert "Insert Test Case")

I had some previous knowledge that the menus in DrScheme were all internationalized, so I could start by searching through the string-constants directory to start my search. Whatever code uses test-case-insert is probably related, so we should start searching for occurrences of that now.

mithril:~/local/plt/collects/string-constants dyoo$ cd ..
mithril:~/local/plt/collects dyoo$ grep -r test-case-insert *

A bunch of output spews out, but I’ll ignore anything dealing with string constants; if I do that, I see that there’s a particular collection called test-suite, and that sounds promising.

Next thing to do: let’s see if anyone else has already tried looking at this, by searching Yup, there appear to be a few. Bugs 7001, 7317, and 7373 seem to be the same bug. Ok, time to read those bugs reports thoroughly just to make sure I understand what other people have said about this.

Ok, it looks like Robby mentioned a workaround: if the user enters:

(require (lib "" "test-suite" "private"))

then things should work out. Yup, I can verify that this works. But that seems really odd to have to do this!

I’ll start to look at test-suite and see what the overall flow of the program is.

[will fill in as soon as I finish doing a review]

[hours pass…]

Well, I traced the issue down to how the snips make external requirements that can’t always be met, especially in modularized code. I posted a question about it in the PLT list, and then, a few days later, they were obliterated altogether.
So, in summary: the code I studied is no longer relevant. It happens.


Merry Christmas to my family and friends! What I have been gifted with is much more than I expected or deserved. I’m thankful for everyone’s support and love.
I don’t have anything really programming-related to say (because my brain’s fried from debugging DivaScheme).

May your holidays be peaceful and without the need of an exception handler.

the moon

I woke up early on Saturday to catch the airport shuttle. It was one of those hours of the night when everything was still and dark, one of those magic weird moments.

I could see a crescent moon above me, like a sharp scythe. But have I really seen a scythe in real life? The only scythe I know is the one held by a Grim Reaper, and that’s clearly fantastical. I have no practical experience with them. So what else would be a good analogy from my own experience?

The moon looked like a large left parenthesis. As soon as that thought floated in my head, I knew. I was doomed.

Anyway, it’s nice to be in California again.


Every so often, a fey mood takes me, and I write a program that probably shouldn’t see the light of day. I’ve done so with a PLT package called infix. It’s a package for writing infix expressions in PLT Scheme, but it does some other funky stuff. For example:

(module test mzscheme
(require (planet "" ("dyoo" "infix.plt" 1 0)))

(infix printf("hello, this is a test: ~a ~a~n",
list(3, 4),

(define (in-order a b c)
(infix printf("in-order(~a, ~a, ~a): ~a~n",
a, b, c, a <= b <= c))) (infix in-order(1, 2, 3)) (infix in-order(1, 3, 2)))

I had a very good laugh with Guillaume when I showed this to him. You have to be a Schemer to appreciate how very wrong this is.

This technique is a proof-of-concept that shows just how programmable the PLT Scheme syntax system can be. It wouldn't be much more work to embed a different programming language syntax in here, as long as it's compatible with s-expressions. The source code for this can be found here.