-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·75 lines (55 loc) · 1.84 KB
/
Copy pathtest.sh
File metadata and controls
executable file
·75 lines (55 loc) · 1.84 KB
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
#!/bin/bash
failures="test-failures"
: > $failures
# Docker cp wildcard does not work:
# sudo docker cp xp-mode-test:logs/* - >> logs/ # https://github.com/mikexstudios/dokku-app-configfiles/pull/4
function copyLogs() {
logs=$(sudo docker exec xp-mode-test bash -c "$@ ls logs")
for logFile in "${logs[@]}"; do
if [ "$logFile" != "" ]; then
sudo docker cp xp-mode-test:logs/$logFile - >> logs/$logFile
fi
done
}
if [ ! -z $BUILD_SERVER ]; then
for file in ./test/*checks.sh
do
bash -c "$@ /bin/bash $file"
done
else
echo "Running in container. Set \`BUILD_SERVER\` to any value to run in the current directory <`pwd`>."
sudo docker rm -f xp-mode-test &> /dev/null
if [[ ! -z $BUILD ]]; then
echo "Building container"
sudo docker build . -t xp-mode
fi
echo "Starting container"
sudo docker run -itd --name xp-mode-test xp-mode #&> /dev/null
echo "Copying files"
rm -fr ./logs && mkdir ./logs
sudo docker cp . xp-mode-test:/
sudo docker exec xp-mode-test bash -c "$@ rm -r .git"
if [[ $TEST != "" ]]; then
echo "Running single test file <$TEST>"
sudo docker exec -e "TRACE=$TRACE" xp-mode-test bash -c "$@ /bin/bash $TEST"
sudo docker cp xp-mode-test:$failures - >> $failures
copyLogs
else
for file in ./test/*checks.sh
do
sudo docker exec xp-mode-test bash -c "$@ /bin/bash $file"
sudo docker cp xp-mode-test:$failures - >> $failures
done
fi
sudo docker stop xp-mode-test &> /dev/null
sudo docker rm xp-mode-test &> /dev/null
fi
source "test/support.sh"
if [[ "$(cat $failures | wc -l)" -gt "0" ]]; then
red "\n\nTESTS FAILED\n"
cat "$failures"
exit 1
else
green "\nAll tests passed\n"
exit 0
fi