1478 |
29 May 12 |
peter |
// $Id$ |
1478 |
29 May 12 |
peter |
2 |
|
1478 |
29 May 12 |
peter |
3 |
/* |
1635 |
30 Mar 23 |
peter |
Copyright (C) 2012, 2023 Peter Johansson |
1478 |
29 May 12 |
peter |
5 |
|
1478 |
29 May 12 |
peter |
This file is part of svndigest, http://dev.thep.lu.se/svndigest |
1478 |
29 May 12 |
peter |
7 |
|
1478 |
29 May 12 |
peter |
svndigest is free software; you can redistribute it and/or modify it |
1478 |
29 May 12 |
peter |
under the terms of the GNU General Public License as published by |
1478 |
29 May 12 |
peter |
the Free Software Foundation; either version 3 of the License, or |
1478 |
29 May 12 |
peter |
(at your option) any later version. |
1478 |
29 May 12 |
peter |
12 |
|
1478 |
29 May 12 |
peter |
svndigest is distributed in the hope that it will be useful, but |
1478 |
29 May 12 |
peter |
WITHOUT ANY WARRANTY; without even the implied warranty of |
1478 |
29 May 12 |
peter |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1478 |
29 May 12 |
peter |
General Public License for more details. |
1478 |
29 May 12 |
peter |
17 |
|
1478 |
29 May 12 |
peter |
You should have received a copy of the GNU General Public License |
1478 |
29 May 12 |
peter |
along with svndigest. If not, see <http://www.gnu.org/licenses/>. |
1478 |
29 May 12 |
peter |
20 |
*/ |
1478 |
29 May 12 |
peter |
21 |
|
1478 |
29 May 12 |
peter |
// Testing that loading a cache file does not fail, i.e., protecting |
1478 |
29 May 12 |
peter |
// development from breaking compatibility with old cache files. |
1478 |
29 May 12 |
peter |
24 |
|
1619 |
12 Mar 23 |
peter |
25 |
#include <config.h> |
1619 |
12 Mar 23 |
peter |
26 |
|
1478 |
29 May 12 |
peter |
27 |
#include "Suite.h" |
1478 |
29 May 12 |
peter |
28 |
|
1478 |
29 May 12 |
peter |
29 |
#include "lib/File.h" |
1478 |
29 May 12 |
peter |
30 |
#include "lib/SVN.h" |
1478 |
29 May 12 |
peter |
31 |
#include "lib/StatsCollection.h" |
1478 |
29 May 12 |
peter |
32 |
#include "lib/utility.h" |
1478 |
29 May 12 |
peter |
33 |
|
1523 |
28 Sep 12 |
peter |
34 |
#include <cassert> |
1478 |
29 May 12 |
peter |
35 |
#include <fstream> |
1478 |
29 May 12 |
peter |
36 |
|
1478 |
29 May 12 |
peter |
37 |
using namespace theplu::svndigest; |
1478 |
29 May 12 |
peter |
38 |
|
1478 |
29 May 12 |
peter |
39 |
void main2(test::Suite& suite); |
1478 |
29 May 12 |
peter |
40 |
|
1478 |
29 May 12 |
peter |
41 |
int main( int argc, char* argv[]) |
1478 |
29 May 12 |
peter |
42 |
{ |
1478 |
29 May 12 |
peter |
43 |
test::Suite suite(argc, argv, true); |
1478 |
29 May 12 |
peter |
44 |
|
1478 |
29 May 12 |
peter |
45 |
try { |
1478 |
29 May 12 |
peter |
46 |
main2(suite); |
1478 |
29 May 12 |
peter |
47 |
} |
1478 |
29 May 12 |
peter |
48 |
catch (std::runtime_error& e) { |
1478 |
29 May 12 |
peter |
49 |
suite.out() << "error: " << e.what() << "\n"; |
1478 |
29 May 12 |
peter |
50 |
suite.add(false); |
1478 |
29 May 12 |
peter |
51 |
} |
1478 |
29 May 12 |
peter |
52 |
return suite.exit_status(); |
1478 |
29 May 12 |
peter |
53 |
} |
1478 |
29 May 12 |
peter |
54 |
|
1478 |
29 May 12 |
peter |
55 |
|
1478 |
29 May 12 |
peter |
56 |
void main2(test::Suite& suite) |
1478 |
29 May 12 |
peter |
57 |
{ |
1478 |
29 May 12 |
peter |
// update wc to rev 61 |
1478 |
29 May 12 |
peter |
59 |
suite.system("svn update -r 61 toy_project", 0); |
1478 |
29 May 12 |
peter |
60 |
|
1478 |
29 May 12 |
peter |
61 |
mkdir_p("toy_project/.svndigest"); |
1478 |
29 May 12 |
peter |
62 |
std::string root="toy_project"; |
1478 |
29 May 12 |
peter |
63 |
std::string filename = root + "/AUTHORS"; |
1478 |
29 May 12 |
peter |
64 |
suite.out() << "Create SVN instance" << std::endl; |
1478 |
29 May 12 |
peter |
65 |
SVN* svn=SVN::instance(root); |
1478 |
29 May 12 |
peter |
66 |
if (!svn) |
1478 |
29 May 12 |
peter |
67 |
throw std::runtime_error("failed creating SVN instance\n"); |
1478 |
29 May 12 |
peter |
68 |
|
1478 |
29 May 12 |
peter |
69 |
StatsCollection stats(filename); |
1478 |
29 May 12 |
peter |
70 |
std::string cache_file=test::src_filename("data/AUTHORS.svndigest-cache-r61"); |
1478 |
29 May 12 |
peter |
71 |
std::ifstream is(cache_file.c_str()); |
1478 |
29 May 12 |
peter |
72 |
assert(is); |
1478 |
29 May 12 |
peter |
73 |
if (!stats.load_cache(is)) { |
1478 |
29 May 12 |
peter |
74 |
suite.add(false); |
1611 |
12 Feb 23 |
peter |
75 |
suite.out() << "error: failed reading cache file\n"; |
1478 |
29 May 12 |
peter |
76 |
} |
1478 |
29 May 12 |
peter |
77 |
} |
1478 |
29 May 12 |
peter |
78 |
|
1478 |
29 May 12 |
peter |
79 |
|
1478 |
29 May 12 |
peter |
80 |
|
1478 |
29 May 12 |
peter |
81 |
|