// $Id$
/*
Copyright (C) 2012 Peter Johansson
This file is part of svndigest, http://dev.thep.lu.se/svndigest
svndigest is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
svndigest is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with svndigest. If not, see .
*/
// Testing that partial ignore works
#include "Suite.h"
#include "lib/Configuration.h"
#include "lib/File.h"
#include "lib/SVN.h"
#include "lib/Stats.h"
#include "lib/StatsCollection.h"
#include "lib/utility.h"
#include
#include
#include
#include
using namespace theplu::svndigest;
void compare(const Stats& stats, const std::vector& jari,
const std::vector& peter, test::Suite& suite);
void test_ignore(svn_revnum_t ignore_rev, const std::string& filename,
test::Suite& suite);
int main( int argc, char* argv[])
{
test::Suite suite(argc, argv, true);
std::string root="toy_project";
std::string filename = root + "/AUTHORS";
suite.out() << "Create SVN instance" << std::endl;
SVN* svn=SVN::instance(root);
if (!svn)
return 1;
test_ignore(0, filename, suite);
test_ignore(2, filename, suite);
test_ignore(48, filename, suite);
test_ignore(62, filename, suite);
test_ignore(67, filename, suite);
return suite.exit_status();
}
void test_ignore(svn_revnum_t ignore_rev, const std::string& filename,
test::Suite& suite)
{
suite.out() << "svndigest:ignore = " << ignore_rev << "\n";
// create a config and load it
std::stringstream ss;
ss << "[svn-props]\n" << filename << " = "
<< "svndigest:ignore=" << ignore_rev << "\n";
Configuration::instance().load(ss);
File file(0,filename,"");
const StatsCollection& stats = file.parse(suite.verbose(), false, ignore_rev);
suite.add(test::consistent(stats, suite));
suite.out() << "classic:\n";
const Stats& classic = stats["classic"];
std::vector add_jari(classic.revision()+1,0);
std::vector add_peter(add_jari);
std::vector blame_jari(add_jari);
std::vector blame_peter(add_jari);
std::vector rm_jari(add_jari);
std::vector rm_peter(add_jari);
blame_jari[2] = 4;
blame_peter[62] = 3;
blame_peter[67] = 1;
add_jari[2] = 14;
if (ignore_rev<2) {
rm_jari[48] = 7;
rm_jari[62] = 2;
rm_jari[67] = 1;
}
add_peter[62] = 3;
add_peter[67] = 1;
std::vector jari_lines(add_jari.size(), 0);
std::vector peter_lines(add_jari.size(), 0);
for (size_t r=ignore_rev+1; r& expected,
const std::string& author, test::Suite& suite)
{
bool all_zero=true;
for (size_t rev=0; rev& jari,
const std::vector& peter, test::Suite& suite)
{
compare(stats, jari, "jari", suite);
compare(stats, peter, "peter", suite);
}