mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-23 11:49:36 +01:00
* Add is_new boolean arg to AddTestResult, to e able to know
if the call really added a new result. git-svn-id: trunk@14807 -
This commit is contained in:
parent
6aa6f7ebf4
commit
2646db8036
@ -404,10 +404,12 @@ var
|
|||||||
TS,PrevTS : TTestStatus;
|
TS,PrevTS : TTestStatus;
|
||||||
ID,PrevID : integer;
|
ID,PrevID : integer;
|
||||||
Testlog : string;
|
Testlog : string;
|
||||||
|
is_new : boolean;
|
||||||
begin
|
begin
|
||||||
Assign(logfile,FN);
|
Assign(logfile,FN);
|
||||||
PrevId:=-1;
|
PrevId:=-1;
|
||||||
PrevLine:='';
|
PrevLine:='';
|
||||||
|
is_new:=false;
|
||||||
PrevTS:=low(TTestStatus);
|
PrevTS:=low(TTestStatus);
|
||||||
{$i-}
|
{$i-}
|
||||||
reset(logfile);
|
reset(logfile);
|
||||||
@ -429,7 +431,7 @@ begin
|
|||||||
is not followed by any other line about the same test }
|
is not followed by any other line about the same test }
|
||||||
TestLog:='';
|
TestLog:='';
|
||||||
AddTestResult(PrevID,TestRunId,ord(PrevTS),
|
AddTestResult(PrevID,TestRunId,ord(PrevTS),
|
||||||
TestOK[PrevTS],TestSkipped[PrevTS],TestLog);
|
TestOK[PrevTS],TestSkipped[PrevTS],TestLog,is_new);
|
||||||
Verbose(V_Warning,'Orphaned test: "'+prevline+'"');
|
Verbose(V_Warning,'Orphaned test: "'+prevline+'"');
|
||||||
end;
|
end;
|
||||||
PrevID:=-1;
|
PrevID:=-1;
|
||||||
@ -446,9 +448,12 @@ begin
|
|||||||
{ AddTestResult can fail for test that contain %recompile
|
{ AddTestResult can fail for test that contain %recompile
|
||||||
as the same }
|
as the same }
|
||||||
if AddTestResult(ID,TestRunID,Ord(TS),TestOK[TS],
|
if AddTestResult(ID,TestRunID,Ord(TS),TestOK[TS],
|
||||||
TestSkipped[TS],TestLog) <> -1 then
|
TestSkipped[TS],TestLog,is_new) <> -1 then
|
||||||
begin
|
begin
|
||||||
Inc(StatusCount[TS]);
|
if is_new then
|
||||||
|
Inc(StatusCount[TS])
|
||||||
|
else
|
||||||
|
Verbose(V_Debug,'Test: "'+line+'" was updated');
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
|
|||||||
@ -28,7 +28,7 @@ Function AddTest(Name : String; AddSource : Boolean) : Integer;
|
|||||||
Function UpdateTest(ID : Integer; Info : TConfig; Source : String) : Boolean;
|
Function UpdateTest(ID : Integer; Info : TConfig; Source : String) : Boolean;
|
||||||
Function AddTestResult(TestID,RunID,TestRes : Integer;
|
Function AddTestResult(TestID,RunID,TestRes : Integer;
|
||||||
OK, Skipped : Boolean;
|
OK, Skipped : Boolean;
|
||||||
Log : String) : Integer;
|
Log : String;var is_new : boolean) : Integer;
|
||||||
Function RequireTestID(Name : String): Integer;
|
Function RequireTestID(Name : String): Integer;
|
||||||
Function CleanTestRun(ID : Integer) : Boolean;
|
Function CleanTestRun(ID : Integer) : Boolean;
|
||||||
|
|
||||||
@ -121,6 +121,19 @@ begin
|
|||||||
Res:=Mysql_store_result(@connection);
|
Res:=Mysql_store_result(@connection);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ No warning if it fails }
|
||||||
|
Function RunSilentQuery (Qry : String; Var res : TQueryResult) : Boolean ;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Verbose(V_DEBUG,'Running silent query:'+Qry);
|
||||||
|
Result:=mysql_query(@Connection,PChar(qry))=0;
|
||||||
|
If Not Result then
|
||||||
|
Verbose(V_DEBUG,'Silent query : '+Qry+'Failed : '+Strpas(mysql_error(@connection)))
|
||||||
|
else
|
||||||
|
Res:=Mysql_store_result(@connection);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function GetResultField (Res : TQueryResult; Id : Integer) : String;
|
Function GetResultField (Res : TQueryResult; Id : Integer) : String;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
@ -410,34 +423,45 @@ end;
|
|||||||
|
|
||||||
Function AddTestResult(TestID,RunID,TestRes : Integer;
|
Function AddTestResult(TestID,RunID,TestRes : Integer;
|
||||||
OK, Skipped : Boolean;
|
OK, Skipped : Boolean;
|
||||||
Log : String) : Integer;
|
Log : String;var is_new : boolean) : Integer;
|
||||||
|
|
||||||
Const
|
Const
|
||||||
SInsertRes='Insert into TESTRESULTS '+
|
SInsertRes='Insert into TESTRESULTS '+
|
||||||
'(TR_TEST_FK,TR_TESTRUN_FK,TR_OK,TR_SKIP,TR_RESULT) '+
|
'(TR_TEST_FK,TR_TESTRUN_FK,TR_OK,TR_SKIP,TR_RESULT) '+
|
||||||
' VALUES '+
|
' VALUES '+
|
||||||
'(%d,%d,"%s","%s",%d) ';
|
'(%d,%d,"%s","%s",%d) ';
|
||||||
SInsertLog='Update TESTRESULTS SET TR_LOG="%s" WHERE (TR_ID=%d)';
|
SSelectId='SELECT TR_ID FROM TESTRESULTS WHERE (TR_TEST_FK=%d) '+
|
||||||
|
' AND (TR_TESTRUN_FK=%d)';
|
||||||
|
SInsertLog='Update TESTRESULTS SET TR_LOG="%s"'+
|
||||||
|
',TR_OK="%s",TR_SKIP="%s",TR_RESULT=%d WHERE (TR_ID=%d)';
|
||||||
Var
|
Var
|
||||||
Qry : String;
|
Qry : String;
|
||||||
Res : TQueryResult;
|
Res : TQueryResult;
|
||||||
|
updateValues : boolean;
|
||||||
begin
|
begin
|
||||||
|
updateValues:=false;
|
||||||
Result:=-1;
|
Result:=-1;
|
||||||
Qry:=Format(SInsertRes,
|
Qry:=Format(SInsertRes,
|
||||||
[TestID,RunID,B[OK],B[Skipped],TestRes,EscapeSQL(Log)]);
|
[TestID,RunID,B[OK],B[Skipped],TestRes,EscapeSQL(Log)]);
|
||||||
If RunQuery(Qry,Res) then
|
If RunSilentQuery(Qry,Res) then
|
||||||
Result:=mysql_insert_id(@connection)
|
Result:=mysql_insert_id(@connection)
|
||||||
else
|
else
|
||||||
Verbose(V_Warning,'AddTestResult failed');
|
|
||||||
if (Result<>-1) and (Log<>'') then
|
|
||||||
begin
|
begin
|
||||||
Qry:=format(SInsertLog,[EscapeSQL(Log),Result]);
|
Qry:=format(SSelectId,[TestId,RunId]);
|
||||||
|
Result:=IDQuery(Qry);
|
||||||
|
if Result<>-1 then
|
||||||
|
updateValues:=true;
|
||||||
|
end;
|
||||||
|
if (Result<>-1) and ((Log<>'') or updateValues) then
|
||||||
|
begin
|
||||||
|
Qry:=format(SInsertLog,[EscapeSQL(Log),B[OK],B[Skipped],TestRes,Result]);
|
||||||
if not RunQuery(Qry,Res) then
|
if not RunQuery(Qry,Res) then
|
||||||
begin
|
begin
|
||||||
Verbose(V_Warning,'Insert Log failed');
|
Verbose(V_Warning,'Insert Log failed');
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
{ If test already existed, return false for is_new to avoid double counting }
|
||||||
|
is_new:=not updateValues;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function RequireTestID(Name : String): Integer;
|
Function RequireTestID(Name : String): Integer;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user