-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·39 lines (34 loc) · 869 Bytes
/
Copy pathtest.sh
File metadata and controls
executable file
·39 lines (34 loc) · 869 Bytes
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
#!/bin/bash
# Run the task worktree's tests. Uses $TEST_CMD if set (export it, or put it in
# a config.env next to this script); otherwise auto-detects by project type.
set -euo pipefail
wt="${WORKTREE_PATH:-}"
if [[ -z "$wt" || ! -d "$wt" ]]; then
echo "no worktree for this task"
exit 0
fi
if [[ -n "${TASK_PLUGIN_DIR:-}" && -f "$TASK_PLUGIN_DIR/config.env" ]]; then
# shellcheck disable=SC1091
source "$TASK_PLUGIN_DIR/config.env"
fi
cd "$wt"
cmd="${TEST_CMD:-}"
if [[ -z "$cmd" ]]; then
if [[ -f go.mod ]]; then
cmd="go test ./..."
elif [[ -f package.json ]]; then
cmd="npm test"
elif [[ -f Rakefile || -d spec ]]; then
cmd="bundle exec rspec"
else
echo "no TEST_CMD set and could not detect project type"
exit 0
fi
fi
echo "running: $cmd"
if eval "$cmd"; then
echo "tests passed"
else
echo "tests FAILED"
exit 1
fi