svnclasses: implemented reading svn log output

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@98 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
vsnijders
2007-02-27 14:09:02 +00:00
parent aaa1e2cc6a
commit 0280be7f26
6 changed files with 421 additions and 298 deletions

View File

@@ -5,7 +5,7 @@ unit TestSvnClasses;
interface
uses
Classes, SysUtils, fpcunit, testutils, testregistry,
Classes, SysUtils, fpcunit, testregistry,
svnclasses;
type
@@ -15,10 +15,15 @@ type
TTestSvnClasses= class(TTestCase)
private
function GetInfoFileName: string;
function GetLogFileName: string;
published
procedure TestHookUp;
procedure TestLoadInfo;
end;
procedure TestLoadLog;
procedure TestLoadSimpleLogPaths;
procedure TestLoadComplexLogPaths;
procedure TestLoadLogTwice;
end;
implementation
@@ -27,12 +32,19 @@ begin
Result := ExtractFilePath(ParamStr(0)) + 'info.xml';
end;
procedure TTestSvnClasses.TestHookUp;
var
InfoFileName: string;
function TTestSvnClasses.GetLogFileName: string;
begin
InfoFileName := GetInfoFileName;
AssertTrue(InfoFileName + ' does not exist', FileExists(InfoFileName));
Result := ExtractFilePath(ParamStr(0)) + 'log.xml';
end;
procedure TTestSvnClasses.TestHookUp;
procedure CheckFile(const FileName: string);
begin
AssertTrue(FileName + ' does not exist', FileExists(FileName));
end;
begin
CheckFile(GetInfoFileName);
CheckFile(GetLogFileName);
end;
procedure TTestSvnClasses.TestLoadInfo;
@@ -63,6 +75,95 @@ begin
end;
end;
procedure TTestSvnClasses.TestLoadLog;
var
SvnLog: TSvnLog;
LogEntry: TLogEntry;
begin
SvnLog := TSvnLog.Create;
try
SvnLog.LoadFromFile(GetLogFileName);
AssertEquals('Wrong number of log entries', 6, SvnLog.LogEntryCount);
LogEntry := SvnLog.LogEntry[0];
AssertEquals('Wrong log revision', 10660, LogEntry.Revision);
AssertEquals('Wrong log author', 'vincents', LogEntry.Author);
AssertEquals('Wrong log date',
'2007-02-20T10:57:42.928052Z', LogEntry.Date);
AssertEquals('Wrong log message',
'TAChart: added icon, added to make bigide', LogEntry.Message);
finally
SvnLog.Free;
end;
end;
procedure TTestSvnClasses.TestLoadSimpleLogPaths;
var
SvnLog: TSvnLog;
LogEntry: TLogEntry;
LogPath: TLogPath;
begin
SvnLog := TSvnLog.Create;
try
SvnLog.LoadFromFile(GetLogFileName);
AssertEquals('Wrong number of log entries', 6, SvnLog.LogEntryCount);
LogEntry := SvnLog.LogEntry[4];
AssertEquals('Wrong log revision', 10664, LogEntry.Revision);
AssertEquals('Wrong number of paths', 1, LogEntry.PathCount);
LogPath := LogEntry.Path[0];
AssertEquals('Wrong path',
'/trunk/lcl/interfaces/win32/win32callback.inc', LogPath.Path);
AssertEquals('Wrong commit action', ord(caModify), ord(LogPath.Action));
finally
SvnLog.Free;
end;
end;
procedure TTestSvnClasses.TestLoadComplexLogPaths;
var
SvnLog: TSvnLog;
LogEntry: TLogEntry;
procedure AssertLogPath(i: integer; action: TCommitAction;
const path, copyfrompath: string; copyfromrev: integer);
var
LogPath: TLogPath;
begin
LogPath := LogEntry.Path[i];
AssertEquals('Wrong commit action', ord(action), ord(LogPath.Action));
AssertEquals('Wrong path', path, LogPath.Path);
AssertEquals('Wrong copy from revision', copyfromrev, LogPath.CopyFromRevision);
AssertEquals('Wrong copy from path', copyfrompath, LogPath.CopyFromPath);
end;
begin
SvnLog := TSvnLog.Create;
try
SvnLog.LoadFromFile(GetLogFileName);
AssertEquals('Wrong number of log entries', 6, SvnLog.LogEntryCount);
LogEntry := SvnLog.LogEntry[3];
AssertEquals('Wrong log revision', 10663, LogEntry.Revision);
AssertEquals('Wrong number of paths', 5, LogEntry.PathCount);
AssertLogPath(0, caDelete, '/trunk/components/tachart/TAEngine.pas', '', 0);
AssertLogPath(1, caAdd, '/trunk/components/tachart/taengine.pas',
'/trunk/components/tachart/TAEngine.pas', 10662);
finally
SvnLog.Free;
end;
end;
procedure TTestSvnClasses.TestLoadLogTwice;
var
SvnLog: TSvnLog;
begin
SvnLog := TSvnLog.Create;
try
SvnLog.LoadFromFile(GetLogFileName);
SvnLog.LoadFromFile(GetLogFileName);
AssertEquals('Wrong number of log entries', 6, SvnLog.LogEntryCount);
finally
SvnLog.Free;
end;
end;
initialization
RegisterTest(TTestSvnClasses);