summaryrefslogtreecommitdiff
path: root/bin/test
blob: 602748594c48fc78e95b8690de3ddf94362263fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh

# bin/test: Run test suite for application. Optionally pass in a path to an
#              individual test file to run a single test.

set -e

cd "$(dirname "$0")/.."

[ -z "$DEBUG" ] || set -x

RACK_ROOT="$(cd "$(dirname "$0")"/.. && pwd)"
export RACK_ROOT

if [ "$RAILS_ENV" = "test" ] || [ "$RACK_ENV" = "test" ]; then
  # if executed and the environment is already set to `test`, then we want a
  # clean from scratch application. This almost always means a ci environment,
  # since we set the environment to `test` directly in `bin/cibuild`.
  bin/setup
else
  # if the environment isn't set to `test`, set it to `test` and update the
  # application to ensure all dependencies are met as well as any other things
  # that need to be up to date, like db migrations. The environment not having
  # already been set to `test` almost always means this is being called on it's
  # own from a `development` environment.
  export RAILS_ENV="test" RACK_ENV="test"

  bin/update
fi

echo "==> Running webpack…"
bin/webpack
echo "==> Running tests…"

if [ -n "$1" ]; then
  # pass arguments to test call. This is useful for calling a single test.
  bin/rspec "$1"
else
  bin/rake test
  bin/yarn test
fi