-
Notifications
You must be signed in to change notification settings - Fork 346
/
Copy pathutils.sh
executable file
·80 lines (70 loc) · 1.95 KB
/
utils.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
#!/usr/bin/env bash
# shellcheck disable=SC1090
# vim:ts=4:sts=4:sw=4:et
#
# Author: Hari Sekhon
# Date: 2015-05-25 01:38:24 +0100 (Mon, 25 May 2015)
#
# https://github.com/HariSekhon/DevOps-Python-tools
#
# License: see accompanying Hari Sekhon LICENSE file
#
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help improve or steer this or other code I publish
#
# https://www.linkedin.com/in/HariSekhon
#
set -eu
[ -n "${DEBUG:-}" ] && set -x
srcdir2="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. "$srcdir2/excluded.sh"
. "$srcdir2/../bash-tools/lib/utils.sh"
. "$srcdir2/../bash-tools/lib/docker.sh"
srcdir="$srcdir2"
export COMPOSE_PROJECT_NAME="pytools"
if [ -n "${TRAVIS:-}" ]; then
sudo=sudo
else
# will be used in sourcing scripts
# shellcheck disable=SC2034
sudo=""
fi
set +o pipefail
spark_home="$(find . -type d -path 'tests/spark-*-bin-hadoop*' 2>/dev/null | head -n 1)"
set -o pipefail
if [ -n "$spark_home" ]; then
export SPARK_HOME="$spark_home"
fi
. "$srcdir/excluded.sh"
. "$srcdir/check.sh"
# echo sample files except those with extensions given as args
sample_files(){
local data_dir="$srcdir2/data"
for filename in \
"$data_dir/add_ou.ldif" \
"$data_dir/multirecord.json" \
"$data_dir/simple.xml" \
"$data_dir/test.csv" \
"$data_dir/test.ini" \
"$data_dir/test.json" \
"$data_dir/test.yaml" \
"$data_dir/../../README.md" \
; do
local excluded=0
for ext in "$@"; do
if [ "${filename##*.}" = "$ext" ]; then
excluded=1
break
fi
done
if [ $excluded = 0 ]; then
echo "$filename"
fi
done
}
check_broken_sample_files(){
echo "Now checking non $* files to detect successful failure:"
echo
for filename in $(sample_files "$@"); do
check_broken "$filename"
done
}