Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: add test package depending on a cmake subproject #599

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
13 changes: 13 additions & 0 deletions tests/packages/cmake-subproject/cmakesubproject.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# SPDX-FileCopyrightText: 2024 The meson-python developers
#
# SPDX-License-Identifier: MIT

cdef extern from "cmaketest.hpp":
cdef cppclass Test:
Test(int) except +
int add(int)


def sum(int a, int b):
t = new Test(a)
return t.add(b)
21 changes: 21 additions & 0 deletions tests/packages/cmake-subproject/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# SPDX-FileCopyrightText: 2024 The meson-python developers
#
# SPDX-License-Identifier: MIT

project('cmake-subproject', ['c', 'cpp', 'cython'], version: '1')

if meson.version().version_compare('>= 1.3.0')
dep = dependency('cmaketest')
else
dep = import('cmake').subproject('cmaketest').dependency('cmaketest')
endif

py = import('python').find_installation()

py.extension_module(
'cmakesubproject',
'cmakesubproject.pyx',
dependencies: dep,
override_options: ['cython_language=cpp'],
install: true,
)
7 changes: 7 additions & 0 deletions tests/packages/cmake-subproject/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: 2021 The meson-python developers
#
# SPDX-License-Identifier: MIT

[build-system]
build-backend = 'mesonpy'
requires = ['meson-python']
9 changes: 9 additions & 0 deletions tests/packages/cmake-subproject/subprojects/cmaketest.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# SPDX-FileCopyrightText: 2024 The meson-python developers
#
# SPDX-License-Identifier: MIT

[wrap-file]
method = cmake

[provide]
cmaketest = cmaketest_dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SPDX-FileCopyrightText: 2024 The meson-python developers
#
# SPDX-License-Identifier: MIT

cmake_minimum_required(VERSION 3.5)

project(cmaketest)
set(CMAKE_CXX_STANDARD 14)

include_directories(${CMAKE_CURRENT_BINARY_DIR})

add_library(cmaketest SHARED cmaketest.cpp)

include(GenerateExportHeader)
generate_export_header(cmaketest)

install(TARGETS cmaketest)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-FileCopyrightText: 2024 The meson-python developers
//
// SPDX-License-Identifier: MIT

#include "cmaketest.hpp"

Test::Test(int x) {
this->x = x;
}

int Test::add(int y) const {
return x + y;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-FileCopyrightText: 2024 The meson-python developers
//
// SPDX-License-Identifier: MIT

#pragma once
#include "cmaketest_export.h"

class CMAKETEST_EXPORT Test {
private:
int x;
public:
Test(int x);
int add(int y) const;
};
12 changes: 12 additions & 0 deletions tests/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,3 +362,15 @@
'package/generated/one.py',
'package/generated/two.py',
}


@pytest.mark.skipif(sys.platform not in {'linux', 'darwin'}, reason='Not supported on this platform')
def test_cmake_subproject(wheel_cmake_subproject):
artifact = wheel.wheelfile.WheelFile(wheel_cmake_subproject)
assert wheel_contents(artifact) == {

Check warning on line 370 in tests/test_wheel.py

View check run for this annotation

Codecov / codecov/patch

tests/test_wheel.py#L369-L370

Added lines #L369 - L370 were not covered by tests
'cmake_subproject-1.dist-info/METADATA',
'cmake_subproject-1.dist-info/RECORD',
'cmake_subproject-1.dist-info/WHEEL',
f'.cmake_subproject.mesonpy.libs/libcmaketest{LIB_SUFFIX}',
f'cmakesubproject{EXT_SUFFIX}',
}
Loading