test-release.sh
Go to the documentation of this file.
1 #!/bin/bash
2 
3 # Test a release. To make a release see make-release.sh
4 #
5 # 1) Get source code for a tagged release
6 #
7 # $ ./test-release.sh get-source <path/to/source> <release-tag>
8 #
9 # 2) Configure the source by telling it where to find externals and where to install (must not exist)
10 #
11 # $ ./test-release.sh configure-source <path/to/source> <path/to/externals> <path/to/install>
12 #
13 # 3) Build, install and run tests
14 #
15 # $ ./test-release.sh install <path/to/source>
16 ####
17 
18 
19 function goto
20 {
21  local dir=${1?no directory given} ; shift
22  if [ ! -d $dir ] ; then
23  echo "No such directory: $dir"
24  exit 1
25  fi
26  pushd $dir >/dev/null
27 }
28 function goback
29 {
30  popd >/dev/null
31 }
32 
33 function get-source
34 {
35  local source=${1?no sourcedir given} ; shift
36  local tag=${1?no tag given} ; shift
37 
38  if [ -d $source ] ; then
39  echo "Source directory already exists: $source"
40  exit 1
41  fi
42 
43  git clone https://github.com/WireCell/wire-cell-build.git $source
44  goto $source
45  git checkout -b $tag $tag
46  git submodule init
47  git submodule update
48  git submodule foreach git checkout -b $tag $tag
49  goback
50 }
51 
52 
53 
54 function configure-source
55 {
56  local source=$(readlink -f ${1?must provide source directory}) ; shift
57  local externals=$(readlink -f ${1?must provide externals directory}) ; shift
58  local install=$(readlink -f ${1?must provide install directory}) ; shift
59 
60 
61  if [ ! -d "$externals" ] ; then
62  echo "No externals directory: $externals"
63  exit 1
64  fi
65  if [ -d "$install" ] ; then
66  echo "Install directory already exits: $install"
67  exit 1
68  fi
69  mkdir -p $install
70 
71  goto $source
72 
73  ./wcb configure --prefix=$install \
74  --boost-includes=$externals/include \
75  --boost-libs=$externals/lib \
76  --boost-mt \
77  --with-eigen-include=$externals/include/eigen3 \
78  --with-jsoncpp=$externals \
79  --with-jsonnet=$externals \
80  --with-zlib=$externals \
81  --with-tbb=no \
82  --with-fftw=$externals \
83  --with-root=$externals
84 
85 
86  cat <<EOF >tester.sh
87 #!/bin/bash
88 env LD_LIBRARY_PATH=$externals/lib:$install/lib "\$@"
89 EOF
90  chmod +x tester.sh
91 
92  goback
93 }
94 
95 function install
96 {
97  local source=$(readlink -f ${1?must provide source directory}) ; shift
98  goto $source
99 
100  ./wcb --notest || exit 1
101  ./wcb --notest install || exit 1
102  ./wcb --alltests --testcmd="$source/tester.sh %s" || exit 1
103 
104  goback
105 }
106 
107 
108 "$@"