quiet_Math_Functor_test.sh
Go to the documentation of this file.
1 #!/usr/bin/env bash
2 #
3 # Math/Functor.h uses std::auto_ptr, which triggers a warning
4 #
5 # Usage: MathFunctor_wrapper_test.sh [include directories]
6 #
7 #
8 
9 ### BEGIN POSIX COMPLIANT ####
10 # Ubuntu 16 insists in using a non-bash default shell, and ctest insists to use the default shell;
11 # this horrible hack saves the day while issue #17234 is being addressed.
12 if [ -z "$BASH_VERSION" ] && [ "$1" != 'shellSwitch' ]
13 then
14  echo "Attempting to switch to bash."
15  bash -- "$0" 'shellSwitch' "$@"
16  exit
17 fi
18 [ "$1" = 'shellSwitch' ] && shift # here bash would be ok...
19 ### END POSIX COMPILANT ######
20 
21 
22 declare -a IncludeDirectives
23 for Dir in "$@" ; do
24  IncludeDirectives=( "${IncludeDirectives[@]}" "-I${Dir}" )
25 done
26 
27 Cmd=( g++ -std='c++14' -Wall -Werror=deprecated-declarations -pedantic "${IncludeDirectives[@]}" -x'c++' -c )
28 cat <<EOH
29 ===============================================================================
30 CMD> ${Cmd[@]}
31 ===============================================================================
32 EOH
33 "${Cmd[@]}" - <<EOC
34 #include "Math/Functor.h"
35 EOC
36 res=$?
37 cat <<EOM
38 -------------------------------------------------------------------------------
39 EXIT CODE: ${res} (errors are expected in the compilation above)
40 EOM
41 if [[ $res == 0 ]]; then
42  echo "Unexpected success in compiling 'Math/Functor.h'. May be time for dropping its wrapper." >&2
43  return 1
44 fi
45 
46 # this should work instead:
47 cat <<EOH
48 ===============================================================================
49 CMD> ${Cmd[@]}
50 ===============================================================================
51 EOH
52 Cmd=( g++ -std='c++14' -Wall -Werror=deprecated-declarations -pedantic "${IncludeDirectives[@]}" -x'c++' -c )
53 "${Cmd[@]}" - <<EOC
54 #include "larcorealg/CoreUtils/quiet_Math_Functor.h"
55 EOC
56 res=$?
57 cat <<EOM
58 -------------------------------------------------------------------------------
59 EXIT CODE: ${res} (errors are NOT expected in the compilation above)
60 ===============================================================================
61 EOM
62