Skip to content
Open
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
4 changes: 1 addition & 3 deletions bindings/pyroot/cppyy/cppyy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,4 @@ install(DIRECTORY ${localruntimedir}/cppyy
COMPONENT libraries
PATTERN *.so EXCLUDE)

if(NOT MSVC)
ROOT_ADD_TEST_SUBDIRECTORY(test)
endif()
ROOT_ADD_TEST_SUBDIRECTORY(test)
174 changes: 132 additions & 42 deletions bindings/pyroot/cppyy/cppyy/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,68 +8,56 @@
set(CPPYY_TEST_DICTS
advancedcpp
advancedcpp2
conversions
cpp11features
crossinheritance
datatypes
doc_helper
example01
fragile
operators
overloads
pythonizables
std_streams
templates
stltypes)
)

foreach(DICT ${CPPYY_TEST_DICTS})
set(CMAKE_ROOTTEST_NOROOTMAP OFF)
# only disable rootmap for all but example01 and stltypes which require them
if(NOT DICT STREQUAL "example01" AND NOT DICT STREQUAL "stltypes")
set(CMAKE_ROOTTEST_NOROOTMAP ON)
endif()
# Generate dictionary for the tests
ROOT_GENERATE_DICTIONARY(G__${DICT}Dict ${CMAKE_CURRENT_SOURCE_DIR}/${DICT}.h LINKDEF ${CMAKE_CURRENT_SOURCE_DIR}/${DICT}.xml)
set(CMAKE_ROOTTEST_NOROOTMAP ON)

set(dictname ${DICT}Dict)

# Generate dictionary WITH PCM/module
ROOT_GENERATE_DICTIONARY(
G__${dictname}
${CMAKE_CURRENT_SOURCE_DIR}/${DICT}.h
LINKDEF ${CMAKE_CURRENT_SOURCE_DIR}/${DICT}.xml
MODULE ${dictname}
)

# Create necessary shared libraries for the tests
add_library(${DICT}Dict SHARED ${CMAKE_CURRENT_SOURCE_DIR}/${DICT}.cxx G__${DICT}Dict.cxx)
target_include_directories(${DICT}Dict PUBLIC ${Python3_INCLUDE_DIRS} ${CMAKE_BINARY_DIR}/include)
target_link_libraries(${DICT}Dict PUBLIC ROOT::Core)
target_compile_options(${DICT}Dict PRIVATE "-w")
if(MSVC)
target_link_libraries(${DICT}Dict PUBLIC Python3::Python)
set_target_properties(${DICT}Dict PROPERTIES
PREFIX "lib"
IMPORT_PREFIX "lib"
)
#set_target_properties(${DICT}Dict PROPERTIES PREFIX "")
set_target_properties(${DICT}Dict PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
elseif(APPLE)
target_link_libraries(${DICT}Dict PUBLIC -Wl,-bind_at_load -Wl,-w -Wl,-undefined -Wl,dynamic_lookup)
else()
target_link_libraries(${DICT}Dict PUBLIC -Wl,--unresolved-symbols=ignore-all)
endif()

endforeach()
unset(CMAKE_ROOTTEST_NOROOTMAP)

# Tests list
set(CPPYY_TESTS
test_aclassloader
test_advancedcpp
test_advancedcpp # requires two dictionaries
test_api
test_boost
test_conversions
test_crossinheritance
test_datatypes
test_doc_features
test_eigen
test_fragile
# The leakcheck test is disabled due to its sporadic nature, especially fragile on VMs
# test_leakcheck
test_lowlevel
test_numba
test_operators
test_overloads
test_pythonify
test_pythonization
test_regression
test_streams
test_templates
test_concurrent)

set(enable_test_cpp11features FALSE)
if(NOT CMAKE_CXX_STANDARD EQUAL 23)
# test_cpp11features crashes when run with C++23
if(APPLE)
Expand All @@ -79,21 +67,123 @@ if(NOT CMAKE_CXX_STANDARD EQUAL 23)
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(MACOS_VERSION VERSION_LESS "26.0")
# Parts of this test suite fail with std::make_unique
list(APPEND CPPYY_TEST_DICTS test_cpp11features)
# Parts of this test suite fail with std::make_unique
set(enable_test_cpp11features TRUE)
endif()
else()
list(APPEND CPPYY_TESTS test_cpp11features)
set(enable_test_cpp11features TRUE)
endif()
endif()

if(NOT APPLE)
# test_stltypes completely fails on OSX
# because it is unable to load the necessary shared libraries
list(APPEND CPPYY_TESTS test_stltypes)
if(MSVC)
set(common_args GENERIC PYTHON_DEPS pytest)
else()
set(common_args GENERIC ENVIRONMENT ${ld_library_path}=${CMAKE_CURRENT_BINARY_DIR} PYTHON_DEPS pytest)
endif()

# Configure the tests
foreach(TEST ${CPPYY_TESTS})
ROOT_ADD_PYUNITTEST(${TEST} ${TEST}.py GENERIC ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR} PYTHON_DEPS pytest)
ROOT_ADD_PYUNITTEST(${TEST} ${TEST}.py ${common_args})
endforeach()

function(ROOT_ADD_PYUNITTEST_ACLIC TESTNAME)
set(options)
set(oneValueArgs)
set(multiValueArgs DICTNAME)
cmake_parse_arguments(ARG
"${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}
)

# Common test args
set(_common_args ${common_args})

set(_precmd $<TARGET_FILE:root.exe> -b -q -l -e ".L ${ARG_DICTNAME}.cxx+")

ROOT_ADD_PYUNITTEST(${TESTNAME} ${TESTNAME}.py
${_common_args}
COPY_TO_BUILDDIR ${ARG_DICTNAME}.cxx ${ARG_DICTNAME}.h
PRECMD ${_precmd}
)
endfunction()

# doesn't pass on Windows
ROOT_ADD_PYUNITTEST_ACLIC(
test_doc_features
DICTNAME doc_helper
)

ROOT_ADD_PYUNITTEST_ACLIC(
test_operators
DICTNAME operators
)

ROOT_ADD_PYUNITTEST_ACLIC(
test_streams
DICTNAME std_streams
)

ROOT_ADD_PYUNITTEST_ACLIC(
test_crossinheritance
DICTNAME crossinheritance
)

ROOT_ADD_PYUNITTEST_ACLIC(
test_conversions
DICTNAME conversions
)

ROOT_ADD_PYUNITTEST_ACLIC(
test_fragile
DICTNAME fragile
)

ROOT_ADD_PYUNITTEST(test_pythonify test_pythonify.py
${common_args}
COPY_TO_BUILDDIR example01.cxx example01.h
PRECMD $<TARGET_FILE:root.exe> -b -q -l -e ".L example01.cxx+"
FIXTURES_SETUP example01_dict_fixture
)

ROOT_ADD_PYUNITTEST(test_lowlevel test_lowlevel.py
${common_args}
COPY_TO_BUILDDIR datatypes.cxx datatypes.h
PRECMD $<TARGET_FILE:root.exe> -b -q -l -e ".L datatypes.cxx+"
FIXTURES_SETUP datatypes_dict_fixture
)

if(NOT MSVC OR win_broken_tests)
ROOT_ADD_PYUNITTEST(test_datatypes test_datatypes.py ${common_args} FIXTURES_REQUIRED datatypes_dict_fixture)

ROOT_ADD_PYUNITTEST_ACLIC(
test_overloads
DICTNAME overloads
)
endif()

ROOT_ADD_PYUNITTEST(test_aclassloader test_aclassloader.py ${common_args} FIXTURES_REQUIRED example01_dict_fixture)

# doesn't pass on Windows
ROOT_ADD_PYUNITTEST_ACLIC(
test_templates
DICTNAME templates
)

# doesn't pass on Windows
if(enable_test_cpp11features)
ROOT_ADD_PYUNITTEST_ACLIC(
test_cpp11features
DICTNAME cpp11features
)
endif()

if(NOT APPLE)
# test_stltypes completely fails on OSX
# because it is unable to load the necessary shared libraries
ROOT_ADD_PYUNITTEST_ACLIC(
test_stltypes
DICTNAME stltypes
)
endif()

# The leakcheck test is disabled due to its sporadic nature, especially fragile on VMs
# ROOT_ADD_PYUNITTEST(test_leakcheck test_leakcheck.py ${common_args})
3 changes: 2 additions & 1 deletion bindings/pyroot/cppyy/cppyy/test/templates.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#ifndef CPPYY_TEST_TEMPLATES_H
#define CPPYY_TEST_TEMPLATES_H

#include <sstream>
#include <stdexcept>
#include <string>
#include <sstream>
#include <typeinfo>
#include <vector>

#ifndef _WIN32
Expand Down
7 changes: 3 additions & 4 deletions bindings/pyroot/cppyy/cppyy/test/test_aclassloader.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import py, pytest, os
import pytest, os

Check failure on line 1 in bindings/pyroot/cppyy/cppyy/test/test_aclassloader.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F401)

bindings/pyroot/cppyy/cppyy/test/test_aclassloader.py:1:16: F401 `os` imported but unused

Check failure on line 1 in bindings/pyroot/cppyy/cppyy/test/test_aclassloader.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E401)

bindings/pyroot/cppyy/cppyy/test/test_aclassloader.py:1:1: E401 Multiple imports on one line
from pytest import raises, mark

Check failure on line 2 in bindings/pyroot/cppyy/cppyy/test/test_aclassloader.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F401)

bindings/pyroot/cppyy/cppyy/test/test_aclassloader.py:2:20: F401 `pytest.raises` imported but unused
from support import setup_make, IS_MAC

Check failure on line 3 in bindings/pyroot/cppyy/cppyy/test/test_aclassloader.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F401)

bindings/pyroot/cppyy/cppyy/test/test_aclassloader.py:3:33: F401 `support.IS_MAC` imported but unused

Check failure on line 3 in bindings/pyroot/cppyy/cppyy/test/test_aclassloader.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F401)

bindings/pyroot/cppyy/cppyy/test/test_aclassloader.py:3:21: F401 `support.setup_make` imported but unused

Check failure on line 3 in bindings/pyroot/cppyy/cppyy/test/test_aclassloader.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (I001)

bindings/pyroot/cppyy/cppyy/test/test_aclassloader.py:1:1: I001 Import block is un-sorted or un-formatted

currpath = os.getcwd()
test_dct = currpath + "/libexample01Dict"
test_dct = "libexample_cxx"


class TestACLASSLOADER:

def setup_class(cls):
import cppyy

Check failure on line 11 in bindings/pyroot/cppyy/cppyy/test/test_aclassloader.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F401)

bindings/pyroot/cppyy/cppyy/test/test_aclassloader.py:11:16: F401 `cppyy` imported but unused

@mark.xfail(condition=IS_MAC, reason="Fails on OSX")
@mark.xfail(reason="rootmap files are a legacy feature")
def test01_class_autoloading(self):
"""Test whether a class can be found through .rootmap."""
import cppyy
Expand Down
5 changes: 2 additions & 3 deletions bindings/pyroot/cppyy/cppyy/test/test_advancedcpp.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import py, pytest, os
import pytest, os

Check failure on line 1 in bindings/pyroot/cppyy/cppyy/test/test_advancedcpp.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F401)

bindings/pyroot/cppyy/cppyy/test/test_advancedcpp.py:1:16: F401 `os` imported but unused

Check failure on line 1 in bindings/pyroot/cppyy/cppyy/test/test_advancedcpp.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E401)

bindings/pyroot/cppyy/cppyy/test/test_advancedcpp.py:1:1: E401 Multiple imports on one line
from pytest import mark, raises, skip
from support import setup_make, pylong, IS_WINDOWS, ispypy

Check failure on line 3 in bindings/pyroot/cppyy/cppyy/test/test_advancedcpp.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (I001)

bindings/pyroot/cppyy/cppyy/test/test_advancedcpp.py:1:1: I001 Import block is un-sorted or un-formatted

currpath = os.getcwd()
test_dct = currpath + "/libadvancedcppDict"
test_dct = "libadvancedcppDict"


class TestADVANCEDCPP:
Expand Down
5 changes: 2 additions & 3 deletions bindings/pyroot/cppyy/cppyy/test/test_conversions.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import py, pytest, os
import pytest, os
from pytest import raises
from support import setup_make

currpath = os.getcwd()
test_dct = currpath + "/libconversionsDict"
test_dct = "conversions_cxx"


class TestCONVERSIONS:
Expand Down
5 changes: 2 additions & 3 deletions bindings/pyroot/cppyy/cppyy/test/test_cpp11features.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import py, sys, pytest, os
import sys, pytest, os
from pytest import mark, raises
from support import setup_make, ispypy, IS_MAC_ARM


currpath = os.getcwd()
test_dct = currpath + "/libcpp11featuresDict"
test_dct = "cpp11features_cxx"


class TestCPP11FEATURES:
Expand Down
6 changes: 2 additions & 4 deletions bindings/pyroot/cppyy/cppyy/test/test_crossinheritance.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import py, os, pytest
import os, pytest
from pytest import raises, skip, mark
from support import setup_make, pylong, IS_MAC_ARM


currpath = os.getcwd()
test_dct = currpath + "/libcrossinheritanceDict"
test_dct = "crossinheritance_cxx"


class TestCROSSINHERITANCE:
Expand Down
5 changes: 2 additions & 3 deletions bindings/pyroot/cppyy/cppyy/test/test_datatypes.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import py, sys, pytest, os
import sys, pytest, os
from pytest import mark, raises, skip
from support import setup_make, pylong, pyunicode, IS_MAC, IS_MAC_ARM

currpath = os.getcwd()
test_dct = currpath + "/libdatatypesDict"
test_dct = "datatypes_cxx"


class TestDATATYPES:
Expand Down
5 changes: 2 additions & 3 deletions bindings/pyroot/cppyy/cppyy/test/test_doc_features.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import py, sys, pytest, os
import sys, pytest, os
from pytest import mark, raises, skip
from support import setup_make, ispypy, IS_WINDOWS, IS_MAC_ARM


currpath = os.getcwd()
test_dct = currpath + "/libdoc_helperDict"
test_dct = "doc_helper_cxx"


class TestDOCFEATURES:
Expand Down
17 changes: 12 additions & 5 deletions bindings/pyroot/cppyy/cppyy/test/test_fragile.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import py, os, sys, pytest
import os, sys, pytest
from pytest import mark, raises, skip
from support import setup_make, ispypy, IS_WINDOWS, IS_MAC_ARM


currpath = os.getcwd()
test_dct = currpath + "/libfragileDict"

test_dct = "fragile_cxx"

class TestFRAGILE:
def setup_class(cls):
Expand Down Expand Up @@ -35,7 +33,16 @@ def test02_missing_classes(self):
assert cppyy.gbl.fragile == cppyy.gbl.fragile
fragile = cppyy.gbl.fragile

raises(AttributeError, getattr, fragile, "no_such_class")
if "runtime_cxxmodules" in cppyy.gbl.gROOT.GetConfigFeatures():
# When using modules, Clang records forward declarations as proper
# AST entities (incomplete types that can't be instantiated).
no_such_class = fragile.no_such_class
raises(TypeError, no_such_class) # cannot instantiate incomplete type
else:
# Without a PCM module, the incomplete type doesn't exist, because
# incomplete types are not existing in the rootmap + dictionary
# metadata.
raises(AttributeError, getattr, fragile, "no_such_class")

assert fragile.C is fragile.C
assert fragile.C == fragile.C
Expand Down
5 changes: 2 additions & 3 deletions bindings/pyroot/cppyy/cppyy/test/test_lowlevel.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import py, sys, pytest, os
import sys, pytest, os
from pytest import mark, raises, skip
from support import setup_make, pylong, pyunicode, IS_WINDOWS, ispypy


currpath = os.getcwd()
test_dct = currpath + "/libdatatypesDict"
test_dct = "datatypes_cxx"


class TestLOWLEVEL:
Expand Down
5 changes: 2 additions & 3 deletions bindings/pyroot/cppyy/cppyy/test/test_operators.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import py, pytest, os
import pytest, os
from pytest import raises, skip, mark
from support import setup_make, pylong, maxvalue, IS_WINDOWS, IS_MAC, no_root_errors


currpath = os.getcwd()
test_dct = currpath + "/liboperatorsDict"
test_dct = "operators_cxx"


class TestOPERATORS:
Expand Down
Loading
Loading