forked from civicrm/civicrm-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjmat
executable file
·105 lines (86 loc) · 3.37 KB
/
jmat
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
####################################################################
function show_help() {
echo "Jeanine Matthews - Divergent Hunter"
echo "summary: Execute test suite in multiple ways and compare results"
echo "usage: env [var1=... var2=...] $0 [--bundled-full|--bf] [--bundled-indiv|--bi] [--standalone-full|--sf] [--standalone-indiv|--si] [--compare]"
echo "Optional variables:"
echo " - CIVI: Path to Civi installation [$CIVI]"
echo " - PHP: Path to PHP binary [$PHP]"
echo " - PHPUNIT: Path to phpunit binary [$PHPUNIT]"
echo " - TESTCLASS: PHP class name for the test case/suite [$TESTCLASS]"
echo " - TESTPATH: Path for the test file/directory (Note: MUST match TESTCLASS) [$TESTPATH]"
echo " - OUTDIR: Folder to which outputs are written [$OUTDIR]"
}
function reset_dir() {
[ -d "$1" ] && rm -rf "$1"
mkdir -p "$1"
}
####################################################################
## Env
export PHP=${PHP:-php}
export PHPUNIT=${PHPUNIT:-phpunit}
export TESTCLASS=${TESTCLASS:-api_v3_AllTests}
export TESTPATH=${TESTPATH:-tests/phpunit/api/v3}
export CIVI=$(realpath "${CIVI:-.}")
export OUTDIR=$(realpath "${OUTDIR:-output}")
####################################################################
## Main
if [ -z "$1" ];then
show_help
exit 1
fi
while [ -n "$1" ]; do
OPTION="$1"
shift
case "$OPTION" in
--bundled-full|--bf)
echo "[[ Prepare $OUTDIR/bundled-full ]]"
[ -d "packages/PHPUnit.bak" ] && mv "packages/PHPUnit.bak" "packages/PHPUnit"
if [ ! -d "$CIVI/packages/PHPUnit" ]; then
echo "Missing $CIVI/packages/PHPUnit"
exit 2
fi
reset_dir "$OUTDIR/bundled-full"
pushd "$CIVI/tools"
$PHP ./scripts/phpunit --tap --log-json "$OUTDIR/bundled-full/all.json" "$TESTCLASS"
popd
;;
--bundled-indiv|--bi)
echo "[[ Prepare $OUTDIR/bundled-indiv ]]"
[ -d "packages/PHPUnit.bak" ] && mv "packages/PHPUnit.bak" "packages/PHPUnit"
if [ ! -d "$CIVI/packages/PHPUnit" ]; then
echo "Missing $CIVI/packages/PHPUnit"
exit 2
fi
reset_dir "$OUTDIR/bundled-indiv"
pushd "$CIVI/tools"
./scripts/phpunit-indiv --civi --test-dir "../$TESTPATH" --json-dir "$OUTDIR/bundled-indiv"
popd
cat "$OUTDIR"/bundled-indiv/*-*.json > "$OUTDIR/bundled-indiv/all.json"
;;
--standalone-full|--sf)
echo "[[ Prepare $OUTDIR/standalone-full ]]"
reset_dir "$OUTDIR/standalone-full"
pushd "$CIVI"
[ -d "packages/PHPUnit" ] && mv "packages/PHPUnit" "packages/PHPUnit.bak"
$PHP $(which $PHPUNIT) --tap --log-json "$OUTDIR/standalone-full/all.json" "$TESTPATH"
[ -d "packages/PHPUnit.bak" ] && mv "packages/PHPUnit.bak" "packages/PHPUnit"
popd
;;
--standalone-indiv|--si)
echo "[[ Prepare $OUTDIR/standalone-indiv ]]"
reset_dir "$OUTDIR/standalone-indiv"
pushd "$CIVI"
[ -d "packages/PHPUnit" ] && mv "packages/PHPUnit" "packages/PHPUnit.bak"
./tools/scripts/phpunit-indiv --test-dir "$TESTPATH" --json-dir "$OUTDIR/standalone-indiv"
[ -d "packages/PHPUnit.bak" ] && mv "packages/PHPUnit.bak" "packages/PHPUnit"
popd
cat "$OUTDIR"/standalone-indiv/*-*.json > "$OUTDIR/standalone-indiv/all.json"
;;
--compare)
echo "[[ Compare all results in $OUTDIR ]]"
phpunit-compare "$OUTDIR"/*/all.json
;;
esac
done