Imported Upstream version 1.8.0
[platform/upstream/augeas.git] / src / try
1 #! /bin/bash
2
3 topdir=$(cd $(dirname $0)/.. && pwd)
4 export AUGEAS_LENS_LIB=${topdir}/lenses
5 export AUGEAS_ROOT=${topdir}/build/try
6
7 AUGCMDS=${topdir}/build/augcmds.txt
8 GDBCMDS=${topdir}/build/gdbcmds.txt
9
10 rm -rf $AUGEAS_ROOT
11 cp -pr ${topdir}/tests/root $AUGEAS_ROOT
12 find $AUGEAS_ROOT -name \*.augnew\* | xargs -r rm
13
14 if [[ ! -f $AUGCMDS ]] ; then
15     cat > $AUGCMDS <<EOF
16 match /augeas/version
17 EOF
18 fi
19
20 if [[ ! -f $GDBCMDS ]] ; then
21     cat > $GDBCMDS <<EOF
22 run --nostdinc -I $AUGEAS_LENS_LIB -r $AUGEAS_ROOT < $AUGCMDS
23 EOF
24 fi
25
26 cd $topdir/src
27 if [[ "x$1" == "xgdb" ]] ; then
28     [[ -n "$EMACS" ]] && int="-i=mi"
29     exec libtool --mode=execute gdb $int -x $GDBCMDS ./augtool
30 elif [[ "x$1" == "xstrace" ]] ; then
31     libtool --mode=execute /usr/bin/strace ./augtool --nostdinc < $AUGCMDS
32 elif [[ "x$1" == "xvalgrind" ]] ; then
33     shift
34     libtool --mode=execute valgrind --leak-check=full ./augtool --nostdinc "$@" < $AUGCMDS
35 elif [[ "x$1" == "xcallgrind" ]] ; then
36     libtool --mode=execute valgrind --tool=callgrind ./augtool --nostdinc < $AUGCMDS
37 elif [[ "x$1" == "xcli" ]] ; then
38     shift
39     exec ./augtool --nostdinc "$@"
40 else
41     ./augtool --nostdinc "$@" < $AUGCMDS
42     echo
43     for f in $(find $AUGEAS_ROOT -name \*.augnew); do
44         echo "File $f"
45         diff -u ${f%.augnew} $f
46     done
47 fi