mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 03:58:09 +02:00
test: store test runs in database
git-svn-id: trunk@16072 -
This commit is contained in:
parent
985be0ddf3
commit
691dd09934
@ -21,9 +21,10 @@ Function GetTestID(Name : string) : Integer;
|
||||
Function GetOSID(Name : String) : Integer;
|
||||
Function GetCPUID(Name : String) : Integer;
|
||||
Function GetCategoryID(Name : String) : Integer;
|
||||
Function GetVersionID(Name : String) : Integer;
|
||||
Function GetRunID(OSID, CPUID, VERSIONID : Integer; Date : TDateTime) : Integer;
|
||||
Function AddRun(OSID, CPUID, VERSIONID, CATEGORYID : Integer; Date : TDateTime) : Integer;
|
||||
Function GetFPCVersionID(Name : String) : Integer;
|
||||
Function GetLAZVersionID(Name : String) : Integer;
|
||||
Function GetRunID(OSID, CPUID, FPCVERSIONID, LazVersionID : Integer; Date : TDateTime) : Integer;
|
||||
Function AddRun(OSID, CPUID, FPCVERSIONID, LazVersionID : Integer; Date : TDateTime) : Integer;
|
||||
Function AddTest(Name : String; AddSource : Boolean) : Integer;
|
||||
Function UpdateTest(ID : Integer; Info : TConfig; Source : String) : Boolean;
|
||||
Function AddTestResult(TestID,RunID,TestRes : Integer;
|
||||
@ -191,15 +192,6 @@ begin
|
||||
Result:=IDQuery(Format(SFromName,[Name]));
|
||||
end;
|
||||
|
||||
Function GetVersionID(Name : String) : Integer;
|
||||
|
||||
Const
|
||||
SFromName = 'SELECT TV_ID FROM TESTVERSION WHERE (TV_VERSION="%s")';
|
||||
|
||||
begin
|
||||
Result:=IDQuery(Format(SFromName,[Name]));
|
||||
end;
|
||||
|
||||
Function GetCPUID(Name : String) : Integer;
|
||||
|
||||
Const
|
||||
@ -218,25 +210,44 @@ begin
|
||||
Result:=IDQuery(Format(SFromName,[Name]));
|
||||
end;
|
||||
|
||||
Function GetRunID(OSID, CPUID, VERSIONID : Integer; Date : TDateTime) : Integer;
|
||||
function GetFPCVersionID(Name: String): Integer;
|
||||
|
||||
Const
|
||||
SFromName = 'SELECT TFV_ID FROM TESTFPCVERSION WHERE (TFV_VERSION="%s")';
|
||||
|
||||
begin
|
||||
Result:=IDQuery(Format(SFromName,[Name]));
|
||||
end;
|
||||
|
||||
|
||||
function GetLAZVersionID(Name: String): Integer;
|
||||
Const
|
||||
SFromName = 'SELECT TLV_ID FROM TESTLAZVERSION WHERE (TLV_VERSION="%s")';
|
||||
|
||||
begin
|
||||
Result:=IDQuery(Format(SFromName,[Name]));
|
||||
end;
|
||||
|
||||
|
||||
function GetRunID(OSID, CPUID, FPCVERSIONID, LazVersionID: Integer;
|
||||
Date: TDateTime): Integer;
|
||||
Const
|
||||
SFromIDS = 'SELECT TU_ID FROM TESTRUN WHERE '+
|
||||
' (TU_OS_FK=%d) '+
|
||||
' AND (TU_CPU_FK=%d) '+
|
||||
' AND (TU_VERSION_FK=%d) '+
|
||||
' AND (TU_FPC_VERSION_FK=%d) '+
|
||||
' AND (TU_LAZ_VERSION_FK=%d) '+
|
||||
' AND (TU_DATE="%s")';
|
||||
|
||||
begin
|
||||
Result:=IDQuery(Format(SFromIDS,[OSID,CPUID,VERSIONID,SQLDate(Date)]));
|
||||
Result:=IDQuery(Format(SFromIDS,[OSID,CPUID,FPCVERSIONID,LazVersionID,SQLDate(Date)]));
|
||||
end;
|
||||
|
||||
Function AddRun(OSID, CPUID, VERSIONID, CATEGORYID : Integer; Date : TDateTime) : Integer;
|
||||
Function AddRun(OSID, CPUID, FPCVERSIONID, LazVersionID : Integer; Date : TDateTime) : Integer;
|
||||
|
||||
Const
|
||||
SInsertRun = 'INSERT INTO TESTRUN '+
|
||||
'(TU_OS_FK,TU_CPU_FK,TU_VERSION_FK,TU_CATEGORY_FK,TU_DATE)'+
|
||||
'(TU_OS_FK,TU_CPU_FK,TU_FPC_VERSION_FK,TU_LAZ_VERSION_FK,TU_DATE)'+
|
||||
' VALUES '+
|
||||
'(%d,%d,%d,%d,"%s")';
|
||||
|
||||
@ -244,7 +255,7 @@ Var
|
||||
Res : TQueryResult;
|
||||
|
||||
begin
|
||||
If RunQuery(Format(SInsertRun,[OSID,CPUID,VERSIONID,CATEGORYID,SQLDate(Date)]),Res) then
|
||||
If RunQuery(Format(SInsertRun,[OSID,CPUID,FPCVERSIONID,LazVersionID,SQLDate(Date)]),Res) then
|
||||
Result:=mysql_insert_id(@connection)
|
||||
else
|
||||
Result:=-1;
|
||||
|
@ -4,14 +4,13 @@
|
||||
<PathDelim Value="\"/>
|
||||
<Version Value="6"/>
|
||||
<General>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<IconPath Value="./"/>
|
||||
<TargetFileExt Value=".exe"/>
|
||||
<ActiveEditorIndexAtStart Value="2"/>
|
||||
</General>
|
||||
<VersionInfo>
|
||||
<ProjectVersion Value=""/>
|
||||
<Language Value=""/>
|
||||
<CharSet Value=""/>
|
||||
</VersionInfo>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
@ -25,46 +24,13 @@
|
||||
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<Units Count="3">
|
||||
<Units Count="1">
|
||||
<Unit0>
|
||||
<Filename Value="importtestresults.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="importtestresuls"/>
|
||||
<CursorPos X="25" Y="20"/>
|
||||
<TopLine Value="7"/>
|
||||
<EditorIndex Value="0"/>
|
||||
<UsageCount Value="20"/>
|
||||
<Loaded Value="True"/>
|
||||
<UnitName Value="importtestresults"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="teststr.pp"/>
|
||||
<UnitName Value="teststr"/>
|
||||
<CursorPos X="45" Y="37"/>
|
||||
<TopLine Value="8"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="testu.pp"/>
|
||||
<UnitName Value="testu"/>
|
||||
<CursorPos X="1" Y="37"/>
|
||||
<TopLine Value="37"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit2>
|
||||
</Units>
|
||||
<JumpHistory Count="2" HistoryIndex="1">
|
||||
<Position1>
|
||||
<Filename Value="teststr.pp"/>
|
||||
<Caret Line="1" Column="1" TopLine="1"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="testu.pp"/>
|
||||
<Caret Line="1" Column="1" TopLine="1"/>
|
||||
</Position2>
|
||||
</JumpHistory>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="5"/>
|
||||
@ -73,65 +39,9 @@
|
||||
<Generate Value="Faster"/>
|
||||
</CodeGeneration>
|
||||
<Other>
|
||||
<CustomOptions Value="
|
||||
"/>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<BreakPoints Count="11">
|
||||
<Item1>
|
||||
<Source Value="..\..\ide\compileroptions.pp"/>
|
||||
<InitialEnabled Value="False"/>
|
||||
<Line Value="1695"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Source Value="..\..\ide\ideprocs.pp"/>
|
||||
<Line Value="1396"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Source Value="..\..\ide\compileroptionsdlg.pp"/>
|
||||
<Line Value="1656"/>
|
||||
</Item3>
|
||||
<Item4>
|
||||
<Source Value="..\..\lcl\include\fileutil.inc"/>
|
||||
<InitialEnabled Value="False"/>
|
||||
<Line Value="210"/>
|
||||
</Item4>
|
||||
<Item5>
|
||||
<Source Value="..\..\ide\condef.pas"/>
|
||||
<Line Value="148"/>
|
||||
</Item5>
|
||||
<Item6>
|
||||
<Source Value="..\..\lcl\include\treeview.inc"/>
|
||||
<Line Value="3949"/>
|
||||
</Item6>
|
||||
<Item7>
|
||||
<Source Value="..\..\components\synedit\synedit.pp"/>
|
||||
<Line Value="6322"/>
|
||||
</Item7>
|
||||
<Item8>
|
||||
<Source Value="..\..\components\synedit\synedit.pp"/>
|
||||
<Line Value="2189"/>
|
||||
</Item8>
|
||||
<Item9>
|
||||
<Source Value="..\..\ide\editoroptions.pp"/>
|
||||
<Line Value="3621"/>
|
||||
</Item9>
|
||||
<Item10>
|
||||
<Source Value="..\..\ide\main.pp"/>
|
||||
<Line Value="3257"/>
|
||||
</Item10>
|
||||
<Item11>
|
||||
<Source Value="..\..\ide\main.pp"/>
|
||||
<Line Value="3256"/>
|
||||
</Item11>
|
||||
</BreakPoints>
|
||||
<Watches Count="2">
|
||||
<Item1>
|
||||
<Expression Value="MainUnitInfo.FSource.FSource"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Expression Value="FOnCompare"/>
|
||||
</Item2>
|
||||
</Watches>
|
||||
</Debugging>
|
||||
</CONFIG>
|
||||
|
@ -20,7 +20,8 @@
|
||||
program importtestresults;
|
||||
|
||||
uses
|
||||
sysutils,teststr,testu,tresults,dbtests;
|
||||
sysutils,teststr,testu,tresults,dbtests,
|
||||
dom, XMLRead;
|
||||
|
||||
|
||||
Var
|
||||
@ -68,8 +69,8 @@ TConfigOpt = (
|
||||
coLogFile,
|
||||
coOS,
|
||||
coCPU,
|
||||
coCategory,
|
||||
coVersion,
|
||||
coWidgetset,
|
||||
coFPCVersion,
|
||||
coDate,
|
||||
coSubmitter,
|
||||
coMachine,
|
||||
@ -90,8 +91,7 @@ ConfigStrings : Array [TConfigOpt] of string = (
|
||||
'os',
|
||||
'cpu',
|
||||
'widgetset',
|
||||
'category',
|
||||
'version',
|
||||
'fpcversion',
|
||||
'date',
|
||||
'submitter',
|
||||
'machine',
|
||||
@ -102,13 +102,13 @@ ConfigStrings : Array [TConfigOpt] of string = (
|
||||
);
|
||||
|
||||
ConfigOpts : Array[TConfigOpt] of char
|
||||
= ('d','h','u','p','l','o','c','w','a','v','t','s','m','C','S','r','V');
|
||||
= ('d','h','u','p','l','o','c','w', 'v','t','s','m','C','S','r','V');
|
||||
|
||||
Var
|
||||
TestOS,
|
||||
TestCPU,
|
||||
TestVersion,
|
||||
TestCategory,
|
||||
TestFPCVersion,
|
||||
TestLazVersion,
|
||||
DatabaseName,
|
||||
HostName,
|
||||
UserName,
|
||||
@ -131,22 +131,21 @@ begin
|
||||
coLogFile : ResultsFileName:=Value;
|
||||
coOS : TestOS:=Value;
|
||||
coCPU : TestCPU:=Value;
|
||||
coCategory : TestCategory:=Value;
|
||||
coVersion : TestVersion:=Value;
|
||||
coFPCVersion : TestFPCVersion:=Value;
|
||||
coDate :
|
||||
begin
|
||||
{ Formated like YYYYMMDDhhmm }
|
||||
if Length(value)=12 then
|
||||
begin
|
||||
year:=StrToInt(Copy(value,1,4));
|
||||
month:=StrToInt(Copy(value,5,2));
|
||||
day:=StrToInt(Copy(Value,7,2));
|
||||
hour:=StrToInt(Copy(Value,9,2));
|
||||
min:=StrToInt(Copy(Value,11,2));
|
||||
TestDate:=EncodeDate(year,month,day)+EncodeTime(hour,min,0,0);
|
||||
end
|
||||
else
|
||||
Verbose(V_Error,'Error in date format, use YYYYMMDDhhmm');
|
||||
if Length(value)=12 then
|
||||
begin
|
||||
year:=StrToInt(Copy(value,1,4));
|
||||
month:=StrToInt(Copy(value,5,2));
|
||||
day:=StrToInt(Copy(Value,7,2));
|
||||
hour:=StrToInt(Copy(Value,9,2));
|
||||
min:=StrToInt(Copy(Value,11,2));
|
||||
TestDate:=EncodeDate(year,month,day)+EncodeTime(hour,min,0,0);
|
||||
end
|
||||
else
|
||||
Verbose(V_Error,'Error in date format, use YYYYMMDDhhmm');
|
||||
end;
|
||||
coSubmitter : Submitter:=Value;
|
||||
coMachine : Machine:=Value;
|
||||
@ -273,36 +272,58 @@ begin
|
||||
end;
|
||||
|
||||
Var
|
||||
Doc: TXMLDocument;
|
||||
TestCPUID : Integer;
|
||||
TestOSID : Integer;
|
||||
TestVersionID : Integer;
|
||||
TestCategoryID : Integer;
|
||||
TestFPCVersionID : Integer;
|
||||
TestLazVersionID : Integer;
|
||||
TestRunID : Integer;
|
||||
|
||||
Procedure GetIDs;
|
||||
var
|
||||
EnvNode: TDOMElement;
|
||||
|
||||
function GetEnvValue(const Name: string): string;
|
||||
var
|
||||
Node: TDomNode;
|
||||
begin
|
||||
Node := EnvNode.FindNode(Name);
|
||||
if not assigned(Node) then
|
||||
Verbose(V_Error,'No environment element for '+Name);
|
||||
Result := Node.TextContent;
|
||||
Verbose(V_Debug,format('Environment: retrieved %s=%s', [Name, Result]));
|
||||
end;
|
||||
|
||||
begin
|
||||
EnvNode := Doc.FirstChild.FindNode('Environment') as TDomElement;
|
||||
if not Assigned(EnvNode) then
|
||||
Verbose(V_Error,'No environment element');
|
||||
TestCPU := GetEnvValue('CPU');
|
||||
TestCPUID := GetCPUId(TestCPU);
|
||||
If TestCPUID=-1 then
|
||||
Verbose(V_Error,'NO ID for CPU "'+TestCPU+'" found.');
|
||||
|
||||
TestOS := GetEnvValue('OS');
|
||||
TestOSID := GetOSID(TestOS);
|
||||
If TestOSID=-1 then
|
||||
Verbose(V_Error,'NO ID for OS "'+TestOS+'" found.');
|
||||
TestCategoryID := GetCategoryID(TestCategory);
|
||||
If TestCategoryID=-1 then
|
||||
begin
|
||||
// Verbose(V_Error,'NO ID for Category "'+TestCategory+'" found.');
|
||||
TestCategoryID:=1;
|
||||
end;
|
||||
TestVersionID := GetVersionID(TestVersion);
|
||||
If TestVersionID=-1 then
|
||||
Verbose(V_Error,'NO ID for version "'+TestVersion+'" found.');
|
||||
|
||||
TestFPCVersion := GetEnvValue('FPCVersion');
|
||||
TestFPCVersionID := GetFPCVersionID(TestFPCVersion);
|
||||
If TestFPCVersionID=-1 then
|
||||
Verbose(V_Error,'NO ID for fpc version "'+TestFPCVersion+'" found.');
|
||||
|
||||
TestLazVersion := GetEnvValue('LazVersion');
|
||||
TestLazVersionID := GetLazVersionID(TestLazVersion);
|
||||
If TestLazVersionID=-1 then
|
||||
Verbose(V_Error,'NO ID for fpc version "'+TestLazVersion+'" found.');
|
||||
|
||||
If (Round(TestDate)=0) then
|
||||
Testdate:=Now;
|
||||
TestRunID:=GetRunID(TestOSID,TestCPUID,TestVersionID,TestDate);
|
||||
TestRunID:=GetRunID(TestOSID,TestCPUID,TestFPCVersionID,TestLazVersionID, TestDate);
|
||||
If (TestRunID=-1) then
|
||||
begin
|
||||
TestRunID:=AddRun(TestOSID,TestCPUID,TestVersionID,TestCategoryID,TestDate);
|
||||
TestRunID:=AddRun(TestOSID,TestCPUID,TestFPCVersionID,TestLazVersionID,TestDate);
|
||||
If TestRUnID=-1 then
|
||||
Verbose(V_Error,'Could not insert new testrun record!');
|
||||
end
|
||||
@ -376,8 +397,17 @@ begin
|
||||
close(logfile);
|
||||
end;
|
||||
|
||||
procedure ProcessResultsFile;
|
||||
procedure ProcessResultsFile(FN: String);
|
||||
|
||||
begin
|
||||
Verbose(V_Debug,'Start ProcessResultsFile');
|
||||
if not FileExists(FN) then
|
||||
Verbose(V_Error,'Results file "'+ResultsFileName+'" does not exist.');
|
||||
|
||||
ReadXMLFile(Doc, FN);
|
||||
GetIDs;
|
||||
Doc.Free;
|
||||
Verbose(V_Debug,'End ProcessResultsFile');
|
||||
end;
|
||||
|
||||
procedure UpdateTestRun;
|
||||
@ -389,21 +419,22 @@ procedure UpdateTestRun;
|
||||
|
||||
begin
|
||||
qry:='UPDATE TESTRUN SET ';
|
||||
for i:=low(TTestStatus) to high(TTestStatus) do
|
||||
qry:=qry+format('%s=%d, ',[SQLField[i],StatusCount[i]]);
|
||||
qry:=qry+format('TU_SUBMITTER="%s", TU_MACHINE="%s", TU_COMMENT="%s", TU_DATE="%s"',[Submitter,Machine,Comment,SqlDate(TestDate)]);
|
||||
//for i:=low(TTestStatus) to high(TTestStatus) do
|
||||
//qry:=qry+format('%s=%d, ',[SQLField[i],StatusCount[i]]);
|
||||
qry:=qry+format('TU_SUBMITTER="%s", TU_MACHINE="%s", TU_COMMENT="%s", TU_DATE="%s"',
|
||||
[Submitter,Machine,Comment,SqlDate(TestDate)]);
|
||||
qry:=qry+' WHERE TU_ID='+format('%d',[TestRunID]);
|
||||
RunQuery(Qry,res)
|
||||
end;
|
||||
|
||||
|
||||
begin
|
||||
DoVerbose := true;
|
||||
ProcessConfigFile('dbdigest.cfg');
|
||||
ProcessCommandLine;
|
||||
If ResultsFileName<>'' then
|
||||
begin
|
||||
ConnectToDatabase(DatabaseName,HostName,UserName,Password);
|
||||
GetIDs;
|
||||
ProcessResultsFile(ResultsFileName);
|
||||
UpdateTestRun;
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user