Changeset 801
- Timestamp:
- Jul 6, 2009, 4:07:42 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/StatsCollection.h
r693 r801 60 60 61 61 /** 62 reset everything63 62 */ 64 63 void print(std::ostream&); -
trunk/test/Makefile.am
r795 r801 4 4 5 5 # Copyright (C) 2005, 2006, 2007, 2008 Jari Häkkinen, Peter Johansson 6 # Copyright (C) 2009 Peter Johansson 7 # Copyright (C) 2008 Peter Johansson 6 # Copyright (C) 2008, 2009 Peter Johansson 8 7 # 9 8 # This file is part of svndigest, http://dev.thep.lu.se/svndigest … … 31 30 32 31 # tests not yet passing are listed here 33 XFAIL_TESTS = cache_partial_test32 XFAIL_TESTS = 34 33 35 34 noinst_HEADERS = Suite.h -
trunk/test/Suite.cc
r744 r801 25 25 #include "environment.h" 26 26 27 #include "utility.h" 27 #include "Stats.h" 28 #include "StatsCollection.h" 29 #include "../lib/utility.h" 28 30 29 31 #include <cassert> … … 90 92 91 93 94 bool equal(const StatsCollection& a, const StatsCollection& b, 95 Suite& suite) 96 { 97 if (a.stats().size() != b.stats().size()) { 98 suite.out() << "size mismatch\n"; 99 return false; 100 } 101 std::map<std::string, Stats*>::const_iterator iter1 = a.stats().begin(); 102 std::map<std::string, Stats*>::const_iterator iter2 = b.stats().begin(); 103 while (iter1 != a.stats().end()) { 104 if (iter1->first != iter2->first) { 105 suite.out() << "key mismatch\n"; 106 suite.out() << iter1->first << " vs " << iter2->first << "\n"; 107 return false; 108 } 109 if (!equal(*iter1->second, *iter2->second, suite)) { 110 suite.out() << "error in " << iter1->first << "\n"; 111 return false; 112 } 113 ++iter1; 114 ++iter2; 115 } 116 return true; 117 } 118 119 120 bool equal(const Stats& a, const Stats& b, test::Suite& suite) 121 { 122 if (a.authors() != b.authors()) { 123 suite.out() << "authors are not equal\n"; 124 return false; 125 } 126 if (a.revision() != b.revision()) { 127 suite.out() << "revision mismatch\n"; 128 return false; 129 } 130 std::vector<std::string> authors; 131 authors.reserve(a.authors().size()+1); 132 std::copy(a.authors().begin(), a.authors().end(), 133 std::back_inserter(authors)); 134 authors.push_back("all"); 135 for (int linetype=0; linetype <= LineTypeParser::total; ++linetype) { 136 for (std::vector<std::string>::const_iterator author=authors.begin(); 137 author!=authors.end(); ++author) { 138 for (svn_revnum_t rev=0; rev<a.revision(); ++rev) { 139 size_t ax = a(linetype, *author, rev); 140 size_t bx = b(linetype, *author, rev); 141 if (ax != bx) { 142 suite.out() << "error: linetype: " << linetype 143 << " author " << *author 144 << " rev " << rev << "\n" 145 << " a: " << ax << "\n" 146 << " b: " << bx << "\n"; 147 return false; 148 } 149 } 150 } 151 } 152 return true; 153 } 154 155 92 156 void Suite::update_test_wc(void) const 93 157 { … … 114 178 115 179 180 std::string src_filename(const std::string& path) 181 { 182 return abs_srcdir()+"/"+path; 183 } 184 185 116 186 }}} -
trunk/test/Suite.h
r744 r801 29 29 namespace theplu { 30 30 namespace svndigest { 31 class Stats; 32 class StatsCollection; 33 31 34 namespace test { 32 35 … … 65 68 }; 66 69 70 bool equal(const StatsCollection& a, const StatsCollection& b, 71 test::Suite& suite); 72 73 bool equal(const Stats& a, const Stats& b, test::Suite& suite); 74 67 75 /** 68 76 \return absolute path to file 69 \param local_path path relative to srcdir77 \param local_path path relative to builddir 70 78 */ 71 79 std::string filename(const std::string& local_path); 72 80 81 /** 82 \return absolute path to file 83 \param path path relative to srcdir 84 */ 85 std::string src_filename(const std::string& path); 73 86 }}} 74 87 -
trunk/test/cache_partial_test.cc
r794 r801 24 24 #include "Suite.h" 25 25 26 #include "File.h" 27 #include "SVN.h" 28 #include "SVNinfo.h" 29 30 #include "../lib/utility.h" 31 26 32 #include <iostream> 33 34 using namespace theplu::svndigest; 27 35 28 36 int main( int argc, char* argv[]) 29 37 { 30 using namespace theplu::svndigest;31 38 test::Suite suite(argc, argv, true); 32 39 33 suite.add(false); 40 mkdir_p(test::filename("toy_project/.svndigest")); 41 std::string root=test::filename("toy_project"); 42 std::string filename = root + "/AUTHORS"; 43 suite.out() << "Create SVN instance" << std::endl; 44 SVN* svn=SVN::instance(root); 45 if (!svn) 46 return 1; 47 // Extract repository location 48 suite.out() << "Extract repository location" << std::endl; 49 std::string repo=SVNinfo(root).repos_root_url(); 50 51 // create file ignoring cache file 52 std::string cache_file = 53 test::filename("toy_project/.svndigest/AUTHORS.svndigest-cache"); 54 File file(0,filename,""); 55 const StatsCollection& stats1 = file.parse(suite.verbose(), true); 56 57 // create file using partial cache 58 copy_file(test::src_filename("data/AUTHORS.svndigest-cache-r61"), cache_file); 59 File file2(0,filename,""); 60 const StatsCollection& stats2 = file2.parse(suite.verbose(), false); 61 62 suite.add(equal(stats1, stats2, suite)); 34 63 35 64 if (suite.ok()) { … … 42 71 43 72 73 74
Note: See TracChangeset
for help on using the changeset viewer.