Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions bindings/tpython/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,38 @@ if(NOT MSVC)
ROOT_ADD_GTEST(testTPython testTPython.cxx LIBRARIES ROOTTPython ENVIRONMENT ${tpython_gtest_env})
ROOT_ADD_PYUNITTEST(test_tpython test_tpython.py)
endif()

# Tests using TPython from ROOT macros and from the C++ Jupyter kernel
set(ROOT_root_CMD $<TARGET_FILE:root.exe>)

# A test for issue #9058
ROOTTEST_ADD_TEST(execscript
MACRO execscript.C
COPY_TO_BUILDDIR execscript.py
FAILREGEX "FAILURE")

# On Windows, code JIT-compiled in the interpreter cannot resolve the
# CppInternal::DispatchRaw::MakeFunctionCallable_interp dispatch slot: it
# is a data symbol (a function-pointer variable), which the bindexplib
# generated export tables do not cover. Exporting writable data across a
# DLL boundary needs a considered fix (or an upstream CppInterOp change
# to register the dispatch slots by value instead of by symbol lookup).
if(NOT MSVC OR win_broken_tests)
ROOTTEST_ADD_TEST(api
MACRO runPyAPITestCppyy.C
WORKING_DIR ${CMAKE_CURRENT_SOURCE_DIR}
OUTREF PyAPITest.ref)
endif()

if(NOT MSVC OR win_broken_tests)
ROOTTEST_ADD_TEST(class
MACRO runPyClassTest.C
WORKING_DIR ${CMAKE_CURRENT_SOURCE_DIR}
OUTREF PyClassTest.ref)
endif()

ROOTTEST_ADD_TEST(notebook
COPY_TO_BUILDDIR tpython.ipynb
COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/roottest/python/JupyROOT/nbdiff.py tpython.ipynb
RUN_SERIAL
PYTHON_DEPS jupyter)
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions roottest/python/JupyROOT/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ set(DOCTEST_LAUNCHER ${CMAKE_CURRENT_SOURCE_DIR}/doctest_launcher.py)
set(NOTEBOOKS importROOT.ipynb
simpleCppMagic.ipynb
thread_local.ipynb
ROOT_kernel.ipynb
tpython.ipynb)
ROOT_kernel.ipynb)

# Test all modules with doctest. All new tests will be automatically picked up
file(GLOB pyfiles ${MODULES_LOCATION}/*.py)
Expand Down
24 changes: 0 additions & 24 deletions roottest/python/cling/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,4 @@
if(pyroot)
# On Windows, code JIT-compiled in the interpreter cannot resolve the
# CppInternal::DispatchRaw::MakeFunctionCallable_interp dispatch slot: it
# is a data symbol (a function-pointer variable), which the bindexplib
# generated export tables do not cover. Exporting writable data across a
# DLL boundary needs a considered fix (or an upstream CppInterOp change
# to register the dispatch slots by value instead of by symbol lookup).
if(NOT MSVC OR win_broken_tests)
set(api_macro_file runPyAPITestCppyy.C) # Uses new Cppyy API
ROOTTEST_ADD_TEST(api
MACRO ${api_macro_file}
WORKING_DIR ${CMAKE_CURRENT_SOURCE_DIR}
OUTREF PyAPITest.ref)
endif()

# TPython::LoadMacro and TPython::Import are broken in the new Cppyy
# https://bitbucket.org/wlav/cppyy/issues/65
# For now, we rely on our own implementation of TPython
if(NOT MSVC OR win_broken_tests)
ROOTTEST_ADD_TEST(class MACRO
runPyClassTest.C
WORKING_DIR ${CMAKE_CURRENT_SOURCE_DIR}
OUTREF PyClassTest.ref)
endif()

ROOTTEST_ADD_TEST(cling
MACRO PyROOT_clingtests.py
WORKING_DIR ${CMAKE_CURRENT_SOURCE_DIR}
Expand Down
8 changes: 2 additions & 6 deletions roottest/python/regression/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
if(pyroot)
set(scott_file ScottCppyy.C) # Uses Cppyy header

if(NOT MSVC OR win_broken_tests)
ROOTTEST_ADD_TEST(regression
MACRO PyROOT_regressiontests.py OPTS -b
LABELS longtest
COPY_TO_BUILDDIR ${scott_file} Scott3.C MuonTileID.C
COPY_TO_BUILDDIR Scott3.C MuonTileID.C
CoralAttributeList.C Marco.C
PRECMD ${ROOT_root_CMD} -b -q -e gSystem->Load\(\"libROOTTPython\"\)
-e .L\ ${scott_file}+
-e .L\ Scott3.C+
PRECMD ${ROOT_root_CMD} -b -q -e .L\ Scott3.C+
-e .L\ MuonTileID.C+
-e .L\ CoralAttributeList.C+)
endif()
Expand Down
39 changes: 35 additions & 4 deletions roottest/python/regression/PyROOT_regressiontests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
ROOT-specific tests and tests without upstream equivalents.
"""

import platform

Check failure on line 16 in roottest/python/regression/PyROOT_regressiontests.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (F401)

roottest/python/regression/PyROOT_regressiontests.py:16:8: F401 `platform` imported but unused help: Remove unused import: `platform`
import sys, os, unittest

Check failure on line 17 in roottest/python/regression/PyROOT_regressiontests.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (E401)

roottest/python/regression/PyROOT_regressiontests.py:17:1: E401 Multiple imports on one line help: Split imports

Check failure on line 17 in roottest/python/regression/PyROOT_regressiontests.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (I001)

roottest/python/regression/PyROOT_regressiontests.py:16:1: I001 Import block is un-sorted or un-formatted help: Organize imports
sys.path.append(os.path.dirname(os.path.dirname(__file__)))

if not os.path.exists('ScottCppyy.C'):
if not os.path.exists('Scott3.C'):
os.chdir(os.path.dirname(__file__))

try:
Expand All @@ -29,11 +29,11 @@

original_preload = os.environ.get('LD_PRELOAD', None)

import ROOT

Check failure on line 32 in roottest/python/regression/PyROOT_regressiontests.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (I001)

roottest/python/regression/PyROOT_regressiontests.py:32:1: I001 Import block is un-sorted or un-formatted help: Organize imports

Check failure on line 32 in roottest/python/regression/PyROOT_regressiontests.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (E402)

roottest/python/regression/PyROOT_regressiontests.py:32:1: E402 Module level import not at top of file help: Move module level imports to top of file
ROOT.PyConfig.IgnoreCommandLineOptions = False
from ROOT import gROOT, gInterpreter

Check failure on line 34 in roottest/python/regression/PyROOT_regressiontests.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (E402)

roottest/python/regression/PyROOT_regressiontests.py:34:1: E402 Module level import not at top of file help: Move module level imports to top of file
from ROOT import TClass, TObject, TFile

Check failure on line 35 in roottest/python/regression/PyROOT_regressiontests.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (E402)

roottest/python/regression/PyROOT_regressiontests.py:35:1: E402 Module level import not at top of file help: Move module level imports to top of file
from ROOT import TVector3, TGraph, TMatrixD

Check failure on line 36 in roottest/python/regression/PyROOT_regressiontests.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (E402)

roottest/python/regression/PyROOT_regressiontests.py:36:1: E402 Module level import not at top of file help: Move module level imports to top of file
import cppyy

Check failure on line 37 in roottest/python/regression/PyROOT_regressiontests.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (I001)

roottest/python/regression/PyROOT_regressiontests.py:34:1: I001 Import block is un-sorted or un-formatted help: Organize imports

cleaned_preload = os.environ.get('LD_PRELOAD', None)
Expand Down Expand Up @@ -65,11 +65,42 @@
x = TestTChain() # TestTChain defined in Amir.py


# TPyException thrown from C++ code ========================================
# PyException thrown from C++ code ==========================================
class Regression02PyException(MyTestCase):
def test1RaiseAndTrapPyException(self):
"""Test thrown TPyException object processing"""
gROOT.LoadMacro("ScottCppyy.C+")
"""Test thrown PyException object processing"""
# JIT-compiled, so the Python symbols resolve to the running interpreter
gInterpreter.Declare(r"""
#include "cpyrt/PyException.h"
#include "DllImport.h"

extern "C" {
struct _object;
void PyErr_SetString(_object *, const char *);
R__EXTERN _object *PyExc_SyntaxError;
}

void ThrowPyException()
{
PyErr_SetString(PyExc_SyntaxError, "test error message");
throw cppjit::cpyrt::PyException();
}

class MyThrowingClass {
public:
static void ThrowPyException(int)
{
PyErr_SetString(PyExc_SyntaxError, "overloaded int test error message");
throw cppjit::cpyrt::PyException();
}

static void ThrowPyException(double)
{
PyErr_SetString(PyExc_SyntaxError, "overloaded double test error message");
throw cppjit::cpyrt::PyException();
}
};
""")

# test of not overloaded global function
with self.assertRaisesRegex(SyntaxError, "test error message"):
Expand Down
29 changes: 0 additions & 29 deletions roottest/python/regression/ScottCppyy.C

This file was deleted.

5 changes: 0 additions & 5 deletions roottest/python/tpython/CMakeLists.txt

This file was deleted.

Loading