From 08abb7df86b4c99bbd75e6bb1b31bb0c5afe0973 Mon Sep 17 00:00:00 2001 From: Stephan Hageboeck Date: Mon, 3 Aug 2026 11:28:47 +0200 Subject: [PATCH 1/2] [gui] Make failures in fit panel unit tests easier to diagnose. Due to output redirection, failures in the fit panel unit tests were silent. Here, the output is shown in case of failure. Furthermore, the program silently crashed if a combo box couldn't select the desired entry. Now, the result of the combo box selection is checked, and an exception is thrown if the requested item is not present. --- gui/fitpanel/test/UnitTesting.cxx | 32 +++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/gui/fitpanel/test/UnitTesting.cxx b/gui/fitpanel/test/UnitTesting.cxx index 7a02a0a3bbee5..0574cc8f993ae 100644 --- a/gui/fitpanel/test/UnitTesting.cxx +++ b/gui/fitpanel/test/UnitTesting.cxx @@ -20,6 +20,7 @@ #include "Math/PdfFuncMathCore.h" #include +#include #include #include #include @@ -49,6 +50,10 @@ int equals(Double_t n1, Double_t n2, double ERRORLIMIT = 1.E-4) int SelectEntry(TGComboBox* cb, const char* name) { TGTextLBEntry* findEntry = static_cast( cb->FindEntry(name) ); + if (!findEntry) { + fprintf(stderr, "*****\nError: Did not find entry %s in combo box %s\n", name, cb->GetName()); + throw std::runtime_error("Did not find the requested entry in a combo box."); + } cb->Select(findEntry->EntryId()); return findEntry->EntryId(); @@ -450,13 +455,20 @@ class FitEditorUnitTesting { RedirectHandle_t gRH; - gSystem->RedirectOutput("outputUnitTesting.txt", first ? "w" : "a", &gRH); + constexpr auto logfile = "outputUnitTesting.txt"; - fprintf(stdout, "\n***** %s *****\n", str); + gSystem->RedirectOutput(logfile, first ? "w" : "a", &gRH); - int status = (this->*func)(); + fprintf(stdout, "\n***** %s *****\n", str); - gSystem->RedirectOutput(0, 0, &gRH); + int status = 1; + try { + status = (this->*func)(); + gSystem->RedirectOutput(0, 0, &gRH); + } catch (std::exception &ex) { + gSystem->RedirectOutput(0, 0, &gRH); + fprintf(stderr, "Caught exception with message '%s'\n Check %s below.\n", ex.what(), logfile); + } fprintf(stdout, "%s..........%s\n", str, status == 0 ? "OK" : "FAILED"); @@ -496,8 +508,16 @@ class FitEditorUnitTesting // TODO: reenable once fit results are fixed // result += MakeTest("TestTreeND.........", &FitEditorUnitTesting::TestTreeND); - fprintf(stdout, "\nRemember to also check outputUnitTesting.txt for " - "more detailed information\n\n"); + if (result == 0) { + fprintf(stdout, "\nRemember to also check outputUnitTesting.txt for " + "more detailed information\n\n"); + } else { + std::cout << "\n\nContents of outputUnitTesting.txt:\n\n"; + std::ifstream file("outputUnitTesting.txt"); + std::string line; + while (std::getline(file, line)) + std::cout << "\t" << line << "\n"; + } return result; } From ffc6f53c558c9798a372efb86d497c2a55d5e2ff Mon Sep 17 00:00:00 2001 From: Stephan Hageboeck Date: Mon, 3 Aug 2026 11:31:28 +0200 Subject: [PATCH 2/2] [tutorials] Add a TGraph to the objects displayed in a fit panel. When object auto-registration is off, a TGraph2D was not displayed in the fit panel, because it is never drawn. This lead to a failure in gui tests. --- tutorials/math/fit/ConfidenceIntervals.C | 1 + 1 file changed, 1 insertion(+) diff --git a/tutorials/math/fit/ConfidenceIntervals.C b/tutorials/math/fit/ConfidenceIntervals.C index c3fbb7a12616b..35e9c64c08353 100644 --- a/tutorials/math/fit/ConfidenceIntervals.C +++ b/tutorials/math/fit/ConfidenceIntervals.C @@ -85,6 +85,7 @@ void ConfidenceIntervals() double z, rnd, e=0.3; TGraph2D *gr2 = new TGraph2D(ngr2); gr2->SetName("Graph2DNoError"); + gr2->SetDirectory(gDirectory); // Because it is never drawn, register the graph, so it shows up in the Fit Panel TF2 *f2 = new TF2("f2", "1000*(([0]*sin(x)/x)*([1]*sin(y)/y))+250",-6,6,-6,6); f2->SetParameters(1,1);