Saturday, December 11, 2010

A Ridiculously Recursive Bug

Work has been going on to get Emscripten to compile CPython (the standard implementation of Python) into JavaScript. It's very close to working, so I started to write an automatic test. But the test failed even though running the test manually worked.

That's weird, I thought.

Turns out that something quite amusing was happening. The automatic test system and other scripts are written in Python, and the test runner checks for script crashes and failures by scanning for the text that appears in a Python stack trace, which is to say something like 'Traceback (most recent call last)' etc.

Now, when Emscripten compiles Python itself, it generates JavaScript code that includes, unsurprisingly, all the constant strings in Python - including that very string! So the right output was erroneously detected as a failure.

I guess that's what can happen if your test compiles the very same runtime in which the test infrastructure is built... ;)

No comments:

Post a Comment

Post a Comment