3 # Checks all FHiCL files under the specified directory.
7 # testFHiCLfiles.sh [file or directory ...]
9 # By default all FHiCL files under the current directory are tested.
16 : ${DefaultTest:=
'dump'}
19 ################################################################################
21 function SetupColors() {
24 if [[ $UseColors != 0 ]]; then
26 [
'reset']=
"${Escape}0m"
27 [
'red']=
"${Escape}31m"
28 [
'yellow']=
"${Escape}1;33m"
29 [
'bright red']=
"${Escape}1;31m"
30 [
'green']=
"${Escape}32m"
31 [
'bright green']=
"${Escape}1;32m"
32 [
'cyan']=
"${Escape}36m"
39 echo -
e "${ColorCodes[$Key]}"
42 function ApplyColor() {
45 echo -
e "$(GetColor "$Color
")$*$(GetColor 'reset')"
48 function isDebugging() {
49 local -i Level=
"${1:-1}"
50 [[
"$DEBUG" -ge
"$Level" ]]
54 isDebugging
"$Level" ||
return
56 STDERR 'green' "DBG[${Level}]| $*" ;
58 function DBG() { DBGN 1
"$@" ; }
59 function INFO() { [[
"$Quiet" == 0 ]] && ApplyColor
'cyan' "$*" ; }
60 function SUCCESS() { ApplyColor
'bright green' "$*" ; }
64 ApplyColor
"$Color" "$*" >&2
70 STDERR 'bright red' "FATAL (${Code}): $*"
75 [[ $res == 0 ]] ||
FATAL "$res" "$@"
79 function DebugTest() {
80 local -ir MaxLevel=
"${1:-10}"
82 for (( Level = 1 ; Level < 10 ; ++Level ));
do
83 DBGN
"$Level" "Debug level ${Level} shown"
88 ################################################################################
96 If an input specification is
a file, that file is tested;
if the input is
a
97 directory, all files with suffix
'.fcl' under that directory
and its
98 subdirectories
are tested.
99 If no input is
specified,
the current directory is used as starting point.
103 lists all
the supported tests
104 --
test=TEST [
"${DefaultTest}"]
105 choose which test to perform; use \`--listtests\` to see
the supported tests
107 shortcut
for \`--test=dump\`
109 shortcut
for \`--test=validate\`
113 equivalent to \`--
exclude=PATTERN\`
for all patterns
in FILE; each line
114 in FILE is interpreted as
a pattern, except
for the lines starting with
115 a '#' (no spaces allowed before it)
119 sets
the verbosity to
the specified LEVEL
for debugging purposes
120 --color | --no-color [
default: enabled]
130 ################################################################################
131 declare -Ar TestDescriptions=(
132 [
'dump']=
'FHiCL syntax check (`fhicl-dump`)'
133 [
'validate']=
'ask `art` to perform validation (`lar --validate-config`)'
136 function printTests() {
138 for TestKey
in "${!TestDescriptions[@]}" ;
do
139 local TestDescription=
"${TestDescriptions[$TestKey]}"
148 function isTestType() {
150 for TestKey
in "${!TestDescriptions[@]}" ;
do
151 [[
"$TestKey" ==
"$Key" ]] &&
return 0
157 function SelectTest() {
161 # add non-standard types here
163 if isTestType
"$Type" ; then
164 TestProc=
"Test_${Type}"
165 TestPrep=
"${TestProc}_prep"
166 DBG
"Selected test '${Type}'."
176 function isExcluded() {
181 for ExcludePattern
in "${ExcludedPatterns[@]}" ;
do
182 [[
"$Path" =~ $ExcludePattern ]] &&
return 0
189 function ExcludeFromFile() {
193 [[ -
r "$File" ]] ||
FATAL 2
"Can't read exclusion file '${File}'!"
198 [[ -
z "$Pattern" ]] &&
continue
199 [[
"${Pattern:0:1}" ==
'#' ]] &&
continue
200 DBGN 2
"Exclude pattern: '${Pattern}'"
201 ExcludedPatterns+=(
"$Pattern" )
205 DBGN 1
"${nExcluded} exclusion patterns loaded from '${File}'."
207 } # ExcludeFromFile()
210 ################################################################################
211 function Test_dump_prep() {
213 if [[ -
z "$fhicldump" ]]; then
214 fhicldump=
"$(which 'fhicl-dump' 2> /dev/null)"
215 [[ -
x "$fhicldump" ]] ||
FATAL 1
"Couldn't find 'fhicl-dump' executable!"
221 function Test_dump() {
225 INFO
"Testing: '${FHiCLpath}'"
228 [[
"$FHiCLpath" =~ / ]] && WithPath=1
231 [[
"$WithPath" == 1 ]] && Options+=(
'-l' 'after1' )
233 $fhicldump --quiet
"${Options[@]}" --config
"$FHiCLpath"
236 [[ $res == 0 ]] ||
ERROR "File '${FHiCLpath}' failed verification (code: ${res})."
241 ################################################################################
242 function Test_validate_prep() {
244 if [[ -
z "$lar" ]]; then
245 lar=
"$(which 'lar' 2> /dev/null)"
246 [[ -
x "$lar" ]] ||
FATAL 1
"Couldn't find 'lar' executable!"
249 } # Test_validate_prep()
252 function Test_validate() {
256 INFO
"Validating: '${FHiCLpath}'"
259 [[
"$FHiCLpath" =~ / ]] && WithPath=1
264 local -
a Cmd=( $lar --validate-config
'/dev/null' "${Options[@]}" --config
"$FHiCLpath" )
268 if [[ $res != 0 ]]; then
269 ERROR "File '${FHiCLpath}' failed validation (code: ${res})."
270 INFO
"Command was:\n${Cwd}\$ ${Cmd[@]}"
276 ################################################################################
277 function TestFHiCLfile() {
281 if isExcluded
"$FilePath" ; then
282 echo
"Skipping '${FilePath}' (excluded)"
286 "$TestProc" "$FilePath"
288 if [[ $res != 0 ]]; then
289 Errors[
"$FilePath"]=
"$res"
296 function TestFHiCLdirectory() {
300 if [[ ! -d
"$DirPath" ]]; then
301 ERROR "Path '${DirPath}' is not a directory."
305 if isExcluded
"$DirPath" ; then
306 echo
"Skipping '${DirPath}' and subdirectories (excluded)"
313 echo
"Testing FHiCL files in '${DirPath}' and subdirectories"
314 while read FilePath ;
do
315 TestFHiCLfile
"$FilePath" || let ++nErrors
316 done < <( find
"$DirPath" -
name "*.fcl" )
318 [[ $nErrors -gt 0 ]] #
return value
322 function TestFHiCLpath() {
325 if [[ -d
"$Path" ]]; then
326 TestFHiCLdirectory
"$Path"
328 TestFHiCLfile
"$Path"
332 ################################################################################
336 declare -
a InputPaths
337 declare -
a ExcludedPatterns
338 declare TestType=
"$DefaultTest"
341 for (( iParam = 1 ; iParam <= $# ; ++iParam ));
do
343 if [[ $NoMoreOptions == 0 ]] && [[
"${Param:0:1}" ==
'-' ]]; then
345 (
'--test='* ) TestType="${
Param#--*=}
" ;;
346 ( '--exclude='* ) ExcludedPatterns+=( "${
Param#--*=}
" ) ;;
347 ( '--exclude-from='* ) ExcludedPatternFiles+=( "${
Param#--*=}
" ) ;;
348 ( '--listtests' | '-L' ) DoListTests=1 ;;
349 ( '--color' ) UseColors=1 ;;
350 ( '--no-color' ) UseColors=0 ;;
351 ( '--quiet' | '-q' ) Quiet=1 ;;
352 ( '--debug' | '-d' ) DEBUG=1 ;;
353 ( '--debug='* ) DEBUG="${
Param#--*=}
" ;;
354 ( '--help' | '-h' | '-?' ) DoHelp=1 ;;
355 ( '--' | '-' ) NoMoreOptions=1 ;;
357 if isTestType "${
Param#--}
" ; then
358 TestType="${
Param#--}
"
360 FATAL 1 "Unsupported
option:
'${Param}'.
"
363 [[ $DoHelp == 1 ]] && break
365 InputPaths+=( "$Param
" )
369 for File in "${ExcludedPatternFiles[@]}
" ; do
370 ExcludeFromFile "$File
"
373 ################################################################################
375 SetupColors "$UseColors
"
378 if [[ $DoHelp == 1 ]]; then
383 if [[ $DoListTests == 1 ]]; then
384 echo "Supported tests
are:
"
390 # test selection and preparation
392 if ! SelectTest "$TestType
" ; then
393 ERROR "Unrecognised test:
'${TestType}'. Supported tests
are:
"
395 FATAL 1 "Unrecognised test:
'${TestType}'.
"
399 [[ "${#InputPaths[@]}
" == 0 ]] && InputPaths=( '.' )
401 if [[ -n "$TestPrep
" ]]; then
403 LASTFATAL 1 "Preparation to test
'${TestType}' failed.
"
410 for InputPath in "${InputPaths[@]}
" ; do
412 TestFHiCLpath "$InputPath
"
416 if [[ "${#Errors[@]}
" -gt 0 ]]; then
417 STDERR 'bright red' "${#Errors[@]} errors found
in test
'${TestType}':
"
418 for Failed in "${!Errors[@]}
" ; do
419 STDERR 'bright red' "-
'${Failed}' (code: ${Errors[$Failed]})
"
423 SUCCESS "All tested files passed
the verification.
"
427 ################################################################################
process_name opflash particleana ie ie ie z
process_name opflash particleana ie x
esac done echo Signal files are
do one_file $F done echo for F in find $TOP name CMakeLists txt print
then echo Sam station was not specified(use option--sam_station)." exit 1 fi if [ x$SAM_GROUP
return match has_match and(match.match_pdg==11 or match.match_pdg==-11)
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker see the discussion of warn common echo in *Note Linker such as a global int variable echo as opposed to a large global array echo echo I echo The symbol is an indirect reference to another symbol This echo is a GNU extension to the a out object file format which is echo rarely used echo echo N echo The symbol is a debugging symbol echo echo R echo The symbol is in a read only data section echo echo S echo The symbol is in an uninitialized data section for small echo objects echo echo T echo The symbol is in the the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo W echo The symbol is a weak symbol that has not been specifically echo tagged as a weak object symbol When a weak defined symbol echo is linked with a normal defined the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo echo The symbol is a stabs symbol in an a out object file In echo this the next values printed are the stabs other echo the stabs desc and the stab type Stabs symbols are echo used to hold debugging information For more information
then echo Work directory not specified exit fi echo Work directory
if &&[-z"$BASH_VERSION"] then echo Attempting to switch to bash bash shellSwitch exit fi &&["$1"= 'shellSwitch'] shift declare a IncludeDirectives for Dir in
BEGIN_PROLOG sequence::SlidingWindowTriggerPatternsOppositeWindows END_PROLOG simSlidingORM6O6 effSlidingORW output
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker options
BEGIN_PROLOG triggeremu_data_config_icarus settings sequence::triggeremu_data_config_icarus settings PMTADCthresholds sequence::triggeremu_data_config_icarus settings PMTADCthresholds sequence::triggeremu_data_config_icarus settings PMTADCthresholds Pattern
BEGIN_PROLOG hitmakerfive clustermakerfour pfparticlemakerthree showermakertwo END_PROLOG hitmakerfive clustermakerfour pfparticlemakerthree sequence::inline_paths sequence::inline_paths sequence::inline_paths showermakers test