Skip to content

Commit 02e3e4b

Browse files
committed
Enable fitpanel UnitTesting again
1 parent 41e95c0 commit 02e3e4b

2 files changed

Lines changed: 36 additions & 36 deletions

File tree

gui/fitpanel/test/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
# For the licensing terms see $ROOTSYS/LICENSE.
55
# For the list of contributors see $ROOTSYS/README/CREDITS.
66

7-
# @author Danilo Piparo CERN
7+
# @author Sergey Linev
88

99
ROOT_EXECUTABLE(fitPanelUnitTesting UnitTesting.cxx LIBRARIES FitPanel Gui Tree Hist MathCore)
1010

11-
# batch usage is instable - need more investigations
12-
#ROOT_ADD_TEST(test-fitpanel-UnitTesting-batch COMMAND fitPanelUnitTesting -b FAILREGEX "FAILED|Error in")
11+
ROOT_ADD_TEST(test-fitpanel-UnitTesting-batch COMMAND fitPanelUnitTesting -b FAILREGEX "FAILED|Error in")
1312

1413
find_program(XVFB_RUN_EXECUTABLE NAMES xvfb-run)
1514

gui/fitpanel/test/UnitTesting.cxx

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ class TTestVirtualX : public TVirtualX {
3939
}
4040
};
4141

42-
TString gTmpfilename;
43-
4442
// Function that compares to doubles up to an error limit
4543
int equals(Double_t n1, Double_t n2, double ERRORLIMIT = 1.E-4)
4644
{
@@ -124,7 +122,8 @@ class FitEditorUnitTesting
124122
};
125123

126124
// Constructor: Receives the instance of the TFitEditor
127-
FitEditorUnitTesting() {
125+
FitEditorUnitTesting()
126+
{
128127

129128
// Execute the initial script
130129
TString scriptLine = TString(".x ") + TROOT::GetTutorialDir() + "/math/fit/FittingDemo.C+";
@@ -151,7 +150,8 @@ class FitEditorUnitTesting
151150
// trying to retrieve the TFitEditor singleton. If the user wants
152151
// to play a bit with the fitpanel once the tests have finised,
153152
// then they should comment this method.
154-
~FitEditorUnitTesting() {
153+
~FitEditorUnitTesting()
154+
{
155155
f->DoClose();
156156
}
157157

@@ -191,7 +191,8 @@ class FitEditorUnitTesting
191191
// of the test should be enough to know what they are testing, as
192192
// these tests are meant to be as simple as possible.
193193

194-
int TestHistogramFit() {
194+
int TestHistogramFit()
195+
{
195196
f->fTypeFit->Select(kFP_UFUNC, kTRUE);
196197
f->fFuncList->Select(kFP_ALTFUNC, kTRUE);
197198
f->DoFit();
@@ -207,7 +208,8 @@ class FitEditorUnitTesting
207208
return CompareFuncPars(pars);
208209
}
209210

210-
int TestGSLFit() {
211+
int TestGSLFit()
212+
{
211213
f->fTypeFit->Select(kFP_PREVFIT, kTRUE);
212214
f->fLibGSL->Toggled(kTRUE);
213215
f->fMinMethodList->Select(kFP_BFGS2, kTRUE);
@@ -224,15 +226,17 @@ class FitEditorUnitTesting
224226
return CompareFuncPars(pars);
225227
}
226228

227-
int TestUpdate() {
229+
int TestUpdate()
230+
{
228231
TString scriptLine = TString(".x ") + TROOT::GetTutorialsDir() + "/math/fit/ConfidenceIntervals.C+";
229232
gROOT->ProcessLine(scriptLine.Data());
230233
f->DoUpdate();
231234

232235
return 0;
233236
}
234237

235-
int TestGraph() {
238+
int TestGraph()
239+
{
236240
SelectEntry(f->fDataSet, "TGraph::GraphNoError");
237241

238242
f->fLibMinuit2->Toggled(kTRUE);
@@ -249,7 +253,8 @@ class FitEditorUnitTesting
249253
return CompareFuncPars(pars);
250254
}
251255

252-
int TestGraphError() {
256+
int TestGraphError()
257+
{
253258
SelectEntry(f->fDataSet, "TGraphErrors::Graph");
254259

255260
f->fLibMinuit2->Toggled(kTRUE);
@@ -266,7 +271,8 @@ class FitEditorUnitTesting
266271
return CompareFuncPars(pars);
267272
}
268273

269-
int TestGraph2D() {
274+
int TestGraph2D()
275+
{
270276
SelectEntry(f->fDataSet, "TGraph2D::Graph2DNoError");
271277

272278
f->fLibMinuit2->Toggled(kTRUE);
@@ -290,7 +296,8 @@ class FitEditorUnitTesting
290296
return CompareFuncPars(pars);
291297
}
292298

293-
int TestGraph2DError() {
299+
int TestGraph2DError()
300+
{
294301
SelectEntry(f->fDataSet, "TGraph2DErrors::Graph2D");
295302

296303
f->fLibMinuit2->Toggled(kTRUE);
@@ -314,13 +321,15 @@ class FitEditorUnitTesting
314321
return CompareFuncPars(pars);
315322
}
316323

317-
int TestUpdateTree() {
324+
int TestUpdateTree()
325+
{
318326
createTree();
319327
f->DoUpdate();
320328
return 0;
321329
}
322330

323-
int TestTree1D() {
331+
int TestTree1D()
332+
{
324333
TObject* objSelected = gROOT->FindObject("tree");
325334
if ( !objSelected )
326335
throw InvalidPointer("In TestUpdateTree");
@@ -345,7 +354,8 @@ class FitEditorUnitTesting
345354
return CompareFuncPars(pars);
346355
}
347356

348-
int TestTree2D() {
357+
int TestTree2D()
358+
{
349359
TObject* objSelected = gROOT->FindObject("tree");
350360
if ( !objSelected )
351361
throw InvalidPointer("In TestUpdateTree");
@@ -374,7 +384,8 @@ class FitEditorUnitTesting
374384
return CompareFuncPars(pars);
375385
}
376386

377-
int TestTreeND() {
387+
int TestTreeND()
388+
{
378389
TObject* objSelected = gROOT->FindObject("tree");
379390
if ( !objSelected )
380391
throw InvalidPointer("In TestUpdateTree");
@@ -421,19 +432,19 @@ class FitEditorUnitTesting
421432
return CompareFuncPars(pars);
422433
}
423434

424-
// This is a generic method to make the output of all the tests
435+
// This is a generic method to make the output of all the tests
425436
// consistent. T is a function pointer to one of the tests
426437
// function. It has been implemented through templates to permit
427438
// more test types than the originally designed.
428439
// @ str : Name of the test
429440
// @ func : Member function pointer to the real implementation of
430441
// the test.
431442
template <typename T>
432-
int MakeTest(const char* str, T func)
443+
int MakeTest(const char *str, T func, Bool_t first = kFALSE)
433444
{
434445
RedirectHandle_t gRH;
435446

436-
gSystem->RedirectOutput(gTmpfilename.Data(), "w", &gRH);
447+
gSystem->RedirectOutput("outputUnitTesting.txt", first ? "w" : "a", &gRH);
437448

438449
fprintf(stdout, "\n***** %s *****\n", str);
439450

@@ -455,7 +466,7 @@ class FitEditorUnitTesting
455466

456467
fprintf(stdout, "\n**STARTING TFitEditor Unit Tests**\n\n");
457468

458-
result += MakeTest("TestHistogramFit...", &FitEditorUnitTesting::TestHistogramFit);
469+
result += MakeTest("TestHistogramFit...", &FitEditorUnitTesting::TestHistogramFit, kTRUE);
459470

460471
result += MakeTest("TestGSLFit.........", &FitEditorUnitTesting::TestGSLFit);
461472

@@ -471,9 +482,7 @@ class FitEditorUnitTesting
471482

472483
result += MakeTest("TestUpdateTree.....", &FitEditorUnitTesting::TestUpdateTree);
473484

474-
// TODO: reenable in batch once stack smashing issue is fixed
475-
if (!gROOT->IsBatch())
476-
result += MakeTest("TestTree1D.........", &FitEditorUnitTesting::TestTree1D);
485+
result += MakeTest("TestTree1D.........", &FitEditorUnitTesting::TestTree1D);
477486

478487
// TODO: reenable once fit results are fixed
479488
// result += MakeTest("TestTree2D.........", &FitEditorUnitTesting::TestTree2D);
@@ -482,7 +491,7 @@ class FitEditorUnitTesting
482491
// result += MakeTest("TestTreeND.........", &FitEditorUnitTesting::TestTreeND);
483492

484493
fprintf(stdout, "\nRemember to also check outputUnitTesting.txt for "
485-
"more detailed information\n\n");
494+
"more detailed information\n\n");
486495

487496
return result;
488497
}
@@ -499,17 +508,9 @@ int UnitTesting()
499508

500509
gROOT->SetWebDisplay("off");
501510

502-
gTmpfilename = "UnitTesting.log";
503-
auto f = gSystem->TempFileName(gTmpfilename);
504-
fclose(f);
505-
506511
FitEditorUnitTesting fUT;
507512

508-
auto res = fUT.UnitTesting();
509-
510-
gSystem->Unlink(gTmpfilename.Data());
511-
512-
return res;
513+
return fUT.UnitTesting();
513514
}
514515

515516
#ifndef __ROOTCLING__
@@ -531,4 +532,4 @@ int main(int argc, char** argv)
531532
return ret;
532533
}
533534

534-
#endif
535+
#endif

0 commit comments

Comments
 (0)