Skip to content
Snippets Groups Projects
Commit a7ea77d2 authored by Pere Mato Vila's avatar Pere Mato Vila
Browse files

Added a test (CTest) for each tutorial (321 new tests). Made FITSIO and...

Added a test (CTest) for each tutorial (321 new tests). Made FITSIO and cernstaff.C tutorials independent of the current working directory.
parent 1f2c1dba
No related branches found
No related tags found
No related merge requests found
......@@ -76,6 +76,7 @@ if(roofit)
endif()
ROOT_ADD_TEST_SUBDIRECTORY(test)
ROOT_ADD_TEST_SUBDIRECTORY(tutorials)
#---Global PCH-----------------------------------------------------------------------------------
get_property(__allTargets GLOBAL PROPERTY ROOT_DICTIONARY_TARGETS)
......
......@@ -28,20 +28,12 @@ else()
include_directories(${ROOT_INCLUDE_DIRS}/../tutorials)
endif()
macro(ROOT_ADD_MACRO macrofile)
get_filename_component(name ${macrofile} NAME_WE)
ROOT_ADD_TEST(macro-${name} COMMAND ${ROOT_root_CMD} -b -q ${macrofile} PASSRC 1 FAILREGEX Error)
endmacro()
#---environment-------------------------------------------------------------------------------
ROOT_ADD_TEST(show-environment COMMAND ${CMAKE_COMMAND} -E environment)
#---hworld------------------------------------------------------------------------------------
ROOT_EXECUTABLE(hworld hworld.cxx LIBRARIES Gpad)
#---Defines some of the tutorials as tests----------------------------------------------------
ROOT_ADD_MACRO(${ROOT_SOURCE_DIR}/tutorials/hsimple.C)
#---event-------------------------------------------------------------------------------------
ROOT_GENERATE_DICTIONARY(EventDict ${CMAKE_CURRENT_SOURCE_DIR}/Event.h MODULE Event LINKDEF EventLinkDef.h)
ROOT_LINKER_LIBRARY(Event Event.cxx EventDict.cxx LIBRARIES Hist MathCore)
......
# CMakeLists.txt for the ROOT tutorials programs.
# Author: Pere Mato, 25/10/2010
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(tutorials)
find_package(ROOT REQUIRED)
include(${ROOT_USE_FILE})
#---Definition of the helper function--------------------------------
function(ROOT_ADD_TUTORIAL macrofile rc)
string(REPLACE ".C" "" name ${macrofile})
string(REPLACE "/" "-" name ${name})
ROOT_ADD_TEST(tutorial-${name} COMMAND ${ROOT_root_CMD} -b -l -q ${CMAKE_CURRENT_SOURCE_DIR}/${macrofile}
PASSRC ${rc} FAILREGEX "Error in" "error:" LABELS tutorial)
endfunction()
#---Tutorials disabled depending on the build components-------------
if(NOT ROOT_minuit2_FOUND)
set(minuit2_veto fit/fit2dHist.C fit/fit2dHist.C
fit/fitCircle.C fit/minuit2FitBench2D.C
fit/minuit2FitBench2D.C fit/minuit2FitBench.C
fit/minuit2FitBench.C fit/minuit2GausFit.C
fit/minuit2GausFit.C fit/NumericalMinimization.C
fit/combinedFit.C)
endif()
if(NOT ROOT_roofit_FOUND)
set(roofit_veto fit/RoofitDemo.C
roofit/*.C roostats/*.C histfactory/*.C)
endif()
if(NOT ROOT_unuran_FOUND)
set(unuran_veto math/testrandom.C unuran/unuranDemo.C unuran/unuranFoamTest.C)
endif()
if(NOT ROOT_xml_FOUND)
set(xml_veto xml/*.C)
endif()
if(NOT ROOT_fitsio_FOUND)
set(fitsio_veto fitsio/*.C)
endif()
if(NOT ROOT_mathmore_FOUND)
set(mathmore_veto math/quasirandom.C math/exampleMultiRoot.C)
endif()
if(NOT ROOT_fftw3_FOUND)
set(fftw3_veto roofit/rf208_convolution.C
roofit/rf210_angularconv.C
roofit/rf211_paramconv.C)
endif()
#---These ones requires a display to run-----------------------------
set(gui_veto fit/fitpanel_playback.C
cocoa/*.C
geom/*.C
gl/*.C
gui/*.C
hist/exec1.C hist/exec2.C
image/*.C
graphics/psview.C graphics/gtime.C
graphics/graph_edit_playback.C
tree/tvdemo.C
eve/*.C)
#---These ones are disabled !!! ------------------------------------
set(extra_veto
htmlex.C
rootalias.C
rootlogon.C
rootlogoff.C
fft/FFT.C
fit/fit1_C.C fit/TwoHistoFit2D.C fit/line3Dfit.C fit/MDF.C
foam/*.C
graphs/graphstruct.C
html/*.C
math/Bessel.C math/LegendreAssoc.C math/Legendre.C
math/mathmoreIntegration.C math/normalDist.C math/tStudent.C
math/testUnfold2.C math/pca.C
net/*.C
proof/*.C
pythia/*.C
sql/*.C
tree/hsimpleProxy.C tree/tree0.C tree/tree2a.C tree/tree4.C
roostats/rs401d_FeldmanCousins.C
roofit/rf104_classfactory.C
histfactory/ModifyInterpolation.C
tree/copytree2.C tree/copytree3.C tree/copytree.C
math/testUnfold4.C
fit/minuit2FitBench.C
fit/minuit2FitBench2D.C
roostats/*.C
http/*.C)
set(all_veto hsimple.C
${extra_veto}
${gui_veto}
${minuit2_veto}
${roofit_veto}
${unuran_veto}
${xml_veto}
${fitsio_veto}
${mathmore_veto}
${fftw3_veto})
file(GLOB_RECURSE tutorials RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.C)
file(GLOB tutorials_veto RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${all_veto})
list(LENGTH tutorials total)
list(LENGTH tutorials_veto veto)
message(STATUS "${veto}/${total} tutorials have been vetoed for various reasons")
list(REMOVE_ITEM tutorials ${tutorials_veto})
set(returncode_1 fit/fit2a.C fit/graph2dfit.C fit/multidimfit.C
graphics/archi.C graphics/arrow.C
graphics/crown.C graphics/diamond.C
graphics/earth.C graphics/ellipse.C
graphics/event.C graphics/pavetext.C
graphics/tmathtext.C graphics/tmathtext2.C
graphs/exclusiongraph.C graphs/multigraph.C
graphs/multipalette.C
hist/ContourList.C hist/hstack.C
hist/th2polyBoxes.C
io/fildir.C
math/chi2test.C )
#---Loop over all tutorials and define the corresponding test---------
ROOT_ADD_TEST(tutorial-hsimple COMMAND ${ROOT_root_CMD} -b -l -q ${CMAKE_CURRENT_SOURCE_DIR}/hsimple.C
PASSRC 1 FAILREGEX "Error in" "error:" LABELS tutorial)
foreach(t ${tutorials})
list(FIND returncode_1 ${t} index)
if(index EQUAL -1)
set(rc 0)
else()
set(rc 1)
endif()
string(REPLACE ".C" "" tname ${t})
string(REPLACE "/" "-" tname ${tname})
ROOT_ADD_TEST(tutorial-${tname}
COMMAND ${ROOT_root_CMD} -b -l -q ${CMAKE_CURRENT_SOURCE_DIR}/${t}
PASSRC ${rc} FAILREGEX "Error in" "error:"
LABELS tutorial
DEPENDS tutorial-hsimple )
endforeach()
......@@ -13,9 +13,10 @@ void FITS_tutorial1()
if (!gROOT->IsBatch()) {
//printf("Press ENTER to start..."); getchar();
}
TString dir = gSystem->DirName(gInterpreter->GetCurrentMacroName());
// Open primary HDU from file
TFITSHDU *hdu = new TFITSHDU("sample1.fits");
TFITSHDU *hdu = new TFITSHDU(dir+"/sample1.fits");
if (hdu == 0) {
printf("ERROR: could not access the HDU\n"); return;
}
......
......@@ -15,9 +15,10 @@ void FITS_tutorial2()
if (!gROOT->IsBatch()) {
//printf("Press ENTER to start..."); getchar();
}
TString dir = gSystem->DirName(gInterpreter->GetCurrentMacroName());
// Open primary HDU from file
TFITSHDU *hdu = new TFITSHDU("sample2.fits");
TFITSHDU *hdu = new TFITSHDU(dir+"/sample2.fits");
if (hdu == 0) {
printf("ERROR: could not access the HDU\n"); return;
}
......
......@@ -15,11 +15,12 @@ void FITS_tutorial3()
// Open extensions 1 to 5 from file
//printf("Press ENTER to see a canvas with all images within the file:"); getchar();
TString dir = gSystem->DirName(gInterpreter->GetCurrentMacroName());
TCanvas *c = new TCanvas("c1", "FITS tutorial #1", 800, 700);
c->Divide(2,3);
for (int i=1; i <= 5; i++) {
TFITSHDU *hdu = new TFITSHDU("sample3.fits", i);
TFITSHDU *hdu = new TFITSHDU(dir+"/sample3.fits", i);
if (hdu == 0) {
printf("ERROR: could not access the HDU\n"); return;
}
......
......@@ -16,9 +16,10 @@ void FITS_tutorial4()
if (!gROOT->IsBatch()) {
//printf("Press ENTER to start..."); getchar();
}
TString dir = gSystem->DirName(gInterpreter->GetCurrentMacroName());
//Open the table extension number 1)
TFITSHDU *hdu = new TFITSHDU("sample2.fits[1][DATAMAX > 2e-15]");
TFITSHDU *hdu = new TFITSHDU(dir+"/sample2.fits[1][DATAMAX > 2e-15]");
if (hdu == 0) {
printf("ERROR: could not access the HDU\n"); return;
}
......
......@@ -19,9 +19,11 @@ void FITS_tutorial5()
//printf("Press ENTER to start..."); getchar();
//printf("\n");
}
TString dir = gSystem->DirName(gInterpreter->GetCurrentMacroName());
//Open the table
TFITSHDU *hdu = new TFITSHDU("sample4.fits[1]");
TFITSHDU *hdu = new TFITSHDU(dir+"/sample4.fits[1]");
if (hdu == 0) {
printf("ERROR: could not access the HDU\n"); return;
}
......
......@@ -10,9 +10,10 @@ void FITS_tutorial6()
printf("We are going to open a table from a FITS file\n");
printf("and dump its columns.\n\n");
TString dir = gSystem->DirName(gInterpreter->GetCurrentMacroName());
//Open the table
TFITSHDU *hdu = new TFITSHDU("sample4.fits[1]");
TFITSHDU *hdu = new TFITSHDU(dir+"/sample4.fits[1]");
if (hdu == 0) {
printf("ERROR: could not access the HDU\n"); return;
}
......
// Playing with a Tree containing variables of type character
// Author: Rene Brun
void cernstaff () {
if (gSystem->AccessPathName("cernstaff.root")) {
TString dir = gSystem->DirName(gInterpreter->GetCurrentMacroName());
if (gSystem->AccessPathName(dir+"/cernstaff.root")) {
gROOT->SetMacroPath(dir);
gROOT->ProcessLine(".x cernbuild.C");
}
TFile *f = new TFile("cernstaff.root");
TFile *f = new TFile(dir+"/cernstaff.root");
TTree *T = (TTree*)f->Get("T");
TCanvas *c1 = new TCanvas("c1","CERN staff",10,10,1000,750);
c1->SetFillColor(17);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment