Ignore:
Timestamp:
Apr 9, 2009, 10:18:54 PM (13 years ago)
Author:
Jari Häkkinen
Message:

Merged trunk changes r645:782 to replacing_gnuplot branch.

Location:
branches/replacing_gnuplot
Files:
15 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/replacing_gnuplot

    • Property svn:ignore
      •  

        old new  
        88autom4te.cache
        99INSTALL
        10 COPYING
        1110aclocal.m4
        1211Makefile
  • branches/replacing_gnuplot/test/Makefile.am

    r646 r784  
    33## $Id$
    44
    5 # Copyright (C) 2005, 2006, 2007 Jari Häkkinen, Peter Johansson
     5# Copyright (C) 2005, 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
     6# Copyright (C) 2009 Peter Johansson
    67# Copyright (C) 2008 Peter Johansson
    78#
    8 # This file is part of svndigest, http://trac.thep.lu.se/svndigest
     9# This file is part of svndigest, http://dev.thep.lu.se/svndigest
    910#
    1011# svndigest is free software; you can redistribute it and/or modify it
    1112# under the terms of the GNU General Public License as published by
    12 # the Free Software Foundation; either version 2 of the License, or
     13# the Free Software Foundation; either version 3 of the License, or
    1314# (at your option) any later version.
    1415#
     
    1920#
    2021# You should have received a copy of the GNU General Public License
    21 # along with this program; if not, write to the Free Software
    22 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    23 # 02111-1307, USA.
     22# along with svndigest. If not, see <http://www.gnu.org/licenses/>.
    2423
    25 check_PROGRAMS = config_test date_test gnuplot_pipe_test \
    26   parser_test trac_test utility_test
     24check_SCRIPTS = svn_update.sh
    2725
    28 # these tests are only for developers since we do not distribute test repository
    29 if HAVE_SVN_WC
    30 check_PROGRAMS += copyright_test stats_test
    31 endif
     26check_PROGRAMS = config_test copyright_test date_test gnuplot_pipe_test \
     27  parser_test stats_test trac_test utility_test
    3228
    33 TESTS = $(check_PROGRAMS)
    34 # these tests are only for developers since we do not distribute test repository
    35 if HAVE_SVN_WC
    36 TESTS += test_repo.sh check_repo_status.sh
    37 endif
     29TESTS = $(check_PROGRAMS) test_repo.sh check_repo_status.sh
    3830
    3931# tests not yet passing are listed here
     
    4234noinst_HEADERS = Suite.h
    4335
    44 check_LTLIBRARIES = libsvndigesttest.la
     36check_LIBRARIES = libsvndigesttest.a
    4537
    4638
    47 LDADD = @builddir@/libsvndigesttest.la \
    48   @top_builddir@/lib/libsvndigest.la \
     39LDADD = $(builddir)/libsvndigesttest.a \
     40  $(top_builddir)/lib/libsvndigest.a \
    4941  $(SVNDIGEST_LIBS)
    50 AM_LDFLAGS = $(STATICFLAG) $(SVNDIGEST_LDFLAGS)
     42AM_LDFLAGS = $(SVNDIGEST_LDFLAGS)
    5143
    52 AM_CPPFLAGS = -I@top_srcdir@/lib $(SVNDIGEST_CPPFLAGS)
     44AM_CPPFLAGS = -I$(top_srcdir)/lib $(SVNDIGEST_CPPFLAGS)
    5345AM_CXXFLAGS = $(SVNDIGEST_CXXFLAGS)
    5446
    55 libsvndigesttest_la_SOURCES = Suite.cc
     47libsvndigesttest_a_SOURCES = Suite.cc
    5648
    5749config_test_SOURCES = config_test.cc
     
    6456utility_test_SOURCES = utility_test.cc
    6557
    66 toy_project = toy_project
    67 rootdir = $(abs_srcdir)/$(toy_project)
    68 targetdir = $(abs_builddir)/generated_output
    69 repodir = $(abs_srcdir)/repo/trunk
     58clean-local:
     59  rm -rf generated_output toy_project
    7060
    71 
    72 # some tests need the test repo to be checked out
    73 stats_test_DEPENDENCIES = $(toy_project) @top_builddir@/lib/libsvndigest.la
    74 copyright_test_DEPENDENCIES = $(toy_project) @top_builddir@/lib/libsvndigest.la
    75 
    76 @top_builddir@/lib/libsvndigest.la:
    77   @cd @top_builddir@/lib/ && $(MAKE) $(AM_MAKEFLAGS);
    78 
    79 $(toy_project):
    80   echo Checking out test repository && \
    81   svn checkout file://$(repodir) $(toy_project);
    82 
    83 clean-local:
    84   rm -rf *.png *.tmp *~ $(targetdir)
    85 
    86 .PHONY: @top_builddir@/lib/libsvndigest.la
     61mostlyclean-local:
     62  rm -f *.png *.tmp *~
  • branches/replacing_gnuplot/test/Suite.cc

    r596 r784  
    22
    33/*
    4   Copyright (C) 2008 Peter Johansson
     4  Copyright (C) 2008, 2009 Peter Johansson
    55
    6   This file is part of the yat library, http://trac.thep.lu.se/yat
     6  This file is part of the yat library, http://dev.thep.lu.se/yat
    77
    88  The yat library is free software; you can redistribute it and/or
    99  modify it under the terms of the GNU General Public License as
    10   published by the Free Software Foundation; either version 2 of the
     10  published by the Free Software Foundation; either version 3 of the
    1111  License, or (at your option) any later version.
    1212
     
    1717
    1818  You should have received a copy of the GNU General Public License
    19   along with this program; if not, write to the Free Software
    20   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    21   02111-1307, USA.
     19  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
    2220*/
     21
     22#include <config.h>
    2323
    2424#include "Suite.h"
    2525#include "environment.h"
    2626
     27#include "utility.h"
     28
     29#include <cassert>
     30#include <fstream>
     31#include <iostream>
    2732#include <string>
    2833
     
    3136namespace test {
    3237
     38  Suite::Suite(int argc, char* argv[], bool need_test_repo)
     39    : dev_null_(NULL), ok_(true), verbose_(false)
     40  {
     41    char* buffer=std::getenv("VERBOSE");
     42    if ( (argc>1 && (argv[1]==std::string("-v")
     43                     || argv[1]==std::string("--verbose"))
     44          || (buffer && buffer == std::string("1"))) ) {
     45      verbose_=true;
     46    }
     47    else
     48      dev_null_ = new std::ofstream("/dev/null");
     49
     50    if (need_test_repo) {
     51      bool have_test_repo=false;
     52      #ifdef HAVE_TEST_REPO
     53      have_test_repo=true;
     54      #endif
     55      if (!have_test_repo) {
     56        out() << "Skipping test because test repository is not available\n";
     57        exit (77);
     58      }
     59      update_test_wc();
     60    }
     61
     62  }
     63
     64
     65  Suite::~Suite(void)
     66  {
     67    delete dev_null_;
     68  }
     69
     70 
     71  bool Suite::add(bool b)
     72  {
     73    ok_ = ok_ && b;
     74    return b;
     75  }
     76
     77
     78  bool Suite::ok(void) const
     79  {
     80    return ok_;
     81  }
     82
     83
     84  std::ostream& Suite::out(void) const
     85  {
     86    if (verbose())
     87      return std::cout;
     88    return *dev_null_;
     89  }
     90
     91
     92  void Suite::update_test_wc(void) const
     93  {
     94    std::string cmd = abs_builddir()+"/svn_update.sh";
     95    out() << cmd << std::endl;
     96    int status = system(cmd.c_str());
     97    if (status) {
     98      out() << "failed with status: " << status << std::endl;
     99      exit (1);
     100    }
     101  }
     102
     103
     104  bool Suite::verbose(void) const
     105  {
     106    return verbose_;
     107  }
     108
     109
    33110  std::string filename(const std::string& path)
    34111  {
    35     return abs_srcdir()+"/"+path;
     112    return abs_builddir()+"/"+path;
    36113  }
    37114
  • branches/replacing_gnuplot/test/Suite.h

    r596 r784  
    55
    66/*
    7   Copyright (C) 2008 Peter Johansson
     7  Copyright (C) 2008, 2009 Peter Johansson
    88
    9   This file is part of svndigest, http://trac.thep.lu.se/svndigest
     9  This file is part of svndigest, http://dev.thep.lu.se/svndigest
    1010
    1111  svndigest is free software; you can redistribute it and/or modify it
    1212  under the terms of the GNU General Public License as published by
    13   the Free Software Foundation; either version 2 of the License, or
     13  the Free Software Foundation; either version 3 of the License, or
    1414  (at your option) any later version.
    1515
     
    2020
    2121  You should have received a copy of the GNU General Public License
    22   along with this program; if not, write to the Free Software
    23   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    24   02111-1307, USA.
     22  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
    2523*/
    2624
     
    3331namespace test {
    3432
     33  class Suite
     34  {
     35  public:
     36    Suite(int argc, char* argv[], bool need_test_repo=false);
     37    ~Suite(void);
     38
     39    /**
     40       If b is false, set ok to false
     41
     42       \return b
     43    */
     44    bool add(bool b);
     45
     46    /**
     47       \return true if all tests are OK
     48     */
     49    bool ok(void) const;
     50
     51    std::ostream& out(void) const;
     52
     53    /**
     54       \return true if we are running in verbose mode
     55     */
     56    bool verbose(void) const;
     57
     58  private:
     59    std::ofstream* dev_null_;
     60    bool ok_;
     61    bool verbose_;
     62
     63    void checkout_test_wc(void) const;
     64    void update_test_wc(void) const;
     65  };
     66
    3567  /**
    3668     \return absolute path to file
  • branches/replacing_gnuplot/test/check_repo_status.sh.in

    r570 r784  
    77# Copyright (C) 2008 Peter Johansson
    88#
    9 # This file is part of svndigest, http://trac.thep.lu.se/svndigest
     9# This file is part of svndigest, http://dev.thep.lu.se/svndigest
    1010#
    1111# svndigest is free software; you can redistribute it and/or modify it
    1212# under the terms of the GNU General Public License as published by
    13 # the Free Software Foundation; either version 2 of the License, or
     13# the Free Software Foundation; either version 3 of the License, or
    1414# (at your option) any later version.
    1515#
     
    2020#
    2121# You should have received a copy of the GNU General Public License
    22 # along with this program; if not, write to the Free Software
    23 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    24 # 02111-1307, USA.
     22# along with svndigest. If not, see <http://www.gnu.org/licenses/>.
     23
     24wc_found="@wc_found@"
     25if test $wc_found = "no"; then
     26    exit 77;
     27fi
     28
    2529
    2630# assume test repository and svndigest repository are synchronized
  • branches/replacing_gnuplot/test/config_test.cc

    r556 r784  
    44  Copyright (C) 2008 Peter Johansson
    55
    6   This file is part of svndigest, http://trac.thep.lu.se/svndigest
     6  This file is part of svndigest, http://dev.thep.lu.se/svndigest
    77
    88  svndigest is free software; you can redistribute it and/or modify it
    99  under the terms of the GNU General Public License as published by
    10   the Free Software Foundation; either version 2 of the License, or
     10  the Free Software Foundation; either version 3 of the License, or
    1111  (at your option) any later version.
    1212
     
    1717
    1818  You should have received a copy of the GNU General Public License
    19   along with this program; if not, write to the Free Software
    20   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    21   02111-1307, USA.
     19  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
    2220*/
    2321
  • branches/replacing_gnuplot/test/copyright_test.cc

    r646 r784  
    22
    33/*
    4   Copyright (C) 2008 Peter Johansson
     4  Copyright (C) 2008, 2009 Peter Johansson
    55
    6   This file is part of svndigest, http://trac.thep.lu.se/svndigest
     6  This file is part of svndigest, http://dev.thep.lu.se/svndigest
    77
    88  svndigest is free software; you can redistribute it and/or modify it
    99  under the terms of the GNU General Public License as published by
    10   the Free Software Foundation; either version 2 of the License, or
     10  the Free Software Foundation; either version 3 of the License, or
    1111  (at your option) any later version.
    1212
     
    1717
    1818  You should have received a copy of the GNU General Public License
    19   along with this program; if not, write to the Free Software
    20   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    21   02111-1307, USA.
     19  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
    2220*/
    2321
     
    4139{
    4240  using namespace theplu::svndigest;
    43   bool verbose=false;
    44   bool ok=true;
    45   if (argc>1 && argv[1]==std::string("-v") )
    46     verbose=true;
     41  test::Suite suite(argc, argv, true);
    4742
    4843  std::string root=test::filename("toy_project");
     
    6358
    6459  if (copyrights_old.size()!=1) {
    65     if (verbose){
    66       std::cout << copyrights_old.size() << " Copyright lines\n";
    67       for (size_t i=0; i<copyrights_old.size(); ++i)
    68         std::cout << copyrights_old[i] << "\n";
    69     }
    70     ok = false;
     60    suite.out() << copyrights_old.size() << " Copyright lines\n";
     61    for (size_t i=0; i<copyrights_old.size(); ++i)
     62      suite.out() << copyrights_old[i] << "\n";
     63    suite.add(false);
    7164  }
    72   else if (verbose)
    73     std::cout << "File contains 1 copyright line.\n";
     65  suite.out() << "File contains 1 copyright line.\n";
    7466
    7567  // warn about missing Copyright statement only in verbose mode
    76   if (verbose){
     68  if (suite.verbose()){
    7769    std::string config_str("[copyright]\nmissing-copyright-warning=yes");
    7870    std::stringstream ss(config_str);
     
    8173  }
    8274
    83   if (verbose)
    84     std::cout << "Create SVN instance" << std::endl;
     75  suite.out() << "Create SVN instance" << std::endl;
    8576  SVN* svn=SVN::instance(root);
    8677  if (!svn)
     
    8879
    8980  // Extract repository location
    90   if (verbose)
    91     std::cout << "Extract repository location" << std::endl;
     81  suite.out() << "Extract repository location" << std::endl;
    9282  std::string repo=SVNinfo(root).repos_root_url();
    93   if (verbose)
    94     std::cout << "Create File object" << std::endl;
     83  suite.out() << "Create File object" << std::endl;
    9584  File file(0,filename,"");
    9685 
    97   if (verbose)
    98     std::cout << "Get stats for file" << std::endl;
    99   file.parse(verbose, true);
     86  suite.out() << "Get stats for file" << std::endl;
     87  file.parse(suite.verbose(), true);
    10088 
    101   if (verbose)
    102     std::cout << "Updating copyright statements" << std::endl;
     89  suite.out() << "Updating copyright statements" << std::endl;
    10390  std::map<std::string, Alias> alias;
    10491  alias["jari"]=Alias("jh", 1);
    10592  alias["peter"]=Alias("pj", 2);
    10693 
    107   file.print_copyright(alias, verbose);
     94  file.print_copyright(alias, suite.verbose());
    10895
    10996  is.open(filename.c_str());
     
    116103  copyright_correct.push_back("Copyright (C) 2007, 2008 pj");
    117104  if (copyrights.size()!=copyright_correct.size()) {
    118     ok = false;
    119     if (verbose)
    120       std::cout << "ERROR: expected " << copyright_correct.size()
     105    suite.add(false);
     106    suite.out() << "ERROR: expected " << copyright_correct.size()
    121107                << " lines of Copyright (C)\n"
    122108                << "But found " << copyrights.size() << " lines.\n";
     
    125111    for (size_t i=0; i<copyrights.size(); ++i)
    126112      if (copyrights[i]!=copyright_correct[i]){
    127         ok=false;
    128         if (verbose)
    129           std::cerr << "ERROR: found '" << copyrights[i] << "'\n"
     113        suite.add(false);
     114        suite.out() << "ERROR: found '" << copyrights[i] << "'\n"
    130115                    << "expected: '" << copyright_correct[i] << "'\n";
    131116      }
     
    140125  os.close();
    141126
    142   if (ok) {
    143     if (verbose)
    144       std::cout << "Test is Ok!" << std::endl;
     127  if (suite.ok()) {
     128    suite.out() << "Test is Ok!" << std::endl;
    145129    return 0;
    146130  }
    147   if (verbose)
    148     std::cout << "Test failed." << std::endl;
     131  suite.out() << "Test failed." << std::endl;
    149132  return 1;
    150133}
  • branches/replacing_gnuplot/test/date_test.cc

    r646 r784  
    44  Copyright (C) 2007 Peter Johansson
    55
    6   This file is part of svndigest, http://trac.thep.lu.se/svndigest
     6  This file is part of svndigest, http://dev.thep.lu.se/svndigest
    77
    88  svndigest is free software; you can redistribute it and/or modify it
    99  under the terms of the GNU General Public License as published by
    10   the Free Software Foundation; either version 2 of the License, or
     10  the Free Software Foundation; either version 3 of the License, or
    1111  (at your option) any later version.
    1212
     
    1717
    1818  You should have received a copy of the GNU General Public License
    19   along with this program; if not, write to the Free Software
    20   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    21   02111-1307, USA.
     19  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
    2220*/
    2321
  • branches/replacing_gnuplot/test/environment.h.in

    r601 r784  
    88  Copyright (C) 2008 Peter Johansson
    99
    10   This file is part of svndigest, http://trac.thep.lu.se/svndigest
     10  This file is part of svndigest, http://dev.thep.lu.se/svndigest
    1111
    1212  svndigest is free software; you can redistribute it and/or modify it
    1313  under the terms of the GNU General Public License as published by
    14   the Free Software Foundation; either version 2 of the License, or
     14  the Free Software Foundation; either version 3 of the License, or
    1515  (at your option) any later version.
    1616
     
    2121
    2222  You should have received a copy of the GNU General Public License
    23   along with this program; if not, write to the Free Software
    24   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    25   02111-1307, USA.
     23  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
    2624*/
    2725
     
    3331
    3432  inline std::string abs_srcdir(void) { return "@abs_srcdir@"; }
     33  inline std::string abs_builddir(void) { return "@abs_builddir@"; }
    3534
    3635}}}
  • branches/replacing_gnuplot/test/gnuplot_pipe_test.cc

    r646 r784  
    44  Copyright (C) 2006 Jari Häkkinen, Peter Johansson
    55
    6   This file is part of svndigest, http://trac.thep.lu.se/svndigest
     6  This file is part of svndigest, http://dev.thep.lu.se/svndigest
    77
    88  svndigest is free software; you can redistribute it and/or modify it
    99  under the terms of the GNU General Public License as published by
    10   the Free Software Foundation; either version 2 of the License, or
     10  the Free Software Foundation; either version 3 of the License, or
    1111  (at your option) any later version.
    1212
     
    1717
    1818  You should have received a copy of the GNU General Public License
    19   along with this program; if not, write to the Free Software
    20   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    21   02111-1307, USA.
     19  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
    2220*/
    2321
  • branches/replacing_gnuplot/test/parser_test.cc

    r646 r784  
    55  Copyright (C) 2007 Peter Johansson
    66
    7   This file is part of svndigest, http://trac.thep.lu.se/svndigest
     7  This file is part of svndigest, http://dev.thep.lu.se/svndigest
    88
    99  svndigest is free software; you can redistribute it and/or modify it
    1010  under the terms of the GNU General Public License as published by
    11   the Free Software Foundation; either version 2 of the License, or
     11  the Free Software Foundation; either version 3 of the License, or
    1212  (at your option) any later version.
    1313
     
    1818
    1919  You should have received a copy of the GNU General Public License
    20   along with this program; if not, write to the Free Software
    21   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    22   02111-1307, USA.
     20  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
    2321*/
    2422
  • branches/replacing_gnuplot/test/stats_test.cc

    r604 r784  
    22
    33/*
    4   Copyright (C) 2008 Peter Johansson
    5 
    6   This file is part of svndigest, http://trac.thep.lu.se/svndigest
     4  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2009 Peter Johansson
     6
     7  This file is part of svndigest, http://dev.thep.lu.se/svndigest
    78
    89  svndigest is free software; you can redistribute it and/or modify it
    910  under the terms of the GNU General Public License as published by
    10   the Free Software Foundation; either version 2 of the License, or
     11  the Free Software Foundation; either version 3 of the License, or
    1112  (at your option) any later version.
    1213
     
    1718
    1819  You should have received a copy of the GNU General Public License
    19   along with this program; if not, write to the Free Software
    20   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    21   02111-1307, USA.
     20  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
    2221*/
    2322
     
    3837#include <numeric>
    3938#include <string>
     39#include <sstream>
    4040#include <vector>
    4141
     
    4343namespace svndigest{
    4444
    45   bool check(const Stats& stats, const std::vector<size_t>& correct,
     45  bool check(const Stats& stats, const std::vector<int>& correct,
    4646             int linetype, const std::string& descr, const std::string& author);
    4747  std::string path(void);
     
    5050  bool test_classic(void);
    5151  bool test_base_class(const Stats&);
     52  bool test_cache(const Stats&);
    5253 
    5354}} // end of namespace svndigest and theplu
     
    5758{
    5859  using namespace theplu::svndigest;
    59   bool verbose=false;
     60  test::Suite suite(argc, argv, true);
     61
     62  bool verbose=suite.verbose();
    6063  bool ok=true;
    61   if (argc>1 && argv[1]==std::string("-v") )
    62     verbose=true;
     64
    6365  SVN* svn=SVN::instance(test::filename("toy_project"));
    6466  if (!svn){
     
    7173  ok &= test_classic();
    7274                                                                               
    73   if (verbose)
     75  if (verbose) {
    7476    if (ok)
    7577      std::cout << "Test is ok.\n";
    7678    else
    7779      std::cout << "Test failed.\n";
     80  }
    7881  if (ok)
    7982    return 0;
     
    9699    cs.parse(path());
    97100    ok &= test_base_class(cs);
     101
     102    std::vector<int> correct(62,0);
     103    correct[15] = 71;
     104    correct[16] = 3;
     105    correct[17] = 7;
     106    correct[28] = 35;
     107    correct[30] = 63;
     108    ok &= check(cs, correct, LineTypeParser::total, "total", "jari");
     109    correct[42] = 1;
     110    correct[43] = 1;
     111    correct[44] = 2;
     112    correct[47] = 2;
     113    ok &= check(cs, correct, LineTypeParser::total, "total", "all");
     114    std::fill(correct.begin(), correct.end(), 0);
     115    correct[42] = 1;
     116    correct[43] = 1;
     117    correct[44] = 2;
     118    correct[47] = 2;
     119    ok &= check(cs, correct, LineTypeParser::copyright, "copyright", "peter");
     120    std::fill(correct.begin(), correct.end(), 0);
     121    correct[15] = 49;
     122    correct[16] = 3;
     123    correct[17] = 7;
     124    correct[28] = 11;
     125    correct[30] = 54;
     126    ok &= check(cs, correct, LineTypeParser::code, "code", "jari");
     127    std::fill(correct.begin(), correct.end(), 0);
     128    correct[15] = 5;
     129    correct[28] = 13;
     130    correct[30] = 7;
     131    ok &= check(cs, correct, LineTypeParser::comment, "comment", "jari");
     132    std::fill(correct.begin(), correct.end(), 0);
     133    correct[15] = 17;
     134    correct[28] = 10;
     135    correct[30] = 2;
     136    ok &= check(cs, correct, LineTypeParser::other, "other", "jari");
     137
    98138    return ok;
    99139  }
     
    106146    cs.parse(path());
    107147    ok &= test_base_class(cs);
    108     return ok;
    109   }
    110 
    111  
     148
     149    std::vector<int> correct(62,0);
     150    correct[15] = 71;
     151    correct[16] = -1;
     152    correct[17] = 2;
     153    correct[28] = 31;
     154    correct[30] = 25;
     155    correct[42] = -1;
     156    ok &= check(cs, correct, LineTypeParser::total, "total", "jari");
     157    correct[42] = 0;
     158    correct[43] = 1;
     159    ok &= check(cs, correct, LineTypeParser::total, "total", "all");
     160    std::fill(correct.begin(), correct.end(), 0);
     161    correct[42] = 1;
     162    correct[43] = 1;
     163    ok &= check(cs, correct, LineTypeParser::copyright, "copyright", "peter");
     164    std::fill(correct.begin(), correct.end(), 0);
     165    correct[15] = 49;
     166    correct[17] = 2;
     167    correct[28] = 8;
     168    correct[30] = 54-29;
     169    ok &= check(cs, correct, LineTypeParser::code, "code", "jari");
     170    std::fill(correct.begin(), correct.end(), 0);
     171    correct[15] = 5;
     172    correct[16] = -1;
     173    correct[28] = 13;
     174    correct[30] = 7-3;
     175    ok &= check(cs, correct, LineTypeParser::comment, "comment", "jari");
     176    std::fill(correct.begin(), correct.end(), 0);
     177    correct[15] = 17;
     178    correct[28] = 10-1;
     179    correct[30] = 2-6;
     180    ok &= check(cs, correct, LineTypeParser::other, "other", "jari");
     181
     182    return ok;
     183  }
     184
     185 
     186  bool test_cache(const Stats& stats)
     187  {
     188    std::stringstream out;
     189    stats.print(out);
     190    std::stringstream in(out.str());
     191    ClassicStats stats2(path());
     192    assert(in.good());
     193    if (!stats2.load_cache(in)){
     194      std::cout << "load_cache() failed\n";
     195      return false;
     196    }
     197
     198    std::stringstream out2;
     199    stats2.print(out2);
     200   
     201    if (out.str()!=out2.str()) {
     202      std::cout << "test_cache() failed\n";
     203      return false;
     204    }
     205    return true;
     206  }
     207
     208
    112209  bool test_classic(void)
    113210  {
     
    118215
    119216    // testing copyright lines for peter
    120     std::vector<size_t> correct(48,0);
     217    std::vector<int> correct(48,0);
    121218    correct[47]=2;
    122219    ok &= check(cs, correct, LineTypeParser::copyright, "copyright", "peter");
     
    162259  }
    163260 
    164   bool check(const Stats& stats, const std::vector<size_t>& correct,
     261  bool check(const Stats& stats, const std::vector<int>& correct,
    165262             int linetype, const std::string& descr, const std::string& author)
    166263  {
     
    171268      size_t n = stats(linetype, author, rev);
    172269      if (n != sum[rev]){
    173         std::cerr << "error: " << descr << " " << author << " rev:" << rev
     270        std::cout << "error: " << descr << " " << author << " rev:" << rev
    174271                  << ": found " << n << " expected " << sum[rev] << "\n";
    175272        ok = false;
    176273      }
    177274    }
    178     return true;
     275    return ok;
    179276  }
    180277
    181278  bool test_base_class(const Stats& s)
    182279  {
     280    if (!test_cache(s))
     281      return false;
    183282    if (s.code()+s.comments()+s.empty()!=s.lines()){
    184283      std::cerr << "Code plus comments plus empty do not add up to lines\n";
  • branches/replacing_gnuplot/test/test_repo.sh.in

    r600 r784  
    55
    66# Copyright (C) 2007 Jari Häkkinen, Peter Johansson
    7 # Copyright (C) 2008 Peter Johansson
     7# Copyright (C) 2008, 2009 Peter Johansson
    88#
    9 # This file is part of svndigest, http://trac.thep.lu.se/svndigest
     9# This file is part of svndigest, http://dev.thep.lu.se/svndigest
    1010#
    1111# svndigest is free software; you can redistribute it and/or modify it
    1212# under the terms of the GNU General Public License as published by
    13 # the Free Software Foundation; either version 2 of the License, or
     13# the Free Software Foundation; either version 3 of the License, or
    1414# (at your option) any later version.
    1515#
     
    2020#
    2121# You should have received a copy of the GNU General Public License
    22 # along with this program; if not, write to the Free Software
    23 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    24 # 02111-1307, USA.
     22# along with svndigest. If not, see <http://www.gnu.org/licenses/>.
    2523
    26 rootdir=@abs_srcdir@/toy_project
    27 targetdir=@abs_builddir@/generated_output
    28 repodir=@abs_srcdir@/repo/trunk
     24abs_top_builddir=@abs_top_builddir@
     25abs_builddir=@abs_builddir@
     26rootdir=$abs_builddir/toy_project
     27targetdir=$abs_builddir/generated_output
    2928
    30 svn update $rootdir > /dev/null;
    31 
    32 if [ ! -d $targetdir ]; then
    33     mkdir $targetdir;
     29test_repo_found=@test_repo_found@
     30if test x$test_repo_found != xyes; then
     31    exit 77;
    3432fi
    3533
    36 @abs_top_builddir@/bin/svndigest -r $rootdir -t $targetdir -f \
     34cd $abs_builddir && @SHELL@ svn_update.sh || exit 1;
     35
     36@MKDIR_P@ $targetdir;
     37
     38$abs_top_builddir/bin/svndigest -r $rootdir -t $targetdir \
    3739--ignore-cache --no-report $1;
    3840
    39 @abs_top_builddir@/bin/svndigest -r $rootdir -t $targetdir -f $1;
     41$abs_top_builddir/bin/svndigest -r $rootdir -t $targetdir -f $1;
    4042
  • branches/replacing_gnuplot/test/trac_test.cc

    r646 r784  
    22
    33/*
    4   Copyright (C) 2007 Peter Johansson
     4  Copyright (C) 2007, 2008, 2009 Peter Johansson
    55
    6   This file is part of svndigest, http://trac.thep.lu.se/svndigest
     6  This file is part of svndigest, http://dev.thep.lu.se/svndigest
    77
    88  svndigest is free software; you can redistribute it and/or modify it
    99  under the terms of the GNU General Public License as published by
    10   the Free Software Foundation; either version 2 of the License, or
     10  the Free Software Foundation; either version 3 of the License, or
    1111  (at your option) any later version.
    1212
     
    1717
    1818  You should have received a copy of the GNU General Public License
    19   along with this program; if not, write to the Free Software
    20   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    21   02111-1307, USA.
     19  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
    2220*/
    2321
     
    3331
    3432bool test(std::string mess, std::string href, std::ostream&);
     33bool test_no_anchor(std::string str, std::ostream&);
    3534
    3635int main(const int argc,const char* argv[])
     
    8079  ok &= test("#65", conf.trac_root()+"ticket/65", my_out);
    8180  ok &= test("ticket:65", conf.trac_root()+"ticket/65", my_out);
     81  ok &= test_no_anchor("Container2D", my_out);
     82  ok &= test_no_anchor("r2b", my_out);
     83  ok &= test_no_anchor("ar2", my_out);
     84  ok &= test_no_anchor("2r2", my_out);
     85  ok &= test_no_anchor("r2r3", my_out);
     86  ok &= test_no_anchor("ar2:3", my_out);
     87  ok &= test_no_anchor("r2:3a", my_out);
    8288
    8389  if (ok)
     
    102108}
    103109
     110bool test_no_anchor(std::string str, std::ostream& os)
     111{
     112  using namespace theplu::svndigest;
     113  std::stringstream ss;
     114  HtmlStream html(ss);
     115  Trac trac(html);
     116  trac.print(str,80);
     117  if (ss.str()!=str) {
     118    os << "error:\n";
     119    os << "  message: " << str << std::endl;
     120    os << "  trac generates output:\n     " << ss.str() << std::endl;
     121    os << "  expected:\n     " << str << std::endl;
     122    return false;
     123  }
     124  return true;
     125}
  • branches/replacing_gnuplot/test/utility_test.cc

    r589 r784  
    33/*
    44  Copyright (C) 2007 Peter Johansson
     5  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
    56
    6   This file is part of svndigest, http://trac.thep.lu.se/svndigest
     7  This file is part of svndigest, http://dev.thep.lu.se/svndigest
    78
    89  svndigest is free software; you can redistribute it and/or modify it
    910  under the terms of the GNU General Public License as published by
    10   the Free Software Foundation; either version 2 of the License, or
     11  the Free Software Foundation; either version 3 of the License, or
    1112  (at your option) any later version.
    1213
     
    1718
    1819  You should have received a copy of the GNU General Public License
    19   along with this program; if not, write to the Free Software
    20   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    21   02111-1307, USA.
     20  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
    2221*/
    2322
Note: See TracChangeset for help on using the changeset viewer.