-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.sh
executable file
·90 lines (72 loc) · 2.21 KB
/
tests.sh
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
#!/bin/bash
# Parameters
testsPath="$1"
targetDir=$(mktemp)
if [ ! -d "$TARGET_PATH" ]; then
export TARGET_PATH="$targetDir"
fi
if [ ! -d "$QMOBILE_HOME" ]; then
export QMOBILE_HOME="/Library/Caches/com.4D.mobile/sdk/1920/Android/sdk"
if [ ! -d "$QMOBILE_HOME" ]; then
export QMOBILE_HOME="/Library/Caches/com.4D.mobile/sdk/1900/Android/sdk"
fi
fi
if [ -z "$testsPath" ]; then
echo "No default test path, try to look into PERFORCE_PATH or relative path to this script"
if [ ! -z "$PERFORCE_PATH" ]; then
testsPath="$PERFORCE_PATH/4eDimension/$branch/4D/Tests/_MobileIT/Resources/test/dataForCreateProject"
else
if [ -d "../../4D/Tests/_MobileIT/Resources/test/dataForCreateProject" ]; then
testsPath="../../4D/Tests/_MobileIT/Resources/test/dataForCreateProject"
fi
fi
fi
if [ ! -d "$testsPath" ]; then
>&2 echo "You must specify a path as argument with test file or PERFORCE_PATH env var"
exit 1
fi
# TODO
# - allow to have different output (teamcity, or less verbose with only result by file)
# Start the tests
finalStatus=0
## get python bin and version
has_python3=$(which python3)
if [ "$has_python3" == "" ]; then
python_bin="python"
python_version=$( $python_bin --version)
if [[ $python_version = Python\ 3* ]]; then
has_python3=1
else
has_python3=0
fi
else
python_bin="python3"
has_python3=1
fi
while read line; do
echo "📦 Processing file '$line' start..."
if [ $has_python3 -eq 1 ]; then
shortPath=$($python_bin -c "import os.path; print(os.path.relpath('$line', '$currentDir'))")
else
shortPath=$($python_bin -c "import os.path; print os.path.relpath('$line', '$currentDir')")
fi
# echo "##teamcity[testStarted name='$shortPath']"
./test.sh "$line"
status=$?
if [ $status -ne 0 ];then
finalStatus=$status
# echo "##teamcity[testFailed name='$shortPath' message='see log']"
fi
# echo "##teamcity[testFinished name='$shortPath']"
echo "📦 Processing file '$line' done"
done <<EOT
$(find "$testsPath" -name '*.4dmobileapp')
EOT
echo "Final result $finalStatus"
if [ "$finalStatus" -eq 0 ]; then
echo "✅ success"
else
>&2 echo "❌ failure"
exit $finalStatus
fi
rm -rf $targetDir