Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What other languages/frameworks have similar tools?

I wrote something like this for cgi-bin scripts in 1996. Problem: you don't necessarily see everything happening in the browser, especially someone else's, especially if they're remote (or unknown), and the only evidence might be a a line in the error log. "playback <script>" would create a wrapper script that saved all environment/server variables and POST data to a file (for later playback) and then call the original script. When run from the command line or debugger, a file containing the selected playback info would be "re-hydrated" into the proper settings, and then call the original script, and it would run as it had previously on the server.

There was a library to extend this to arbitrary data (within the framework). The idiom was something like (after some initial setup):

  if ( $PLAYBACK_MODE ) {
    $result1 = get_playback_value('result1');
  } else {
     $result1 = normal_function_call();
     save_playback_value('result1', $result1);
  }
Which is pretty much portable to any language. If your language supports it, maybe automagically wrap normal_function_call so the caller doesn't have to--if you want this for every call. Recording multiple values could be done by appending something to the identifier (e.g. "result1:$i"). Generally, too much data collected in tight loops (or every db request, etc.), but you could programmatically turn it on in certain cases, only save after an assertion has failed, etc.

Playback use can be great for debugging, somewhere in between unit tests and end-to-end testing, kind of like a mock for medium-level complexity. Decouple data, events, etc. from the context in which they occur ("the real world") for later examination in a more controlled environment. Helping make irreproducible results more produceable.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: