From d0869a6d8f0f21c758ade72900478f2f622f9a7b Mon Sep 17 00:00:00 2001 From: Stephan Hageboeck Date: Mon, 5 Jan 2026 15:07:40 +0100 Subject: [PATCH 1/2] [test] Small improvements to stressGraphics - Use non-zero exit code when a test fails. - When a test fails, print the file name of the generated graphics. - Label all stressGraphics runs as longtest. - Print differences in SVGs similar to how a unified diff would be printed. --- test/CMakeLists.txt | 3 ++- test/stressGraphics.cxx | 41 ++++++++++++++++++++++++++--------------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b972e7825fb0a..6365a93103b9d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -152,7 +152,8 @@ if(opengl AND TARGET TreeViewer) ROOT_ADD_TEST(test-stressgraphics-interpreted COMMAND ${root_exe} -b --web=off -q -l ${CMAKE_CURRENT_SOURCE_DIR}/stressGraphics.cxx FAILREGEX "FAILED|Error in" - DEPENDS test-stressgraphics) + DEPENDS test-stressgraphics + LABELS longtest) ROOT_ADD_TEST(test-stressgraphics-svg COMMAND stressGraphics -b --web=off -p=svg --svg=${CMAKE_CURRENT_SOURCE_DIR}/svg_ref/ FAILREGEX "FAILED|Error in" diff --git a/test/stressGraphics.cxx b/test/stressGraphics.cxx index e2a9aeeb054c9..3d0c171906a05 100644 --- a/test/stressGraphics.cxx +++ b/test/stressGraphics.cxx @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -277,6 +278,7 @@ Int_t StatusPrint(const TString &filename, const TString &title, Int_t res, Int_ std::cout << " Result = " << res << "\n"; std::cout << " Reference = " << ref << "\n"; std::cout << " Error = " << TMath::Abs(res - ref) << " (was " << err << ")\n"; + std::cout << " File = " << filename << "\n"; gTestsFailed++; return 1; } @@ -355,9 +357,19 @@ Int_t CompareSVGFiles(const TString &filename1, const TString &filename2, int te return 0; } + std::stringstream diffOld; + std::stringstream diffNew; + auto flushDiff = [&]() { + if (diffOld.tellp() != std::streampos(0)) { + std::cout << diffOld.str() << diffNew.str() << "\n"; + diffOld.str(""); + diffNew.str(""); + } + }; + std::string line1, line2; - int cnt = 0, diffcnt = 0, finediffcnt = 0; + int cnt = 0, diffcnt = 0, finediffcnt = 0, lastError = -1; while (std::getline(f1, line1) && std::getline(f2, line2)) { ++cnt; @@ -369,24 +381,23 @@ Int_t CompareSVGFiles(const TString &filename1, const TString &filename2, int te if (!gSvgCompact && (cnt == 8)) continue; - // ignore difference in file name, only for debugging - // if (gSvgCompact && (cnt == 4)) - // continue; + if (lastError + 1 != cnt) { + flushDiff(); + diffOld << "--- " << filename1 << "\n" << "+++ " << filename2 << "\n@@@ " << cnt << "\n"; + } + lastError = cnt; + diffOld << "- " << line1 << "\n"; + diffNew << "+ " << line2 << "\n"; - printf("Diff in line %d", cnt); - if (line1.length() != line2.length()) - printf(" len1: %d len2: %d\n", (int) line1.length(), (int) line2.length()); - else - printf("\n"); - printf("Ref: %s\n", line1.substr(0, 200).c_str()); - printf("New: %s\n", line2.substr(0, 200).c_str()); if ((testsvg == kFineSvgTest) && SpecialCompareOfSVGLines(line1, line2)) { if (finediffcnt++ > 5) return 0; } else if (++diffcnt > 5) - return 0; + break; } + flushDiff(); + if (diffcnt > 0) return 0; @@ -633,8 +644,8 @@ void print_reports() StatusPrint(e.pngfile, "PNG output", FileSize(e.pngfile), ref->pngref, ref->pngerr); if (e.execute_ccode) { - Int_t ret_code = StatusPrint(e.ps2file, "C file result", - e.IPS ? FileSize(e.ps2file) : AnalysePS(e.ps2file), ref->ps2ref, ref->ps2err); + Int_t ret_code = StatusPrint(e.ps2file, ".C -> .PS file result", + e.IPS ? FileSize(e.ps2file) : AnalysePS(e.ps2file), ref->ps2ref, ref->ps2err); #ifndef __CLING__ if (!gOptionK && !ret_code) @@ -4704,7 +4715,7 @@ int main(int argc, char *argv[]) stressGraphics(verbose, generate, keep); - return 0; + return gTestsFailed != 0; } #endif From 7532ccc9a94b68b2241663f11280053ec6375653 Mon Sep 17 00:00:00 2001 From: Stephan Hageboeck Date: Tue, 6 Jan 2026 15:29:41 +0100 Subject: [PATCH 2/2] [test] Always draw fresh histograms in stressGraphics. In the past, stressGraphics was retrieving a histogram from a file, modifying it and drawing it. In subsequent tests, the histogram is again read from the TFile, but this returns the in-memory object. This means that the previous tests influence the subsequent tests, e.g. whether or not statistics objects are displayed. In particular, subsequent tests will have the statistics box drawn twice, once from THistPainter::PaintStat(), and once from the fact that the box is added to the list of functions. This impacts output files such as PDF/PS/SVG. Here, the histogram is always cloned when it is retrieved from the file, so the tests are independent. The reference files for SVG are regenerated, because the statistics box is now only drawn once. Similarly, the output size of the .ps files has been corrected to reflect that the boxes are only drawn once. --- test/stressGraphics.cxx | 4 +- test/stressGraphics.ref | 4 +- test/stressGraphics_builtinzlib.ref | 4 +- test/svg_ref/clonepad.svg | 4 +- test/svg_ref/th2_candle.svg | 272 ---------------------------- test/svg_ref/th2_cut.svg | 2 +- test/svg_ref/th2_violin.svg | 136 -------------- 7 files changed, 9 insertions(+), 417 deletions(-) diff --git a/test/stressGraphics.cxx b/test/stressGraphics.cxx index 3d0c171906a05..1b2ec5f05cf14 100644 --- a/test/stressGraphics.cxx +++ b/test/stressGraphics.cxx @@ -2016,7 +2016,7 @@ void th2_cut() Float_t y[6] = { 2, 0, -2, -2, 0, 2 }; TCutG *cut = new TCutG("cut", 6, x, y); - TH1 *hpxpy = (TH1*)gHsimple->Get("hpxpy"); + TH1 *hpxpy = (TH1 *)gHsimple->Get("hpxpy")->Clone("th2_cut"); hpxpy->Draw("col [cut]"); cut->Draw("l"); @@ -3828,7 +3828,7 @@ void clonepad() { TCanvas *C = StartTest(700,500); - TH1 *hpxpy = (TH1*)gHsimple->Get("hpxpy"); + TH1 *hpxpy = (TH1 *)gHsimple->Get("hpxpy")->Clone("hpxpy_clonepad"); hpxpy->Draw(); TCanvas *C2 = (TCanvas*)C->DrawClone(); diff --git a/test/stressGraphics.ref b/test/stressGraphics.ref index 67ea7f2fe24f4..403bab7b5396b 100644 --- a/test/stressGraphics.ref +++ b/test/stressGraphics.ref @@ -30,8 +30,8 @@ th1_palette 17056 100 32429 100 29162 12000 35018 15000 17487 300 thstack1 30815 100 28522 100 46061 15000 23026 10000 31035 100 th2_cut 14774 600 16179 300 19511 5000 11533 4000 16039 600 - th2_candle 113353 1000 71394 500 136880 40000 51345 20000 115314 1000 - th2_violin 73316 500 84161 500 85037 20000 34733 15000 73223 500 + th2_candle 102431 1000 71394 500 136880 40000 51345 20000 115314 1000 + th2_violin 67738 500 84161 500 85037 20000 34733 15000 73223 500 th2_axlabels 4878 600 14375 100 17419 5000 11709 1800 5770 600 th2_stats 27107 300 19227 300 30587 14000 16531 7000 27039 500 tellipse 4131 40 15272 100 34038 2500 12258 1400 4162 40 diff --git a/test/stressGraphics_builtinzlib.ref b/test/stressGraphics_builtinzlib.ref index 6c9d79fb5572f..383d8c6b638c1 100644 --- a/test/stressGraphics_builtinzlib.ref +++ b/test/stressGraphics_builtinzlib.ref @@ -30,8 +30,8 @@ th1_palette 17056 100 32200 500 29162 12000 35018 15000 17487 300 thstack1 30815 100 28300 500 46061 15000 23026 10000 31035 100 th2_cut 14774 600 16179 300 19511 5000 11533 4000 16039 600 - th2_candle 113353 1000 71394 500 136880 40000 51345 20000 115314 1000 - th2_violin 73316 500 84161 500 85037 20000 34733 15000 73223 500 + th2_candle 102431 1000 71394 500 136880 40000 51345 20000 115314 1000 + th2_violin 67738 500 84161 500 85037 20000 34733 15000 73223 500 th2_axlabels 4878 600 14375 100 17419 5000 11709 1800 5770 600 th2_stats 27107 300 19227 300 30587 14000 16531 7000 27039 500 tellipse 4130 40 15193 50 34790 2500 12156 1400 4161 40 diff --git a/test/svg_ref/clonepad.svg b/test/svg_ref/clonepad.svg index 84d6dc13660ea..a50fe174323f6 100644 --- a/test/svg_ref/clonepad.svg +++ b/test/svg_ref/clonepad.svg @@ -1048,7 +1048,7 @@ clonepad.svg -hpxpy +hpxpy_clonepad Entries @@ -1082,7 +1082,7 @@ clonepad.svg -hpxpy +hpxpy_clonepad Entries diff --git a/test/svg_ref/th2_candle.svg b/test/svg_ref/th2_candle.svg index 8ddf820da576e..6ec1cef0f52ad 100644 --- a/test/svg_ref/th2_candle.svg +++ b/test/svg_ref/th2_candle.svg @@ -656,40 +656,6 @@ th2_candle.svg 1.006 - - - -candleh1 - - -Entries - - 25000 - -Mean x - -0.003961 - -− - - - -Mean y - -0.003377 - -− - - - -Std Dev x - - 0.9978 - -Std Dev y - - 1.006 - @@ -1414,40 +1380,6 @@ th2_candle.svg 1.006 - - - -candleh2 - - -Entries - - 25000 - -Mean x - -0.003961 - -− - - - -Mean y - -0.003377 - -− - - - -Std Dev x - - 0.9978 - -Std Dev y - - 1.006 - @@ -2250,40 +2182,6 @@ th2_candle.svg 1.006 - - - -candleh3 - - -Entries - - 25000 - -Mean x - -0.003961 - -− - - - -Mean y - -0.003377 - -− - - - -Std Dev x - - 0.9978 - -Std Dev y - - 1.006 - @@ -3086,40 +2984,6 @@ th2_candle.svg 1.006 - - - -candleh4 - - -Entries - - 25000 - -Mean x - -0.003961 - -− - - - -Mean y - -0.003377 - -− - - - -Std Dev x - - 0.9978 - -Std Dev y - - 1.006 - @@ -3787,40 +3651,6 @@ th2_candle.svg 1.006 - - - -candlev1 - - -Entries - - 25000 - -Mean x - -0.003961 - -− - - - -Mean y - -0.003377 - -− - - - -Std Dev x - - 0.9978 - -Std Dev y - - 1.006 - @@ -4542,40 +4372,6 @@ th2_candle.svg 1.006 - - - -candlev2 - - -Entries - - 25000 - -Mean x - -0.003961 - -− - - - -Mean y - -0.003377 - -− - - - -Std Dev x - - 0.9978 - -Std Dev y - - 1.006 - @@ -5377,40 +5173,6 @@ th2_candle.svg 1.006 - - - -candlev3 - - -Entries - - 25000 - -Mean x - -0.003961 - -− - - - -Mean y - -0.003377 - -− - - - -Std Dev x - - 0.9978 - -Std Dev y - - 1.006 - @@ -6212,40 +5974,6 @@ th2_candle.svg 1.006 - - - -candlev4 - - -Entries - - 25000 - -Mean x - -0.003961 - -− - - - -Mean y - -0.003377 - -− - - - -Std Dev x - - 0.9978 - -Std Dev y - - 1.006 - diff --git a/test/svg_ref/th2_cut.svg b/test/svg_ref/th2_cut.svg index 5d95d2adca484..32d80bdb1b8b8 100644 --- a/test/svg_ref/th2_cut.svg +++ b/test/svg_ref/th2_cut.svg @@ -454,7 +454,7 @@ th2_cut.svg -hpxpy +th2_cut Entries diff --git a/test/svg_ref/th2_violin.svg b/test/svg_ref/th2_violin.svg index 5db37a6b14e3e..dff472d8be20f 100644 --- a/test/svg_ref/th2_violin.svg +++ b/test/svg_ref/th2_violin.svg @@ -663,40 +663,6 @@ th2_violin.svg 1.006 - - - -violinh1 - - -Entries - - 25000 - -Mean x - -0.003961 - -− - - - -Mean y - -0.003377 - -− - - - -Std Dev x - - 0.9978 - -Std Dev y - - 1.006 - @@ -1506,40 +1472,6 @@ th2_violin.svg 1.006 - - - -violinh2 - - -Entries - - 25000 - -Mean x - -0.003961 - -− - - - -Mean y - -0.003377 - -− - - - -Std Dev x - - 0.9978 - -Std Dev y - - 1.006 - @@ -2203,40 +2135,6 @@ th2_violin.svg 1.006 - - - -violinv1 - - -Entries - - 25000 - -Mean x - -0.003961 - -− - - - -Mean y - -0.003377 - -− - - - -Std Dev x - - 0.9978 - -Std Dev y - - 1.006 - @@ -3034,40 +2932,6 @@ th2_violin.svg 1.006 - - - -violinv2 - - -Entries - - 25000 - -Mean x - -0.003961 - -− - - - -Mean y - -0.003377 - -− - - - -Std Dev x - - 0.9978 - -Std Dev y - - 1.006 -