]> git.uio.no Git - u/mrichter/AliRoot.git/blame - test/Violation.cmake
HLTcomp
[u/mrichter/AliRoot.git] / test / Violation.cmake
CommitLineData
eee962e6 1cmake_minimum_required(VERSION 2.8)
2
3if(COMMAND CMAKE_POLICY)
4 if(POLICY CMP0009)
5 cmake_policy(SET CMP0009 NEW)
6 endif(POLICY CMP0009)
7endif(COMMAND CMAKE_POLICY)
8
9#Run Checkaliroot to get latest violations
10execute_process(COMMAND make -k check-all
11 WORKING_DIRECTORY $ENV{ALICE_INSTALL}
12 OUTPUT_FILE CheckAliroot.log )
13
14find_program(svn_command svn)
15
16#Function to count no of lines in a file equivalent to wc -l
17function (wcl _nLinesVar fileName)
18 file(READ ${fileName} fileData)
19 if(fileData)
20 if(WIN32)
21 string(REGEX MATCHALL "\r\n" nLines ${fileData})
22 else()
23 string(REGEX MATCHALL "[\r\n]" nLines ${fileData})
24 endif(WIN32)
25 list(LENGTH nLines nLines)
26 set(${_nLinesVar} ${nLines} PARENT_SCOPE)
27 else()
28 set(${_nLinesVar} -1 PARENT_SCOPE)
29 endif()
30endfunction()
31
f34fe1f8 32file(GLOB_RECURSE violExc "$ENV{ALICE_INSTALL}/*THerwig6.viol"
33 "$ENV{ALICE_INSTALL}/*AliRawReaderDateV3.viol"
34 "$ENV{ALICE_INSTALL}/*dateStream.viol"
35 "$ENV{ALICE_INSTALL}/TTherminator/*.viol"
36 "$ENV{ALICE_INSTALL}/*esdAna.viol"
37 "$ENV{ALICE_INSTALL}/*TIsajet*.viol"
38 "$ENV{ALICE_INSTALL}/*RecAna.viol"
39 "$ENV{ALICE_INSTALL}/*LHAPDFWrap.viol"
40 "$ENV{ALICE_INSTALL}/RAW/check/event.viol"
41 "$ENV{ALICE_INSTALL}/THerwig/check/HCommon.viol"
42 "$ENV{ALICE_INSTALL}/*HBTprocCOMMON.viol"
43 "$ENV{ALICE_INSTALL}/*EPOScommon.viol"
44 "$ENV{ALICE_INSTALL}/*DPMcommon.viol"
45 "$ENV{ALICE_INSTALL}/*Hcommon.viol"
46 "$ENV{ALICE_INSTALL}/*TPHICcommon.viol"
47 "$ENV{ALICE_INSTALL}/JETAN/check/fastjet/*.viol"
48 "$ENV{ALICE_INSTALL}/HLT/check/JET/fastjet/*.viol"
49 "$ENV{ALICE_INSTALL}/PYTHIA8/*.viol"
50 "$ENV{ALICE_INSTALL}/TEvtGen/*.viol"
51 "$ENV{ALICE_INSTALL}/LHAPDF/*.viol"
52 "$ENV{ALICE_INSTALL}/*HydCommon.viol"
53 "$ENV{ALICE_INSTALL}/*AliHLTDataBuffer.viol")
54file(GLOB_RECURSE violFiles "$ENV{ALICE_INSTALL}/*.viol")
eee962e6 55list(REMOVE_ITEM violFiles ${violExc})
56
57#Total list of files
58list(LENGTH violFiles totf)
59#Total no of lines
60set(totl 0)
61#Count the number Violations per file and sort
62foreach( violFile ${violFiles} )
63 file(READ ${violFile} fileData)
64 math(EXPR violLen "0")
65 if(fileData)
66 string(REGEX MATCHALL "violated:" violList ${fileData})
67 list(LENGTH violList violLen)
68 endif(fileData)
69 math(EXPR totl "${totl} + ${violLen}")
70 math(EXPR violLen "999999 - ${violLen}")
71 list(APPEND violCount "${violLen}:${violFile}")
72endforeach( violFile )
73list(SORT violCount)
74list(LENGTH violCount max)
75if(max GREATER 10)
76 set(max 10)
77endif(max GREATER 10)
78message("==============================Overall Violations==============================\n")
79message("COUNT : VIOLATION FILE NAME\n------------------------------------------------------------------------------")
80#Print out top 10 violations
81foreach(i RANGE ${max})
82 list(GET violCount ${i} line)
83 string(LENGTH ${line} lineLen)
84 math(EXPR lineLen "${lineLen}-7")
85 string(SUBSTRING ${line} 0 6 count)
86 string(SUBSTRING ${line} 7 ${lineLen} lineLen)
87
88 string(REPLACE "check/" "" args ${lineLen})
89 string(REPLACE "viol" "*" args ${args})
f34fe1f8 90 string(REPLACE "$ENV{ALICE_INSTALL}" "$ENV{ALICE_ROOT}" args ${args})
eee962e6 91 file(GLOB args "${args}")
92 foreach(arg ${args})
93 list(APPEND argList "${arg}")
94 endforeach(arg)
95
f34fe1f8 96 string(REPLACE "$ENV{ALICE_INSTALL}/" "" module ${lineLen})
eee962e6 97 math(EXPR count "999999 - ${count}")
98 string(LENGTH ${count} digit)
99 if(${digit} EQUAL 1)
100 set(space " ")
101 elseif(${digit} EQUAL 2)
102 set(space " ")
103 elseif(${digit} EQUAL 3)
104 set(space " ")
105 endif(${digit} EQUAL 1)
106 message("${space}${count} : ${module}")
107
108endforeach(i)
109
110set(tot 0)
111set (anlys "${anlys}\n\n==============================Detailed Analysis==============================\n")
112#Blaming people
113set (anlys "${anlys}+--| AliRoot\n")
114foreach( blameFile ${argList} )
115 string(REPLACE "$ENV{ALICE_ROOT}/" "" mainFile ${blameFile})
116 set(anlys "${anlys} |\n")
117 execute_process(COMMAND "${svn_command}" "blame" "${blameFile}"
f34fe1f8 118 WORKING_DIRECTORY "$ENV{ALICE_INSTALL}"
eee962e6 119 OUTPUT_FILE tmpViols
120 OUTPUT_VARIABLE tmpVio)
f34fe1f8 121 wcl(fileLen "$ENV{ALICE_INSTALL}/tmpViols")
eee962e6 122 set(anlys "${anlys} |--| ${mainFile} |-- ${fileLen} lines\n")
123 set(nameList "")
f34fe1f8 124 file(STRINGS "$ENV{ALICE_INSTALL}/tmpViols" violData)
eee962e6 125 # file(READ "tmpViols" violData)
126 # string(REGEX REPLACE "\n" ";" "violData" "${violData}")
127 foreach(violLine ${violData})
128 string(REGEX MATCH "[0-9]+[ ]+[a-zA-Z0-9]+" "name" "${violLine}")
129 string(REGEX REPLACE "^[0-9]+[ ]+" "" "name" "${name}")
130 list(APPEND nameList ${name})
131 list(APPEND fullViolList ${name})
132 endforeach(violLine)
133 list(LENGTH violData tot)
134 set (userList ${nameList})
135 set(finale "")
136 if(userList)
137 list(REMOVE_DUPLICATES userList)
138 endif(userList)
139 foreach(name ${userList})
140 string(REGEX MATCHALL "${name}" "nameCount" "${nameList}")
141 list(LENGTH nameCount nameCount)
142 math(EXPR num "(${nameCount}*100)/${tot}")
143 math(EXPR dec "((10000*${nameCount}/${tot}-100*${num}+5))")
144 if( ${dec} GREATER 99 )
145 set(dec 0)
146 math(EXPR num "${num}+1")
147 endif(${dec} GREATER 99)
148 math(EXPR dec "${dec}/10")
149 math(EXPR pcnt "99999 - ${num}${dec}")
150 string(LENGTH ${num} digit)
151 if(digit EQUAL 1)
152 set(space " ")
153 elseif(digit EQUAL 2)
154 set(space " ")
155 endif(digit EQUAL 1)
156 list(APPEND finale "${pcnt}-${space}${num}.${dec}% | ${name} |-- ${nameCount} lines")
157 endforeach(name)
158 list(SORT finale)
159 foreach(record ${finale})
160 string(LENGTH ${record} recLen)
161 math(EXPR recLen "${recLen}-6")
162 string(SUBSTRING ${record} 6 ${recLen} record)
163 set(anlys "${anlys} +--|${record}\n")
164 endforeach(record)
165endforeach( blameFile)
166
167list(LENGTH fullViolList tot)
168set(nameList ${fullViolList})
169set(finale "")
170#Sorting Names
171if(nameList)
172 list(REMOVE_DUPLICATES nameList)
173endif(nameList)
174foreach(name ${nameList})
175 string(REGEX MATCHALL "${name}" "nameCount" "${fullViolList}")
176 list(LENGTH nameCount nameCount)
177 math(EXPR num "(${nameCount}*100)/${tot}")
178 math(EXPR dec "((10000*${nameCount}/${tot}-100*${num}+5))")
179 if( ${dec} GREATER 99 )
180 set(dec 0)
181 math(EXPR num "${num}+1")
182 endif(${dec} GREATER 99)
183 math(EXPR dec "${dec}/10")
184 math(EXPR pcnt "99999 - ${num}${dec}")
185 string(LENGTH ${num} digit)
186 if(digit EQUAL 1)
187 set(space " ")
188 elseif(digit EQUAL 2)
189 set(space " ")
190 endif(digit EQUAL 1)
191 list(APPEND finale "${pcnt}-${space}${num}.${dec}% | ${name}")
192endforeach(name)
193
194#Print Code Percentages
195list(SORT finale)
196message("\n\n==============================Overall Percentages==============================\n")
197foreach(record ${finale})
198 string(LENGTH ${record} recLen)
199 math(EXPR recLen "${recLen}-6")
200 string(SUBSTRING ${record} 6 ${recLen} record)
201 message("${record}")
202endforeach(record)
203
204#Print Detailed Analysis
205message("${anlys}")