source: trunk/test/cache.cc @ 1523

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

merge release 0.10 into trunk

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.9 KB
Line 
1// $Id: cache.cc 1523 2012-09-28 05:48:51Z 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 <cassert>
33#include <fstream>
34
35using namespace theplu::svndigest;
36
37void main2(test::Suite& suite);
38
39int main( int argc, char* argv[])
40{
41  test::Suite suite(argc, argv, true);
42
43  try {
44    main2(suite);
45  }
46  catch (std::runtime_error& e) {
47    suite.out() << "error: " << e.what() << "\n";
48    suite.add(false);
49  }
50  return suite.exit_status();
51}
52
53
54void main2(test::Suite& suite)
55{
56  // update wc to rev 61
57  suite.system("svn update -r 61 toy_project", 0);
58
59  mkdir_p("toy_project/.svndigest");
60  std::string root="toy_project";
61  std::string filename = root + "/AUTHORS";
62  suite.out() << "Create SVN instance" << std::endl;
63  SVN* svn=SVN::instance(root);
64  if (!svn)
65    throw std::runtime_error("failed creating SVN instance\n");
66
67  StatsCollection stats(filename);
68  std::string cache_file=test::src_filename("data/AUTHORS.svndigest-cache-r61");
69  std::ifstream is(cache_file.c_str());
70  assert(is);
71  if (!stats.load_cache(is)) {
72    suite.add(false);
73    suite.out() << "error: failed reading config file\n";
74  }
75}
76
77
78
79
Note: See TracBrowser for help on using the repository browser.