Changeset 1092


Ignore:
Timestamp:
Jun 13, 2010, 1:50:18 AM (11 years ago)
Author:
Peter Johansson
Message:

fixes #445. tests are now performed in testSubDir/foo and each test has its own wc (and own svndigest cache) to work on.

Location:
trunk/test
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/Makefile.am

    r1091 r1092  
    7070
    7171clean-local:
    72   rm -rf generated_output toy_project
     72  rm -rf generated_output toy_project testSubDir
    7373
    7474mostlyclean-local:
  • trunk/test/README

    r1050 r1092  
    8181  present, i.e., the test is expected to fail.
    8282
     83  Note that that if tests are initialized correctly using either Suite
     84  class (see section C++ tests) or via init.sh (see shell tests) a
     85  sub-dir testSubDir/foo is created from which the test is run.
     86
    8387C++ tests
    8488---------
     
    113117  Include init.sh, with `. ./init.sh`.
    114118
    115   Use variables set in init.sh such as $srcdir, $SVNDIGEST, and $SVN.
     119  Use variables set in init.sh such as $srcdir and $abs_top_builddir, and $SVN.
     120
     121  Do not run svndigest and svncopyright directly, but use functions
     122  SVNDIGEST_run and SVNCOPYRIGHT_run.
    116123
    117124  Do not use `exit`, but use functions `exit_fail()`, `exit_skip()`,
  • trunk/test/Suite.cc

    r1044 r1092  
    4444    : ok_(true)
    4545  {
     46    chdir(abs_builddir());
     47    std::string test_dir = concatenate_path("testSubDir", file_name(argv[0]));
     48    mkdir_p(test_dir);
     49    chdir(test_dir);
    4650    if (need_test_repo) {
    4751      bool have_test_repo=false;
  • trunk/test/cache_partial_test.cc

    r803 r1092  
    3838  test::Suite suite(argc, argv, true);
    3939
    40   mkdir_p(test::filename("toy_project/.svndigest"));
    41   std::string root=test::filename("toy_project");
     40  mkdir_p("toy_project/.svndigest");
     41  std::string root="toy_project";
    4242  std::string filename = root + "/AUTHORS";
    4343  suite.out() << "Create SVN instance" << std::endl;
  • trunk/test/cmd_format_test.sh

    r1023 r1092  
    2525set -e
    2626
    27 $mkdir_p $targetdir
    28 $SVNDIGEST -f -r $rootdir -t $targetdir --format=banana 2> tmp_stderr && exit_fail
    29 test -s tmp_stderr || exit_fail
    30 cat tmp_stderr
    31 grep 'invalid argument.*banana.*format' tmp_stderr || exit_fail
    32 rm -f tmp_stderr
     27SVNDIGEST_run 1 -f --format=banana
     28test -s stderr || exit_fail
     29grep 'invalid argument.*banana.*format' stderr || exit_fail
    3330
    34 $SVNDIGEST -g --format=svg --anchor-format=svg > tmp_stdout
    35 cat tmp_stdout
    36 grep 'format = svg' tmp_stdout || exit_fail
    37 grep 'anchor_format = svg' tmp_stdout || exit_fail
    38 rm -f tmp_stdout
     31SVNDIGEST_run 0 -g --format=svg --anchor-format=svg
     32grep 'format = svg' stdout || exit_fail
     33grep 'anchor_format = svg' stdout || exit_fail
    3934
    4035exit_success;
  • trunk/test/config2_test.sh

    r1017 r1092  
    2727set -e
    2828
    29 $SVNDIGEST -g --config-file $srcdir/../.svndigest/config || exit_fail
     29SVNDIGEST_run 0 -g --config-file $abs_top_srcdir/.svndigest/config || exit_fail
    3030
    3131cat > tmp_config <<EOF
     
    3535EOF
    3636
    37 $SVNDIGEST -g --config-file tmp_config 2> tmp_stderr && exit_fail
    38 grep 'unknown format.* apple' tmp_stderr || exit_fail
    39 rm -f tmp_stderr tmp_config
     37SVNDIGEST_run 1 -g --config-file tmp_config
     38grep 'unknown format.* apple' stderr || exit_fail
     39
    4040exit_success
  • trunk/test/config3_test.sh

    r1091 r1092  
    2626test -e /dev/null || exit_skip
    2727test -r /dev/null || exit_skip
    28 $SVNDIGEST -g --config-file /dev/null || exit_fail
    29 $SVNDIGEST -g --config-file . && exit_fail
     28SVNDIGEST_run 0 -g --config-file /dev/null
     29SVNDIGEST_run 1 -g --config-file .
     30grep 'is a directory' stderr || exit_fail
    3031
    3132exit_success
  • trunk/test/copyright2_test.sh

    r978 r1092  
    2828set -e
    2929
    30 # this test has its own wc since it modifies wc
    31 rootdir=$abs_builddir/.toy_project2
    32 
    3330rm -rf $rootdir
    34 $SVN co ${repo_url}/trunk $rootdir -r 45
     31$SVN update $rootdir -r 45
    3532$SVN update $rootdir/lib
    3633# cannot use old config file because it's invalid
    3734$SVN update $rootdir/.svndigest
    3835
    39 $SVNDIGEST -r $rootdir --copyright --ignore-cache --no-report || exit_fail
    40 
    41 # remove wc to avoid someone being tempted to modify it
    42 rm -rf $rootdir
     36SVNCOPYRIGHT_run 1 -r $rootdir --ignore-cache
    4337
    4438exit_success;
  • trunk/test/copyright_test.cc

    r978 r1092  
    4242  test::Suite suite(argc, argv, true);
    4343
    44   std::string root=test::filename("toy_project");
     44  std::string root="toy_project";
    4545  std::string filename = root + "/README";
    4646
  • trunk/test/init.sh.in

    r1045 r1092  
    4242# primary variables - set by config.status
    4343abs_top_builddir=@abs_top_builddir@
     44abs_top_srcdir=@abs_top_srcdir@
    4445abs_builddir=@abs_builddir@
    4546mkdir_p="@MKDIR_P@"
     
    4950wc_found="@wc_found@"
    5051
    51 test -z "$SVNDIGEST" && SVNDIGEST="@top_builddir@/bin/svndigest --verbose";
     52test -z "$SVNDIGEST" && SVNDIGEST="@abs_top_builddir@/bin/svndigest --verbose";
     53test -z "$SVNCOPYRIGHT" && SVNCOPYRIGHT="${abs_top_builddir}/bin/svncopyright";
    5254test -z "$srcdir" && srcdir="@srcdir@";
    5355test -z "$SVN" && SVN=svn;
    5456
    5557# some helpful derived variables
    56 rootdir=$abs_builddir/toy_project
     58rootdir=toy_project
    5759targetdir=$abs_builddir/generated_output
    5860repo_url="file://$repo"
     61svn_update=${abs_builddir}/svn_update.sh
    5962
    6063me=$0
     64
     65test_dir=`echo $me.dir | sed -e 's,.*[\\/],,'`
     66test_dir="testSubDir/$test_dir"
     67$mkdir_p --verbose $test_dir
     68cd $test_dir
     69
     70abs_wcdir=${abs_builddir}/${test_dir}/toy_project
    6171
    6272for r in : $required; do
     
    6474    repo*)
    6575      if test x$test_repo_found = xyes; then
    66         cd $abs_builddir && $shell svn_update.sh || exit 1;
     76        $shell ${svn_update} || exit_fail;
    6777      else
    6878        exit_skip "no test repository available";
     
    7787done
    7888
     89
     90foo_run ()
     91{
     92    expected_exitcode=$1
     93    shift
     94    exitcode=0
     95    $foo_prog ${1+"$@"} > stdout 2>stderr || exitcode=$?
     96    cat stderr >&2
     97    cat stdout
     98    test $exitcode = $expected_exitcode || exit_fail
     99}
     100
     101SVNDIGEST_run ()
     102{
     103    foo_prog="$SVNDIGEST --verbose"
     104    foo_run $@
     105}
     106
     107SVNCOPYRIGHT_run ()
     108{
     109    foo_prog="$SVNCOPYRIGHT"
     110    foo_run $@
     111}
     112
     113
    79114echo "=== running $me ==="
    80115
  • trunk/test/repo_test.sh

    r1090 r1092  
    2626
    2727$mkdir_p $targetdir
    28 $SVNDIGEST -r $rootdir -t $targetdir --ignore-cache --no-report || exit_fail;
     28SVNDIGEST_run 0 -r $rootdir -t $targetdir --ignore-cache --no-report
    2929
    30 $SVNDIGEST -r $rootdir -t $targetdir --force || exit_fail;
     30SVNDIGEST_run 0 -r $rootdir -t $targetdir --force
    3131
    3232exit_success;
  • trunk/test/stats_test.cc

    r981 r1092  
    6464  bool ok=true;
    6565
    66   SVN* svn=SVN::instance(test::filename("toy_project"));
     66  SVN* svn=SVN::instance("toy_project");
    6767  if (!svn){
    6868    std::cerr << "error: cannot create SVN instance\n";
     
    9191  std::string path(void)
    9292  {
    93     return test::filename("toy_project/bin/svnstat.cc");
     93    return "toy_project/bin/svnstat.cc";
    9494  }
    9595
  • trunk/test/svn_update.sh.in

    r978 r1092  
    2323
    2424test -z "$SVN" && SVN=svn
    25 rootdir=@abs_builddir@/toy_project
     25rootdir=toy_project
    2626
    2727if test ! -e $rootdir; then
    2828    repo="@abs_test_repo@";
    29     $SVN co file://$repo/trunk $rootdir > /dev/null;
     29    $SVN checkout file://$repo/trunk $rootdir;
    3030fi
    3131
    32 $SVN update $rootdir > /dev/null;
     32$SVN update $rootdir
  • trunk/test/svncopyright_test.sh

    r1060 r1092  
    2525
    2626for opt in --version --help; do
    27   ../bin/svncopyright $opt > out.tmp 2> error.tmp
     27  $SVNCOPYRIGHT $opt > out.tmp 2> error.tmp
    2828  test -n "`cat out.tmp`" || exit_fail
    2929  test -z "`cat error.tmp`" || exit_fail
     
    3131done
    3232
    33 ../bin/svncopyright --version | head -n 1 | grep svncopyright || exit_fail
     33$SVNCOPYRIGHT --version | head -n 1 | grep svncopyright || exit_fail
    3434
    3535exit_success
  • trunk/test/svndigest_copy_cache_test.sh

    r968 r1092  
    2020
    2121required="repo"
    22 
     22set -x
    2323. ./init.sh || exit 1
    2424set -e
    2525
    2626for opt in --version --help; do
    27   ../bin/svndigest-copy-cache $opt > out.tmp 2> error.tmp
     27  $abs_top_builddir/bin/svndigest-copy-cache $opt > out.tmp 2> error.tmp
    2828  test -n "`cat out.tmp`" || exit_fail
    2929  test -z "`cat error.tmp`" || exit_fail
     
    3131done
    3232
    33 pristine=$abs_builddir/.toy_project2
     33pristine=fresh_wc
    3434rm -rf $pristine
    3535$SVN co ${repo_url}/trunk $pristine
Note: See TracChangeset for help on using the changeset viewer.