--- /dev/null
+Processed 10 csets from 4 developers
+4 employers found
+A total of 24 lines added, 24 removed (delta 0)
+
+Developers with the most changesets
+Martin Nordholts 6 (60.0%)
+Random Joe 2 (20.0%)
+Line Remover 1 (10.0%)
+Punk Rocker 1 (10.0%)
+
+Developers with the most changed lines
+Line Remover 14 (34.1%)
+Random Joe 13 (31.7%)
+Martin Nordholts 10 (24.4%)
+Punk Rocker 1 (2.4%)
+
+Developers with the most lines removed
+Line Remover 14 (58.3%)
+
+Developers with the most signoffs (total 2)
+Martin Nordholts 2 (100.0%)
+
+Developers with the most reviews (total 0)
+
+Developers with the most test credits (total 0)
+
+Developers who gave the most tested-by credits (total 0)
+
+Developers with the most report credits (total 0)
+
+Developers who gave the most report credits (total 0)
+
+Top changeset contributors by employer
+enselic@gmail.com 6 (60.0%)
+random.joe@example.com 2 (20.0%)
+line.remover@bogus.bo 1 (10.0%)
+punk.rocker@example.com 1 (10.0%)
+
+Top lines changed by employer
+line.remover@bogus.bo 14 (34.1%)
+enselic@gmail.com 13 (31.7%)
+random.joe@example.com 13 (31.7%)
+punk.rocker@example.com 1 (2.4%)
+
+Employers with the most signoffs (total 2)
+enselic@gmail.com 2 (100.0%)
--- /dev/null
+#!/usr/bin/python
+#
+
+#
+# This code is part of the LWN git data miner.
+#
+# Copyright 2009 Martin Nordholts <martinn@src.gnome.org>
+#
+# This file may be distributed under the terms of the GNU General
+# Public License, version 2.
+
+import unittest, subprocess, os
+
+class GitdmTests(unittest.TestCase):
+
+ ##
+ # Setup test fixture.
+ #
+ def setUp(self):
+ self.srcdir = os.getcwd ()
+ self.git_dir = os.path.join (self.srcdir, "tests/testrepo")
+ if not os.path.exists (self.git_dir):
+ self.fail ("'" + self.git_dir + "' didn't exist, you probably "+
+ "didn't run the test with the source root as the working directory.")
+
+
+ ##
+ # Makes sure that the statistics collected for the test repository
+ # is the expected statistics. Note that the test must be run with
+ # the working directory as the source root and with git in the
+ # PATH.
+ #
+ def testResultOutputRegressionTest(self):
+
+ # Build paths
+ actual_results_path = os.path.join (self.srcdir, "tests/actual-results.txt")
+ expected_results_path = os.path.join (self.srcdir, "tests/expected-results.txt")
+
+ # Run actual test
+ self.runOutputFileRegressionTest (expected_results_path,
+ actual_results_path,
+ ["-o", actual_results_path])
+
+
+ ##
+ # Does a regression test on the datelc (data line count) file
+ #
+ def testDateLineCountOutputRegressionTest(self):
+
+ # Build paths
+ actual_datelc_path = os.path.join (self.srcdir, "datelc")
+ expected_datelc_path = os.path.join (self.srcdir, "tests/expected-datelc")
+
+ # Run actual test
+ self.runOutputFileRegressionTest (expected_datelc_path,
+ actual_datelc_path,
+ ["-D"])
+
+
+ ##
+ # Run a test, passing path to file with expected output, path to
+ # file which will countain the actual output, and arguments to
+ # pass to gitdm. We both make sure the file where the result will
+ # be put when gitdm is run does not exist beforehand, and we clean
+ # up after we are done.
+ #
+ def runOutputFileRegressionTest(self, expected_output_path, actual_output_path, arguments):
+
+ # Make sure we can safely run the test
+ self.ensureFileDoesNotExist (actual_output_path)
+
+ try:
+ # Collect statistics
+ self.runGitdm (arguments)
+
+ # Make sure we got the result we expected
+ self.assertFilesEqual (expected_output_path, actual_output_path)
+
+ finally:
+ # Remove any file we created, also if test fails
+ self.purgeFile (actual_output_path)
+
+
+ ##
+ # If passed file exists, delete it.
+ #
+ def purgeFile(self, filename):
+ if os.path.exists (filename):
+ os.remove (filename)
+
+
+ ##
+ # Make sure the file does not exist so we don't risk overwriting
+ # an important file.
+ #
+ def ensureFileDoesNotExist(self, filename):
+ if os.path.exists (filename):
+ self.fail ("The file '" + filename + "' exists, failing "
+ "test to avoid overwriting file.")
+
+
+ ##
+ # Run gitdm on the test repository with the passed arguments.
+ #
+ def runGitdm(self, arguments):
+ git_log_process = subprocess.Popen (["git", "--git-dir", self.git_dir, "log", "-p", "-M"],
+ stdout=subprocess.PIPE)
+ gitdm_process = subprocess.Popen (["./gitdm"] + arguments,
+ stdin=git_log_process.stdout)
+ gitdm_process.communicate ()
+
+
+ ##
+ # Makes sure the files have the same content.
+ #
+ def assertFilesEqual(self, file1, file2):
+ f = open (file1, 'r')
+ file1_contents = f.read ()
+ f.close ()
+ f = open (file2, 'r')
+ file2_contents = f.read ()
+ f.close ()
+ self.assertEqual (file1_contents, file2_contents,
+ "The files '" + file1 + "' and '" +
+ file2 + "' were not equal!")
+
+
+if __name__ == '__main__':
+ unittest.main ()