#! /bin/bash -ex

test $MOZHARNESS_REPOSITORY # mozharness repository
test $MOZHARNESS_REV # mozharness revision

# This file is intended to be used as the "entrypoint" or first command in the
# docker image. It uses "eval" so it takes place of the usual /bin/bash -c
# <stuff> conventions you need when running a docker image. Primarily it
# bootstraps any processes that need to run outside of mozharness (like Xvfb)

# XXX: Note that all tests could be faster at smaller bit depth
Xvfb :0 -nolisten tcp -screen 0 1600x1200x24 2>/dev/null &
export DISPLAY=:0

pulseaudio --start

# First check if the mozharness directory is available. This is intended to be
# used locally in development to test mozharness changes:
#
#   $ docker -v your_mozharness:/home/worker/mozharness ...
#
if [ ! -d mozharness ]; then
  buildbot_step 'Checkout mozharness' tc-vcs checkout mozharness $MOZHARNESS_REPOSITORY $MOZHARNESS_REPOSITORY $MOZHARNESS_REV
fi

buildbot_step 'Running tests' $@
