Changeset 3036


Ignore:
Timestamp:
Jun 3, 2013, 10:19:32 AM (9 years ago)
Author:
Peter
Message:

common_defs does two things: 1) init test scripts 2) defines some variables. Decouple these into two files: defs.sh and init.sh.

Location:
trunk
Files:
1 added
23 edited
1 copied
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/configure.ac

    r3035 r3036  
    416416     doc/doxygen.config
    417417     doc/first_page.doxygen
    418      test/common_defs.sh
     418                 test/defs.sh
    419419])
    420420
  • trunk/test/Makefile.am

    r3034 r3036  
    2929check_LTLIBRARIES = test/libyattest.la
    3030
    31 check_SCRIPTS = test/common_defs.sh
     31check_SCRIPTS = test/defs.sh
    3232
    3333EXTRA_PROGRAMS = test/alignment.test \
     
    116116lazycheck:; $(MAKE) $(AM_MAKEFLAGS) check RECHECK_LOGS=
    117117
     118shell_test_deps = test/init.sh test/defs.sh
     119
    118120# dependencies for lazycheck
    119 test/cmd_test.log: test/help.test test/common_defs.sh
    120 test/help_test.log: test/help.test test/common_defs.sh
    121 test/static_test.log: $(srcdir)/m4/yat.m4 test/common_defs.sh
     121test/cmd_test.log: test/help.test $(shell_test_deps)
     122test/help_test.log: test/help.test $(shell_test_deps)
     123test/static_test.log: $(srcdir)/m4/yat.m4 $(shell_test_deps)
    122124test/yat_config_test.log: build_support/yat-config \
    123   build_support/for_installation/yat-config test/common_defs.sh
    124 test/yat_config_cblas_test.log: build_support/yat-config test/common_defs.sh
     125  build_support/for_installation/yat-config $(shell_test_deps)
     126test/yat_config_cblas_test.log: build_support/yat-config $(shell_test_deps)
    125127test/yat_cpp_add_flag_test.log: $(srcdir)/m4/yat_add_flag.m4 \
    126128  $(srcdir)/m4/ax_append_flag.m4 \
    127129  $(srcdir)/m4/ax_check_preproc_flag.m4 \
    128   test/common_defs.sh
     130  $(shell_test_deps)
    129131test/yat_cxx_add_flag_test.log: $(top_srcdir)/m4/yat_add_flag.m4 \
    130132  $(top_srcdir)/m4/ax_append_compile_flags.m4 \
    131133  $(top_srcdir)/m4/ax_append_flag.m4 \
    132134  $(top_srcdir)/m4/ax_check_compile_flag.m4 \
    133   test/common_defs.sh
    134 test/yat_have_svn_wc_test.log: $(srcdir)/m4/yat_am_macros.m4 test/common_defs.sh
     135  $(shell_test_deps)
     136test/yat_have_svn_wc_test.log: $(srcdir)/m4/yat_am_macros.m4 $(shell_test_deps)
    135137test/yat_ld_add_flag_test.log: $(top_srcdir)/m4/yat_add_flag.m4 \
    136138  $(top_srcdir)/m4/ax_append_flag.m4 \
    137139  $(top_srcdir)/m4/ax_append_link_flags.m4 \
    138140  $(top_srcdir)/m4/ax_check_link_flag.m4 \
    139   test/common_defs.sh
     141  $(shell_test_deps)
    140142test/yat_lt_link_ifelse_test.log: $(top_srcdir)/m4/yat_lt_link_ifelse.m4 \
    141   $(top_srcdir)/m4/yat.m4 test/common_defs.sh \
     143  $(top_srcdir)/m4/yat.m4 $(shell_test_deps) \
    142144  $(top_builddir)/build_support/yat-config
    143 test/yat_m4_test.log:$(top_srcdir)/m4/yat.m4 test/common_defs.sh \
     145test/yat_m4_test.log:$(top_srcdir)/m4/yat.m4 $(shell_test_deps) \
    144146  $(top_builddir)/build_support/yat-config
    145 test/yat_m4_test2.log:$(top_srcdir)/m4/yat.m4 test/common_defs.sh
    146 test/yat_msg_error_test.log:$(srcdir)/m4/yat_msg_error.m4 test/common_defs.sh
    147 test/yat_msg_error_test2.log:$(srcdir)/m4/yat_msg_error.m4 test/common_defs.sh
    148 test/yat_pc_test.log: test/common_defs.sh build_support/yat.pc
     147test/yat_m4_test2.log:$(top_srcdir)/m4/yat.m4 $(shell_test_deps)
     148test/yat_msg_error_test.log:$(srcdir)/m4/yat_msg_error.m4 $(shell_test_deps)
     149test/yat_msg_error_test2.log:$(srcdir)/m4/yat_msg_error.m4 $(shell_test_deps)
     150test/yat_pc_test.log: $(shell_test_deps) build_support/yat.pc
    149151test/yat_prog_move_if_change_test.log: $(top_srcdir)/m4/yat_am_macros.m4 \
    150152  $(top_srcdir)/m4/ax_ac_append_to_file.m4 \
    151153  $(top_srcdir)/m4/ax_ac_print_to_file.m4 \
    152154  $(top_srcdir)/m4/ax_file_escapes.m4 \
    153   test/common_defs.sh
     155  $(shell_test_deps)
    154156test/yat_revision_header_test.log: $(top_srcdir)/m4/yat_am_macros.m4 \
    155   test/common_defs.sh \
     157  $(shell_test_deps) \
    156158  $(top_srcdir)/m4/ax_ac_append_to_file.m4 \
    157159  $(top_srcdir)/m4/ax_ac_print_to_file.m4 \
    158160  $(top_srcdir)/m4/ax_file_escapes.m4
    159161test/yat_svn_release_year_test.log: $(top_srcdir)/m4/yat_am_macros.m4 \
    160   test/common_defs.sh \
     162  $(shell_test_deps) \
    161163  $(top_srcdir)/m4/ax_ac_append_to_file.m4 \
    162164  $(top_srcdir)/m4/ax_ac_print_to_file.m4 \
    163165  $(top_srcdir)/m4/ax_file_escapes.m4
    164166test/yat_svn_revision_test.log: $(top_srcdir)/m4/yat_am_macros.m4 \
    165   test/common_defs.sh \
     167  $(shell_test_deps) \
    166168  $(top_srcdir)/m4/ax_ac_append_to_file.m4 \
    167169  $(top_srcdir)/m4/ax_ac_print_to_file.m4 \
    168170  $(top_srcdir)/m4/ax_file_escapes.m4
    169 test/yat_use_libtool_tag_test.log: test/common_defs.sh \
     171test/yat_use_libtool_tag_test.log: $(shell_test_deps) \
    170172  $(top_srcdir)/m4/yat_lt_link_ifelse.m4
    171173
  • trunk/test/cmd_test.sh

    r2853 r3036  
    2424set -e
    2525
    26 . test/common_defs.sh || exit 99
     26. test/init.sh || exit 99
    2727
    2828run ../../help.test 1 --no-foo
  • trunk/test/defs.sh.in

    r3035 r3036  
    6262exit_success () { echo "$me: successsful test: $@"; Exit 0; }
    6363
    64 me=$0
    65 
    66 echo "=== Running $me ==="
    67 
     64check_requirements ()
     65{
    6866# if required tool is not available, exit_skip
    6967if test -n "$required"; then
     
    110108  done
    111109fi
     110}
    112111
     112
     113me=$0
    113114# some defs we need in tests
    114115test_dir=`echo $me.dir | sed -e 's,.*[\\/],,'`
     
    123124# user is always right
    124125test -z "$DOXYGEN" && DOXYGEN="@DOXYGEN@"
    125 
    126 rm -rf $test_dir/*
    127 @MKDIR_P@ --verbose $test_dir
    128 
    129 # Taken from Automake 1.11 tests/defs.sh.in
    130 
    131 # Unset some MAKE... variables that may cause 'make' to act like a
    132 # recursively invoked sub-make.  Any 'make' invocation in a test is
    133 # conceptually an independent invocation, not part of the main
    134 # 'yat' build.
    135 unset MFLAGS
    136 unset MAKEFLAGS
    137 unset MAKELEVEL
    138 unset DESTDIR
    139 unset V
    140 unset TESTS
    141 unset TEST_LOGS
    142 unset RECHECK_LOGS
    143 unset VERBOSE
    144 
    145 cd $test_dir
    146 
    147 if (echo "$required" | grep autoconf > /dev/null); then
    148 echo "creating configure.ac"
    149 cat > configure.ac <<EOF
    150 AC_INIT([hello],[1.0])
    151 AC_CONFIG_SRCDIR([hello.cc])
    152 AC_CONFIG_MACRO_DIR([m4])
    153 EOF
    154 if (echo "$required" | grep automake > /dev/null); then
    155 echo "AM_INIT_AUTOMAKE([foreign])" >> configure.ac
    156 fi
    157 if (echo "$required" | grep libtool > /dev/null); then
    158 cat >> configure.ac << EOF
    159 AC_LANG([C++])
    160 AC_PROG_CXXCPP
    161 AC_PROG_CXX
    162 AC_PROG_LIBTOOL
    163 EOF
    164 fi
    165 
    166 
    167 echo "creating Makefile.am"
    168 cat > Makefile.am <<EOF
    169 ACLOCAL_AMFLAGS = -I m4
    170 AM_CPPFLAGS = \$(YAT_CPPFLAGS)
    171 AM_CXXFLAGS = \$(YAT_CXXFLAGS)
    172 AM_LDFLAGS = \$(YAT_LDFLAGS)
    173 LDADD = \$(YAT_LDADD)
    174 bin_PROGRAMS = hello
    175 TESTS = hello
    176 hello_SOURCES = hello.cc
    177 EOF
    178 
    179 echo "creating hello.cc"
    180 cat > hello.cc <<EOF
    181 #include <yat/utility/Vector.h>
    182 #include <yat/utility/version.h>
    183 #include <algorithm>
    184 #include <iostream>
    185 #include <string>
    186 int main(void)
    187 {
    188   using namespace theplu::yat;
    189   if (utility::version()!="@VERSION@") {
    190     std::cerr << "Incorrect version of linked libyat\n";
    191     return 1;
    192   }
    193   // testing something with gsl
    194   utility::Vector v(10);
    195   v.resize(120);
    196   // testing something with boost
    197   std::copy(v.begin(), v.begin()+10, v.begin()+10);
    198   return 0;
    199 }
    200 EOF
    201 fi #end of creation of autotool files
    202 
    203 # turn on shell traces
    204 set -x
    205 # remove old core dumps
    206 rm -f core*
     126VERSION="@VERSION@"
  • trunk/test/doxygen_test.sh

    r2787 r3036  
    2323
    2424required=doxygen
    25 . test/common_defs.sh || exit 99
     25. test/init.sh || exit 99
    2626
    2727printf "doxygen "
  • trunk/test/help_test.sh

    r2787 r3036  
    2424set -e
    2525
    26 . test/common_defs.sh || exit 99
     26. test/init.sh || exit 99
    2727
    2828run ../../help.test 0 --nonsense --help
  • trunk/test/init.sh

    r3035 r3036  
    1 # @configure_input@
    21# $Id$
    32
     
    1918# along with yat. If not, see <http://www.gnu.org/licenses/>.
    2019
    21 
    22 # bootstrap a test project
    23 #
    24 bootstrap ()
    25 {
    26     rm -rf m4
    27     @MKDIR_P@ m4
    28     cp @abs_top_srcdir@/m4/*.m4 m4/.
    29     rm -f m4/lt*.m4 m4/libtool.m4
    30     autoreconf -siv && true
    31     res=$?
    32     case $res in
    33         0)
    34             :;;
    35         63)
    36             exit_skip;;
    37         *)
    38             exit $res;;
    39     esac
    40 }
    41 
    42 # Usage: run PROG EXPECTED_EXITCODE [OPTION]...
    43 run ()
    44 {
    45     test $# -ge 2 || exit_fatal
    46     foo_prog=$1
    47     shift
    48     expected_exitcode=$1
    49     shift
    50     exitcode=0
    51     $foo_prog ${1+"$@"} > stdout 2>stderr || exitcode=$?
    52     cat stderr >&2
    53     cat stdout
    54     test $exitcode = $expected_exitcode || Exit 1
    55 }
    56 
    57 Exit () { set +x; exit $1; }
    58 warn_ () { echo $@ >&2; }
    59 exit_fail () { warn_ "$me: failed test: $@"; Exit 1; }
    60 exit_fatal () { warn_ "$me: hard error: $@"; Exit 99; }
    61 exit_skip () { warn_ "$me: skipped test: $@"; Exit 77; }
    62 exit_success () { echo "$me: successsful test: $@"; Exit 0; }
    63 
    64 me=$0
     20. test/defs.sh || exit 99
    6521
    6622echo "=== Running $me ==="
    6723
    68 # if required tool is not available, exit_skip
    69 if test -n "$required"; then
    70   for tool in $required; do
    71     case $tool in
    72       automake)
    73       echo "$me: running $tool --version"
    74       ($tool --version) || exit_skip;
    75       # skip test if automake older than v1.10
    76       version_am=`$tool --version | head -n 1 | cut -f 2 -d ')'`
    77       ver_major=`echo ${version_am} | cut -f 1 -d '.'`
    78       test ${ver_major} -ge 1 || exit_skip
    79       ver_minor=`echo ${version_am} | cut -f 2 -d '.'`
    80       test ${ver_major} -gt 1 || test ${ver_minor} -ge 10 || exit_skip
    81       ;;
    82       doxygen)
    83       test @have_doxygen@ = "yes" || exit_skip no doxygen
    84       ;;
    85       libbam)
    86       test @have_libbam@ = "yes" || exit_skip no libbam
    87       ;;
    88       libtool)
    89       # GNU libtool comes as glibtool on Mac OS
    90       (echo "$me: running libtool --version" && libtool --version) || \
    91       (echo "$me: running glibtool --version" && glibtool --version) || \
    92        exit_skip
    93       ;;
    94       shared)
    95       if (test "x@enable_shared@" = "xno"); then
    96         echo shared disabled;
    97         exit_skip;
    98       fi
    99       ;;
    100       static)
    101       if (test "x@enable_static@" = "xno"); then
    102         echo static disabled;
    103         exit_skip;
    104       fi
    105       ;;
    106       *)
    107       echo "$me: running $tool --version"
    108       ($tool --version) || exit_skip
    109     esac
    110   done
    111 fi
    112 
    113 # some defs we need in tests
    114 test_dir=`echo $me.dir | sed -e 's,.*[\\/],,'`
    115 test_dir="test/testSubDir/$test_dir"
    116 abs_top_builddir=@abs_top_builddir@
    117 abs_top_srcdir=@abs_top_srcdir@
    118 have_doxygen="@have_doxygen@"
    119 mkdir_p="@MKDIR_P@ --verbose"
    120 
    121 GSL_CONFIG=@GSL_CONFIG@
    122 
    123 # user is always right
    124 test -z "$DOXYGEN" && DOXYGEN="@DOXYGEN@"
     24check_requirements
    12525
    12626rm -rf $test_dir/*
    127 @MKDIR_P@ --verbose $test_dir
     27$mkdir_p $test_dir
    12828
    12929# Taken from Automake 1.11 tests/defs.sh.in
     
    18787{
    18888  using namespace theplu::yat;
    189   if (utility::version()!="@VERSION@") {
     89  if (utility::version()!="$VERSION") {
    19090    std::cerr << "Incorrect version of linked libyat\n";
    19191    return 1;
  • trunk/test/static_test.sh

    r2805 r3036  
    2626set -e
    2727
    28 . test/common_defs.sh || exit 99
     28. test/init.sh || exit 99
    2929
    3030cat >> configure.ac <<EOF
  • trunk/test/yat_config_cblas_test.sh

    r2787 r3036  
    2626set -e
    2727
    28 . test/common_defs.sh || exit 99
     28. test/init.sh || exit 99
    2929
    3030export YAT_CBLAS_LIB=BOGUSBOGUS
  • trunk/test/yat_config_test.sh

    r2787 r3036  
    2626set -e
    2727
    28 . test/common_defs.sh || exit 99
     28. test/init.sh || exit 99
    2929
    3030prog=${abs_top_builddir}/build_support/for_installation/yat-config
  • trunk/test/yat_cpp_add_flag_test.sh

    r2787 r3036  
    2727set -e
    2828
    29 . test/common_defs.sh || exit 99
     29. test/init.sh || exit 99
    3030
    3131cat >> configure.ac <<EOF
  • trunk/test/yat_cxx_add_flag_test.sh

    r2787 r3036  
    2727set -e
    2828
    29 . test/common_defs.sh || exit 99
     29. test/init.sh || exit 99
    3030
    3131cat >> configure.ac <<EOF
  • trunk/test/yat_have_svn_wc_test.sh

    r2787 r3036  
    2626set -e
    2727
    28 . test/common_defs.sh || exit 99
     28. test/init.sh || exit 99
    2929
    3030cat >> configure.ac <<EOF
  • trunk/test/yat_ld_add_flag_test.sh

    r2787 r3036  
    2727set -e
    2828
    29 . test/common_defs.sh || exit 99
     29. test/init.sh || exit 99
    3030
    3131cat >> configure.ac <<EOF
  • trunk/test/yat_lt_link_ifelse_test.sh

    r2805 r3036  
    2727set -e
    2828
    29 . ./test/common_defs.sh || exit 99
     29. ./test/init.sh || exit 99
    3030
    3131cat >> configure.ac <<EOF
  • trunk/test/yat_m4_test.sh

    r3018 r3036  
    2727set -e
    2828
    29 . test/common_defs.sh || exit 99
     29. test/init.sh || exit 99
    3030
    3131cat >> configure.ac <<EOF
  • trunk/test/yat_m4_test2.sh

    r2992 r3036  
    2626set -e
    2727
    28 . test/common_defs.sh || exit 99
     28. test/init.sh || exit 99
    2929
    3030cat >> configure.ac <<EOF
  • trunk/test/yat_msg_error_test.sh

    r2865 r3036  
    2626set -e
    2727
    28 . ./test/common_defs.sh || exit 99
     28. ./test/init.sh || exit 99
    2929
    3030specific_msg='some specific message a51965'
  • trunk/test/yat_msg_error_test2.sh

    r2787 r3036  
    2727set -e
    2828
    29 . test/common_defs.sh || exit 99
     29. test/init.sh || exit 99
    3030
    3131cat >> configure.ac <<EOF
  • trunk/test/yat_pc_test.sh

    r2981 r3036  
    2525set -e
    2626
    27 . test/common_defs.sh || exit 99
     27. test/init.sh || exit 99
    2828
    2929# test if pkg-config find gsl.pc
  • trunk/test/yat_prog_move_if_change_test.sh

    r2787 r3036  
    2626set -e
    2727
    28 . test/common_defs.sh || exit 99
     28. test/init.sh || exit 99
    2929
    3030cat >> configure.ac <<EOF
  • trunk/test/yat_revision_header_test.sh

    r2787 r3036  
    2626set -e
    2727
    28 . test/common_defs.sh || exit 99
     28. test/init.sh || exit 99
    2929
    3030cat >> configure.ac <<EOF
  • trunk/test/yat_svn_release_year_test.sh

    r2739 r3036  
    2626set -e
    2727
    28 . test/common_defs.sh || exit 99
     28. test/init.sh || exit 99
    2929
    3030cat >> configure.ac <<EOF
  • trunk/test/yat_svn_revision_test.sh

    r2787 r3036  
    2626set -e
    2727
    28 . test/common_defs.sh || exit 99
     28. test/init.sh || exit 99
    2929
    3030cat >> configure.ac <<EOF
  • trunk/test/yat_use_libtool_tag_test.sh

    r3034 r3036  
    2121required="autoconf"
    2222set -e
    23 . ./test/common_defs.sh || exit 99
     23. ./test/init.sh || exit 99
    2424
    2525cat >> configure.ac <<EOF
Note: See TracChangeset for help on using the changeset viewer.