forked from KiCad/kicad-library-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_sch.sh
executable file
·37 lines (30 loc) · 853 Bytes
/
test_sch.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
#!/usr/bin/env bash
# This script file is used to test the consistency of files saved
# from sch python class. Spaces and line positioning will be ignored
if [[ $# < 1 ]]; then
echo "Usage: $0 sch_files"
exit 1
fi
function test_sch {
filename=`basename "$1"`
# python code --- START
python << EOF
from sch import *
lib = Schematic('$1')
lib.save('/tmp/$filename')
EOF
# python code --- END
sort "$1" > "/tmp/$filename.original.sorted"
sort "/tmp/$filename" > "/tmp/$filename.sch.sorted"
[[ `diff -b /tmp/$filename.original.sorted /tmp/$filename.sch.sorted` ]] && return 0
return 1
}
# colors
RED="\e[0;31m"
NOCOLOR="\e[0m"
for file in "$@"; do
echo "* testing $file"
if ( test_sch "$file" ); then
echo -e "${RED}sch class has generated a non identical output for the file: $file${NOCOLOR}"
fi
done