forked from heroku/heroku-buildpack-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test
executable file
·50 lines (45 loc) · 2.32 KB
/
test
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
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
# bin/test <build-dir> <env-dir>
# env vars are passed in already, so we can ignore the dir
# fail hard
set -o pipefail
# fail harder
set -eu
# unlike a regular app.json "test" script, this one isn't run with the app dir as the CWD
# we `cd` with a default value, so that the script can also be called from inside the app dir (`cd ""` does not change cwd)
cd "${1-}"
ram=$(cat "/sys/fs/cgroup/memory/memory.limit_in_bytes" || true)
if [[ -n "$ram" ]]; then
export COMPOSER_MEMORY_LIMIT="$ram"
fi
export COMPOSER_PROCESS_TIMEOUT=0
echo "Trying to auto-detect test framework; first match will be found. You may use composer script 'test', or app.json, to specify what to run." >&2
# 'composer run-script -l' prints a "scripts:" header on stderr...
if composer run-script -l 2> /dev/null | grep -q -- "^\s*test\b"; then
echo "Script 'composer test' found, executing..." >&2
composer run-script test
elif composer exec -l | grep -q -- "^-\s*codecept\b"; then
echo "Codeception found, executing 'codecept run'..." >&2
composer exec -v codecept run # without -v, no stderr output is printed
elif composer exec -l | grep -q -- "^-\s*behat\b"; then
echo "Behat found, executing 'behat'..." >&2
composer exec -v behat # without -v, no stderr output is printed
elif composer exec -l | grep -q -- "^-\s*phpspec\b"; then
echo "PHPSpec found, executing 'phpspec run'..." >&2
composer exec -v phpspec run # without -v, no stderr output is printed
elif composer exec -l | grep -q -- "^-\s*atoum\b"; then
echo "atoum found, executing 'atoum'..." >&2
composer exec -v atoum # without -v, no stderr output is printed
elif composer exec -l | grep -q -- "^-\s*kahlan\b"; then
echo "Kahlan found, executing 'kahlan'..." >&2
composer exec -v kahlan # without -v, no stderr output is printed
elif composer exec -l | grep -q -- "^-\s*peridot\b"; then
echo "Peridot found, executing 'peridot'..." >&2
composer exec -v peridot # without -v, no stderr output is printed
elif composer exec -l | grep -q -- "^-\s*phpunit\b"; then
echo "PHPUnit found, executing 'phpunit'..." >&2
composer exec -v phpunit # -dmemory_limit="${ram:-"-1"}" # composer exec -- is currently broken, so we can't pass -d to phpunit # without -v, no stderr output is printed
else
echo "No tests found. Please use composer script 'test', or app.json, to specify what to run." >&2
exit 1
fi