source: trunk/test/cache.cc @ 1478

Last change on this file since 1478 was 1478, checked in by Peter Johansson, 9 years ago

closes #387

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