 # TODO: Cleanup even if there were errors.  Use promises for sanity?
 #  Use a test runner with guaranteed pre/post methods?
 
-test = (cb) ->
+test = (url, cb) ->
   # Kludge: set to failed first, change to passed if we get to the end without crashing.
   browser.sauceJobStatus false, ->
-    browser.get 'http://localhost:8000/?doc=_mathdown_test_smoke', (err) ->
+    browser.get url + '?doc=_mathdown_test_smoke', (err) ->
       assert.ifError(err)
       browser.waitFor wd.asserters.jsCondition('document.title.match(/smoke test/)'), 10000, (err, value) ->
         assert.ifError(err)

  console.log(desired)
  browser.init desired, (err) ->
    assert.ifError(err)
    test ->
      browser.quit()
      server.close()
      tunnel.stop ->
        console.log(chalk.green('Cleaned up.'))

assert = require('assert')
chalk = require('chalk')

# 'mathdown' is a sub-account I created.
sauceUser = process.env.SAUCE_USERNAME || 'mathdown'
# I hope storing this in a public test is OK given that an Open Sauce account
# is free anyway.  Can always revoke if needed...
