- Timestamp:
- Jan 8, 2009, 11:37:12 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 8 8 autom4te.cache 9 9 INSTALL 10 COPYING11 10 aclocal.m4 12 11 Makefile
-
- Property svn:ignore
-
trunk/configure.ac
r743 r744 13 13 # Copyright (C) 2006 Jari Häkkinen 14 14 # Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson 15 # Copyright (C) 2009 Peter Johansson 15 16 # 16 17 # This file is part of svndigest, http://dev.thep.lu.se/svndigest … … 170 171 # checking if we have test repo 171 172 test_repo_filename=$srcdir/test/repo; 172 AC_CHECK_FILE([$test_repo_filename], [test_repo_found="yes"], 173 AC_CHECK_FILE([$test_repo_filename], 174 [AC_DEFINE([HAVE_TEST_REPO],[1],[define if test repo is available]) 175 test_repo_found="yes"], 173 176 [test_repo_found="no"]) 174 AM_CONDITIONAL([HAVE_TEST_REPO], [test "$test_repo_found" = "yes"])175 177 if (test "$test_repo_found" = "yes"); then 176 178 dnl test repo is not distributed 177 179 AC_CONFIG_FILES([test/test_repo.sh], [chmod +x test/test_repo.sh]) 180 AC_CONFIG_FILES([test/svn_update.sh], [chmod +x test/svn_update.sh]) 178 181 AC_CONFIG_FILES([test/check_repo_status.sh], 179 182 [chmod +x test/check_repo_status.sh]) -
trunk/test/Makefile.am
r738 r744 4 4 5 5 # Copyright (C) 2005, 2006, 2007, 2008 Jari Häkkinen, Peter Johansson 6 # Copyright (C) 2009 Peter Johansson 6 7 # 7 8 # This file is part of svndigest, http://dev.thep.lu.se/svndigest … … 20 21 # along with svndigest. If not, see <http://www.gnu.org/licenses/>. 21 22 22 check_PROGRAMS = config_test date_test gnuplot_pipe_test \ 23 parser_test trac_test utility_test 23 check_SCRIPTS = svn_update.sh 24 24 25 # these tests are only for developers since we do not distribute test repository 26 if HAVE_TEST_REPO 27 check_PROGRAMS += copyright_test stats_test 28 endif 25 check_PROGRAMS = config_test copyright_test date_test gnuplot_pipe_test \ 26 parser_test stats_test trac_test utility_test 29 27 30 TESTS = $(check_PROGRAMS) 31 # these tests are only for developers since we do not distribute test repository 32 if HAVE_TEST_REPO 33 TESTS += test_repo.sh 34 endif 35 TESTS += check_repo_status.sh 28 TESTS = $(check_PROGRAMS) test_repo.sh check_repo_status.sh 36 29 37 30 # tests not yet passing are listed here … … 62 55 utility_test_SOURCES = utility_test.cc 63 56 64 toy_project = toy_project 65 rootdir = $(abs_srcdir)/$(toy_project) 66 targetdir = $(abs_builddir)/generated_output 57 clean-local: 58 rm -rf generated_output toy_project 67 59 68 # some tests need the test repo to be checked out 69 stats_test_DEPENDENCIES = $(toy_project) $(top_builddir)/lib/libsvndigest.a 70 copyright_test_DEPENDENCIES = $(toy_project) $(top_builddir)/lib/libsvndigest.a 71 72 $(toy_project): 73 echo Checking out test repository && \ 74 repo=`cd $(abs_srcdir)/repo && pwd` && \ 75 svn checkout file://$$repo/trunk $(toy_project); 76 77 clean-local: 78 rm -rf *.png *.tmp *~ $(targetdir) 60 mostlyclean-local: 61 rm -f *.png *.tmp *~ -
trunk/test/Suite.cc
r737 r744 2 2 3 3 /* 4 Copyright (C) 2008 Peter Johansson4 Copyright (C) 2008, 2009 Peter Johansson 5 5 6 6 This file is part of the yat library, http://dev.thep.lu.se/yat … … 20 20 */ 21 21 22 #include <config.h> 23 22 24 #include "Suite.h" 23 25 #include "environment.h" 24 26 27 #include "utility.h" 28 29 #include <cassert> 30 #include <fstream> 31 #include <iostream> 25 32 #include <string> 26 33 … … 28 35 namespace svndigest { 29 36 namespace test { 37 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 30 109 31 110 std::string filename(const std::string& path) -
trunk/test/Suite.h
r693 r744 5 5 6 6 /* 7 Copyright (C) 2008 Peter Johansson7 Copyright (C) 2008, 2009 Peter Johansson 8 8 9 9 This file is part of svndigest, http://dev.thep.lu.se/svndigest … … 31 31 namespace test { 32 32 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 33 67 /** 34 68 \return absolute path to file -
trunk/test/copyright_test.cc
r693 r744 2 2 3 3 /* 4 Copyright (C) 2008 Peter Johansson4 Copyright (C) 2008, 2009 Peter Johansson 5 5 6 6 This file is part of svndigest, http://dev.thep.lu.se/svndigest … … 39 39 { 40 40 using namespace theplu::svndigest; 41 bool verbose=false; 42 bool ok=true; 43 if (argc>1 && argv[1]==std::string("-v") ) 44 verbose=true; 41 test::Suite suite(argc, argv, true); 45 42 46 43 std::string root=test::filename("toy_project"); … … 61 58 62 59 if (copyrights_old.size()!=1) { 63 if (verbose){ 64 std::cout << copyrights_old.size() << " Copyright lines\n"; 65 for (size_t i=0; i<copyrights_old.size(); ++i) 66 std::cout << copyrights_old[i] << "\n"; 67 } 68 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); 69 64 } 70 else if (verbose) 71 std::cout << "File contains 1 copyright line.\n"; 65 suite.out() << "File contains 1 copyright line.\n"; 72 66 73 67 // warn about missing Copyright statement only in verbose mode 74 if ( verbose){68 if (suite.verbose()){ 75 69 std::string config_str("[copyright]\nmissing-copyright-warning=yes"); 76 70 std::stringstream ss(config_str); … … 79 73 } 80 74 81 if (verbose) 82 std::cout << "Create SVN instance" << std::endl; 75 suite.out() << "Create SVN instance" << std::endl; 83 76 SVN* svn=SVN::instance(root); 84 77 if (!svn) … … 86 79 87 80 // Extract repository location 88 if (verbose) 89 std::cout << "Extract repository location" << std::endl; 81 suite.out() << "Extract repository location" << std::endl; 90 82 std::string repo=SVNinfo(root).repos_root_url(); 91 if (verbose) 92 std::cout << "Create File object" << std::endl; 83 suite.out() << "Create File object" << std::endl; 93 84 File file(0,filename,""); 94 85 95 if (verbose) 96 std::cout << "Get stats for file" << std::endl; 97 file.parse(verbose, true); 86 suite.out() << "Get stats for file" << std::endl; 87 file.parse(suite.verbose(), true); 98 88 99 if (verbose) 100 std::cout << "Updating copyright statements" << std::endl; 89 suite.out() << "Updating copyright statements" << std::endl; 101 90 std::map<std::string, Alias> alias; 102 91 alias["jari"]=Alias("jh", 1); 103 92 alias["peter"]=Alias("pj", 2); 104 93 105 file.print_copyright(alias, verbose);94 file.print_copyright(alias, suite.verbose()); 106 95 107 96 is.open(filename.c_str()); … … 114 103 copyright_correct.push_back("Copyright (C) 2007, 2008 pj"); 115 104 if (copyrights.size()!=copyright_correct.size()) { 116 ok = false; 117 if (verbose) 118 std::cout << "ERROR: expected " << copyright_correct.size() 105 suite.add(false); 106 suite.out() << "ERROR: expected " << copyright_correct.size() 119 107 << " lines of Copyright (C)\n" 120 108 << "But found " << copyrights.size() << " lines.\n"; … … 123 111 for (size_t i=0; i<copyrights.size(); ++i) 124 112 if (copyrights[i]!=copyright_correct[i]){ 125 ok=false; 126 if (verbose) 127 std::cerr << "ERROR: found '" << copyrights[i] << "'\n" 113 suite.add(false); 114 suite.out() << "ERROR: found '" << copyrights[i] << "'\n" 128 115 << "expected: '" << copyright_correct[i] << "'\n"; 129 116 } … … 138 125 os.close(); 139 126 140 if (ok) { 141 if (verbose) 142 std::cout << "Test is Ok!" << std::endl; 127 if (suite.ok()) { 128 suite.out() << "Test is Ok!" << std::endl; 143 129 return 0; 144 130 } 145 if (verbose) 146 std::cout << "Test failed." << std::endl; 131 suite.out() << "Test failed." << std::endl; 147 132 return 1; 148 133 } -
trunk/test/stats_test.cc
r727 r744 3 3 /* 4 4 Copyright (C) 2008 Jari Häkkinen, Peter Johansson 5 Copyright (C) 2009 Peter Johansson 5 6 6 7 This file is part of svndigest, http://dev.thep.lu.se/svndigest … … 57 58 { 58 59 using namespace theplu::svndigest; 59 bool verbose=false; 60 test::Suite suite(argc, argv, true); 61 62 bool verbose=suite.verbose(); 60 63 bool ok=true; 61 if (argc>1 && argv[1]==std::string("-v") ) 62 verbose=true; 64 63 65 SVN* svn=SVN::instance(test::filename("toy_project")); 64 66 if (!svn){ -
trunk/test/svn_update.sh.in
r736 r744 4 4 # $Id$ 5 5 6 # Copyright (C) 2007 Jari Häkkinen, Peter Johansson 7 # Copyright (C) 2008 Peter Johansson 6 # Copyright (C) 2009 Peter Johansson 8 7 # 9 8 # This file is part of svndigest, http://dev.thep.lu.se/svndigest … … 23 22 24 23 rootdir=@abs_builddir@/toy_project 25 targetdir=@abs_builddir@/generated_output 26 repodir=@abs_srcdir@/repo/trunk 24 25 if test ! -e $rootdir; then 26 repo="@abs_srcdir@/repo"; 27 svn co file://$repo/trunk $rootdir > /dev/null; 28 fi 27 29 28 30 svn update $rootdir > /dev/null; 29 30 if [ ! -d $targetdir ]; then31 mkdir $targetdir;32 fi33 34 @abs_top_builddir@/bin/svndigest -r $rootdir -t $targetdir \35 --ignore-cache --no-report $1;36 37 @abs_top_builddir@/bin/svndigest -r $rootdir -t $targetdir -f $1;38 -
trunk/test/test_repo.sh.in
r736 r744 5 5 6 6 # Copyright (C) 2007 Jari Häkkinen, Peter Johansson 7 # Copyright (C) 2008 Peter Johansson7 # Copyright (C) 2008, 2009 Peter Johansson 8 8 # 9 9 # This file is part of svndigest, http://dev.thep.lu.se/svndigest … … 24 24 rootdir=@abs_builddir@/toy_project 25 25 targetdir=@abs_builddir@/generated_output 26 repodir=@abs_srcdir@/repo/trunk27 26 28 svn update $rootdir > /dev/null; 27 test_repo_found="@test_repo_found@" 28 if test $test_repo_found = "no"; then 29 exit 77; 30 fi 31 32 cd @abs_builddir@ && @SHELL@ svn_update.sh; 29 33 30 34 if [ ! -d $targetdir ]; then
Note: See TracChangeset
for help on using the changeset viewer.