   if status is 'success'
     test = ->
       page.evaluate(
-        (packNames, date, buildId, gitHash, gitBranch, hostname, ncpu, os, jobName, perf, excludeFlowNames) ->
+        (packNames, date, buildId, gitHash, gitBranch, hostname, ncpu, os, jobName, perf, excludeFlowsNames) ->
           window._date = date
           window._buildId = buildId
           window._gitHash = gitHash

                  (Flow.Async.iterate tasks) go

            runFlow = (packName, flowName, go) ->
              doFlow = (flowName, excludeFlowNames) ->
                for f in excludeFlowNames
                  return false if flowName is f
                true

              if doFlow flowName, window._excludeFlowNames
                flowTitle = "#{packName} - #{flowName}"
                window._phantom_test_summary_[flowTitle] = 'FAILED'
                console.log "Fetching flow document: #{packName} - #{flowName}..."

parseOpts = (args) ->
  console.log "Using args #{args.join ' '}"
  i = 0
  opts = {}
  while i < args.length
    if args[i] == "--host"
      i = i + 1
      if i > args.length then printUsageAndExit "Unknown argument: #{args[i]}"
      opts['hostname'] = args[i]
    else if args[i] == "--timeout"
      i = i + 1
      if i > args.length then printUsageAndExit "Unknown argument: #{args[i]}"
      opts['timeout'] = args[i]
    else if args[i] == "--packs"
      i = i + 1
      if i > args.length then printUsageAndExit "Unknown argument: #{args[i]}"
      opts['packs'] = args[i]
    else if args[i] == "--perf"
      opts['perf'] = true
      i = i + 1
      if i > args.length then printUsageAndExit "Unknown argument: #{args[i]}"
      opts['date'] = args[i]
      i = i + 1
      if i > args.length then printUsageAndExit "Unknown argument: #{args[i]}"
      opts['buildId'] = args[i]
      i = i + 1
      if i > args.length then printUsageAndExit "Unknown argument: #{args[i]}"
      opts['gitHash'] = args[i]
      i = i + 1
      if i > args.length then printUsageAndExit "Unknown argument: #{args[i]}"
      opts['gitBranch'] = args[i]
      i = i + 1
      if i > args.length then printUsageAndExit "Unknown argument: #{args[i]}"
      opts['ncpu'] = args[i]
      i = i + 1
      if i > args.length then printUsageAndExit "Unknown argument: #{args[i]}"
      opts['os'] = args[i]
      i = i + 1
      if i > args.length then printUsageAndExit "Unknown argument: #{args[i]}"
      opts['jobName'] = args[i]
      i = i + 1
      if i > args.length then printUsageAndExit "Unknown argument: #{args[i]}"
      opts['outputDir'] = args[i]
    else if args[i] == "--excludeFlows"
      i = i + 1
      if i > args.length then printUsageAndExit "Unknown argument: #{args[i]}"
      opts['excludeFlows'] = args[i]
    else
      printUsageAndExit "Unknown argument: #{args[i]}"
    i = i + 1
  opts

opts = parseOpts system.args[1..]

hostname = opts['hostname'] ? 'localhost:54321'
console.log "PHANTOM: Using #{hostname}"

timeout = if timeoutArg = opts['timeout']
  1000 * parseInt timeoutArg, 10
else
  3600000
console.log "PHANTOM: Using timeout #{timeout}ms"

packsArg = opts['packs']
packNames = if packsArg
  packsArg.split ':'
else
  ['examples']

excludeFlowsArg = opts['excludeFlows']
excludeFlowsNames = if excludeFlowsArg
  excludeFlowsArg.split ';'
else
  []
for excludeFlowName in excludeFlowsNames
  console.log "PHANTOM: Excluding flow: #{excludeFlowName}"

page = webpage.create()

if opts['perf']
  console.log "PHANTOM: Performance of individual tests will be recorded in perf.csv in output directory: \
               #{opts['outputDir']}."
  page._outputDir = opts['outputDir']

page.onResourceError = ({ url, errorString }) ->
  console.log "BROWSER: *** RESOURCE ERROR *** #{url}: #{errorString}"
