<?xml version='1.0' encoding='utf-8' ?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Social Memory Complex: tdd</title>
<link href="https://www.socialmemorycomplex.net/tags/tdd/feed.xml" rel="self" />
<link href="https://www.socialmemorycomplex.net/tags/tdd/" />
<updated>2026-05-24T21:17:06+00:00</updated>
<id>https://www.socialmemorycomplex.net/tags/tdd/</id>
<entry>
  <title>Add Sound to Autotest on OS X</title>
  <link href="http://socialmemorycomplex.net/2010/04/14/add-sound-to-autotest/" />
  <updated>2010-04-14T00:00:00+00:00</updated>
  <id>http://socialmemorycomplex.net/2010/04/14/add-sound-to-autotest/</id>
  <author><name>Jeremy Weiland</name></author>
  <content type="html"><![CDATA[<p>To me, development is all about communication. With clients and other developers, sure, but mostly with the computer itself. I’m trying to describe to the computer how to accomplish a task it does not have any capacity to understand or appreciate. On the other hand, the context of a given problem can be so natural to me that I have a hard time articulating it. Using <a href="https://github.com/grosser/autotest">autotest</a>, I can engage in a sort of conversation with the computer, where it tells me in real time as I program whether it understands what I’m telling it or not.</p>

<p>A Growl notification informing me of test results is great, and I can even tell Growl to play a sound when the notification is ready. But that sound tells me to look for the notification, not whether the tests pass or fail. To make this conversation more fluid, it would be nice if I had not just visual but also audio feedback which told me immediately what the test results were, instead of having to constantly context switch to the test results.</p>

<p>There have been a <a href="https://www.fozworks.com/2007/7/28/autotest-sound-effects">few</a> <a href="https://www.metaskills.net/2008/4/6/autotest-playlist-for-red-green-feedback">attempts</a> to do this already, but they all seem so complex. I found a simple command line sound file player called <a href="https://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man1/afplay.1.html">afplay</a> that makes all this trivial. In your ~/.autotest file, add the following:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>def play(filename, volume = ".15")
  system "afplay -v #{volume} /Users/jeremyweiland/.autotest_sounds/#{filename}.wav"
end
 
Autotest.add_hook :ran_command do |at|
  play(at.results.detect { |line| line.include?("0 failures, 0 errors") } ? "passed" : "failed")
end

Autotest.add_hook :run_command do |at|
  play("running")
end
</code></pre></div></div>

<p>This will play some select sounds when tests start running, pass, and fail. Just drop audio files in ~/.autotest_sounds and name them appropriately. Here are <a href="/media/dot-autotest_sounds.zip">my sounds</a> to get you started. The “play” method can be modified to use the “say” command or play any sound file you want.</p>

<p>I find that being able to use my ears to help have this difficult conversation helps me stay in the flow of the conversation more, where I do better and faster work.</p>
]]></content>
</entry>
</feed>
