From ba9652673361a1658263bce2ae6432f96094a049 Mon Sep 17 00:00:00 2001 From: juha Date: Tue, 21 Apr 2015 17:29:56 +0000 Subject: [PATCH] fpcunit: Reduce the amount of data written to the INI file. Issue #27887, patch from Graeme Geldenhuys. git-svn-id: trunk@48800 - --- components/fpcunit/guitestrunner.pas | 53 ++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/components/fpcunit/guitestrunner.pas b/components/fpcunit/guitestrunner.pas index 4c3f1a0d03..19e79155bc 100644 --- a/components/fpcunit/guitestrunner.pas +++ b/components/fpcunit/guitestrunner.pas @@ -189,6 +189,7 @@ implementation uses xmlwrite + ,strutils ; const @@ -243,8 +244,10 @@ end; function TGUITestRunner.MakeTestPath(Node: TTreeNode): string; begin - Result := ''; - while Node <> nil do + Result := Node.Text; + Node := Node.Parent; + // We can now skip the unnecessary "All Tests" text + while Node.Parent <> nil do begin Result := Node.Text + '.' + Result; Node := Node.Parent; @@ -255,20 +258,48 @@ procedure TGUITestRunner.SaveTree; var i: integer; begin - FConfStore.EraseSection('Tests'); - for i := 0 to TestTree.Items.Count - 1 do - FConfStore.WriteBool('Tests', MakeTestPath(TestTree.Items[i]), TestTree.Items[i].StateIndex = Ord(tsChecked)); + FConfStore.EraseSection('DisabledTests'); + for i := 0 to TestTree.Items.Count-1 do + begin + if TestTree.Items[i].StateIndex = ord(tsUnChecked) then + FConfStore.WriteBool('DisabledTests', MakeTestPath(TestTree.Items[i]), True); + end; end; procedure TGUITestRunner.RestoreTree; var - i: integer; + i, j: integer; + c: integer; + t: string; + n: TTreeNode; + sl: TStringList; begin - for i := 0 to TestTree.Items.Count - 1 do - if FConfStore.ReadBool('Tests', MakeTestPath(TestTree.Items[i]), true) then - TestTree.Items[i].StateIndex := Ord(tsChecked) - else - TestTree.Items[i].StateIndex := Ord(tsUnChecked); + if not FConfStore.SectionExists('DisabledTests') then + Exit; + sl := TStringList.Create; + FConfStore.ReadSection('DisabledTests', sl); + try + for i := 0 to sl.Count-1 do + begin + c := WordCount(sl[i], ['.']); + n := TestTree.Items.GetFirstNode; + for j := 1 to c do + begin + t := ExtractWord(j,sl[i],['.']); + if Assigned(n) then + begin + if n.Text = t then + continue + else + n := n.FindNode(t); + end; + end; + if Assigned(n) and (n.Text = t) then // we have a node and it matches the last text found + n.StateIndex := ord(tsUnChecked); + end; + finally + sl.Free; + end; end; procedure TGUITestRunner.GUITestRunnerCreate(Sender: TObject);