-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathci_test.sh
executable file
·116 lines (90 loc) · 2.65 KB
/
ci_test.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/env bash
set -e
DIR=$(dirname "${BASH_SOURCE[0]}")
cd "$DIR"
CPU_COUNT=$(grep -c "^processor" "/proc/cpuinfo" || sysctl -n "hw.ncpu")
TMP_PATH="$(pwd)/../tmp"
TMP_SIZE="64"
./temp/mount.sh "$TMP_PATH" "$TMP_SIZE"
cd ".."
ROOT_DIR=$(pwd)
# We need to send coverage for extension.
curl -s "https://codecov.io/bash" > "build/codecov.sh"
chmod +x "build/codecov.sh"
/usr/bin/env bash -cl "\
cd \"$ROOT_DIR\" && \
gem install bundler --force && \
bundle install \
"
# Using standard default prefix.
prefix=${1:-"/usr/local"}
# Fix path environment params.
export PATH="${PATH}:${prefix}/bin"
export C_INCLUDE_PATH="${C_INCLUDE_PATH}:${prefix}/include"
export LIBRARY_PATH="${C_INCLUDE_PATH}:${prefix}/lib"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${prefix}/lib"
# Compiling library from source.
LZWS_BRANCH="v1.5.6"
cd "tmp"
# Remove orphaned directory.
rm -rf "lzws"
git clone "https://github.com/andrew-aladev/lzws.git" \
--single-branch \
--branch "$LZWS_BRANCH" \
--depth 1 \
"lzws"
cd "lzws/build"
# "sudo" may be required for prefix.
if command -v "sudo" > /dev/null 2>&1; then
sudo_prefix="sudo"
else
sudo_prefix=""
fi
# "dos2unix" may be required for text file handling.
if command -v "dos2unix" > /dev/null 2>&1; then
dos2unix_prefix="${sudo_prefix} dos2unix"
else
dos2unix_prefix=":"
fi
DICTIONARIES=("linked-list" "sparse-array")
BIGNUM_LIBRARIES=("gmp" "tommath")
some_test_passed=false
for dictionary in "${DICTIONARIES[@]}"; do
for bignum_library in "${BIGNUM_LIBRARIES[@]}"; do
echo "dictionary: ${dictionary}, bignum library: ${bignum_library}"
find . -depth \( \
-name "CMake*" \
-o -name "*.cmake" \
\) -exec rm -rf {} +
# It may not work on target platform.
cmake ".." \
-DCMAKE_INSTALL_PREFIX="$prefix" \
-DLZWS_COMPRESSOR_DICTIONARY="$dictionary" \
-DLZWS_BIGNUM_LIBRARY="$bignum_library" \
-DLZWS_SHARED=ON \
-DLZWS_STATIC=OFF \
-DLZWS_CLI=OFF \
-DLZWS_TESTS=OFF \
-DLZWS_EXAMPLES=OFF \
-DLZWS_MAN=OFF \
-DLZWS_COVERAGE=OFF \
-DCMAKE_BUILD_TYPE="Release" \
|| continue
cmake --build "." --target "clean"
cmake --build "." -j${CPU_COUNT} --config "Release"
$sudo_prefix cmake --build "." --target "install" --config "Release"
/usr/bin/env bash -cl "\
cd \"$ROOT_DIR\" && \
bundle exec rake clean && \
bundle exec rake && \
./build/codecov.sh \
"
$dos2unix_prefix "install_manifest.txt"
cat "install_manifest.txt" | $sudo_prefix xargs rm -f
some_test_passed=true
done
done
if [ "$some_test_passed" = false ]; then
>&2 echo "At least one test should pass"
exit 1
fi