1
1
#! /bin/sh
2
2
LogParse (){
3
3
echo ' Log Parse Begin'
4
- path=' EarlGreyToolLogs'
5
- if [ -d ]
6
4
now=$( date +%Y-%m-%d-%T)
7
- xcodebuild test -project mobile.xcodeproj -scheme mobile -destination ' platform=iOS Simulator,OS=9.3,name=iPhone 6 Plus' > $now .log
8
- headLineNum=$( awk ' /========== Detailed Exception ==========/{ print NR;}' $now .log) # find a head
9
- endLineNum=$( awk ' / failed \(/{ print NR;}' $now .log) # find end line
5
+ path=TestLogs
6
+ fullLogPath=$path /$now .log
7
+ errorLogPath=$path /error_$now .log
8
+ echo $( pwd) /$fullLogPath
9
+ echo $( pwd) /$errorLogPath
10
+ if [ ! -d $path ]; then
11
+ mkdir $path
12
+ fi
13
+ xcodebuild test -project mobile.xcodeproj -scheme mobile -destination ' platform=iOS Simulator,OS=9.3,name=iPhone 6 Plus' > $fullLogPath
14
+ headLineNum=$( awk ' /========== Detailed Exception ==========/{ print NR;}' $fullLogPath ) # find a head
15
+ endLineNum=$( awk ' / failed \(/{ print NR;}' $fullLogPath ) # find end line
10
16
hNums=(${headLineNum// \ / } )
11
17
eNums=(${endLineNum// \ / } )
12
- if ${# hNums} =${# eNums}
13
- then
18
+ if [ ${# hNums} = ${# eNums} ]; then
14
19
echo ${# hNums}
15
20
count=${# eNums[@]}
16
21
for (( i= 0 ;i< count;i++ ))
17
22
do
18
23
# echo loop $i
19
24
for (( n= ${hNums[$i]} ;n<= ${eNums[$i]} ;n++ ))
20
25
do
21
- sed " ${n} q;d" $now .log >> error_ $now .log
26
+ sed " ${n} q;d" $fullLogPath >> $errorLogPath
22
27
done
23
28
done
24
29
elif [ ${# hNums} =0 -a [${# eNums} = 0 ]
@@ -27,10 +32,9 @@ LogParse(){
27
32
else
28
33
echo ' read line numbers error'
29
34
fi
30
- tail -n 2 $now .log >> error_ $now .log
35
+ tail -n 2 $fullLogPath >> $errorLogPath
31
36
}
32
37
33
- i= $1
34
38
if [ " $1 " = " run" ]; then
35
39
LogParse
36
40
exit
0 commit comments