Our project includes two types of tests: one written in C++ using the ROOT framework and CTest and the other written in JavaScript using JSRoot and Node.js. Below are the instructions to run the tests. To run the tests, you need to have ROOT installed on your system. ROOT is a framework for data processing, developed by CERN. If you do not have ROOT installed, please visit the ROOT Installation Guide for installation instructions.
The first test in the Test_Root.cpp file creates TCanvas objects using ROOT macros. These TCanvas objects are then used to generate JSON/SVG files, which ate then compared to reference JSON/SVG files located in the json_ref/old_svg_ref folder.
The second test in the Test_JsRoot.js file generates SVG files using JSROOT based on the reference JSON files in the json_ref folder. These generated SVG files are then compared during the test execution to ensure they match the expected output.
To start using the project, clone the repository to your local machine:
git clone https://github.com/DuesselbergAdrian/root-graphic-tests.git
cd root-graphic-tests
Install all necessary dependencies using npm:
npm install
To prepare and run tests, ensure you have the required node packages installed in the root/js directory.
mkdir build
cd build
cmake ..
make
ctest
You can use ctest with various options to run specific tests. Below are some examples:
To run a specific test for a macro with a particular test type:
ctest -R macroname_ALL_testtype
Important: Replace macroname and testype
To run all tests for a specific macro:
ctest -R macroname_ALL
Important: Replace macroname
To run all tests within a specific macro folder:
ctest -R macrofolder
Important: Replace macrofolder
Important: Both ways can be implemented but not at the same time.
When comparing generated and reference files using git diff, you can directly observe changes when a test fails and the reference file is overwritten. It's crucial to note that certain parts of the files should be considered separately, as they are not part of standard comparison algorithms:
- JSON Files: fTsumwx, ftsumwx2
- Old SVG Files: <title> and sections
- PDF files: creationDate-, modDate-, title- and xrefPattern
For detailed information please have a look at the PREPROCESSCONTENT functions.
To check differences between generated and reference jsons one can use diff in the root-graphics-tests repository. These files are saved in the folders json_pro and json_ref.
diff builddir/json_pro/macroname_pro.json json_ref/macroname.json
Important: Replace macroname and builddir
To check differences between new generated and reference svgs one can use diff root-graphics-tests repository. These files are saved in the folders svg_pro and svg_ref.
diff builddir/svg_pro/macroname_pro.svg svg_ref/macroname.svg
Important: Replace macroname and builddir
To check differences between old generated and refernece svgs one can use diff in the root-graphics-tests repository. These files are saved in the folders old_svg_pro and old_svg_ref.
diff builddir/old_svg_pro/macroname_pro.svg old_svg_ref/macroname.svg
Important: Replace macroname and builddir
To check differences between old generated and refernece pdfs one can use diff in the root-graphics-tests repository. These files are saved in the folders pdf_pro and pdf_ref.
diff builddir/pdf_pro/macroname_pro.pdf pdf_ref/macroname.pdf
Important: Replace macroname and builddir
To update reference files if there are changes, delete the corresponding reference files and run the test twice. (Note: This process is not yet automated.)
For instructions on how to add new tests, refer to the CONTRIBUTING.md file.
To run the tests located in root-graphic-tests, execute the following commands:
cd build
ctest
To run it parallel on 9 cores:
cd build
ctest --parallel 9
To run it with additional information:
cd build
ctest --verbose
if [ -z "$ROOTSYS" ]; then
echo "ROOTSYS is not set. Please set the ROOTSYS environment variable."
exit 1
fi
JS_DIR="$ROOTSYS/js"
if [ -d "$JS_DIR" ]; then
cd "$JS_DIR"
else
echo "$JS_DIR does not exist. Please check your ROOTSYS path."
exit 1
fi
cat <<EOL > package.json
{
"name": "js",
"version": "1.0.0",
"engines": {
"node": ">= 0.18.0"
},
"description": "JavaScript ROOT",
"homepage": "https://root.cern/js/",
"type": "module",
"main": "./build/jsroot.js",
"module": "./modules/main.mjs",
"dependencies": {
"canvas": "^2.11.2",
"gl": "^8.0.2",
"jsdom": "^22.1.0",
"mathjax": "^3.2.2"
},
"repository": {
"type": "git",
"url": "https://github.com/root-project/root.git"
},
"license": "MIT",
"author": "Adrian D."
}
EOL
npm install
cd -
git clone https://github.com/DuesselbergAdrian/root-graphic-tests.git
cd root-graphic-tests
npm install
mkdir build
cd build
cmake ..
make
ctest