-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·54 lines (47 loc) · 1.47 KB
/
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
#/bin/bash
binary=$1
folder=$2
if [ -z "$binary" ]
then
binary=".build/release/coredataimport"
fi
if [ -z "$folder" ]
then
folder="Resources"
fi
if [[ "$binary" != \/* ]]
then
binary="./$binary"
fi
echo "$binary --verbosity 2 --structure $folder/Structures.xcdatamodeld --asset $folder/Assets.xcassets --output $folder"
"$binary" --verbosity 2 --structure "$folder/Structures.xcdatamodeld" --asset "$folder/Assets.xcassets" --output "$folder"
"$binary" check --structure "$folder/Structures.xcdatamodeld" --asset "$folder/Assets.xcassets" --output "$folder"
# todo: make a loop on hash/dico, maybe find in jSON
foldername=`basename $folder`
manifest="$folder/manifest.txt"
if [ -f "$manifest" ]; then
while IFS=, read -r table expected
do
count=$(sqlite3 $folder/Structures.sqlite "select count(*) FROM Z$table")
if [ $count -eq $expected ]; then
echo "$count $table ok"
else
>&2 echo "expected $expected but receive $count for $table"
exit 1
fi
done < "$manifest"
else
echo "Database content of $folder is not tested"
total=0
tables=$(sqlite3 $folder/Structures.sqlite .tables)
for table in $tables; do
# show more info?
count=$(sqlite3 $folder/Structures.sqlite "select count(*) FROM $table")
echo "$table: $count"
total=$(( $total + $count))
done
if [ $total -eq 0 ]; then
>&2 echo "there is no record in database"
exit 2
fi
fi