Skip to content

Commit

Permalink
Build C++ unit tests in a separate job
Browse files Browse the repository at this point in the history
  • Loading branch information
xhochy committed Sep 2, 2024
1 parent 291f554 commit 9c9f8e3
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 96 deletions.
36 changes: 31 additions & 5 deletions .github/workflows/conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,37 @@ jobs:
user: __token__
password: ${{ secrets.PYPI_UPLOAD }}
packages_dir: dist
linux-unit-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
environment:
# - "py310-pa14"
# - "py311-pa14"
- "py312-pa14"
# - "py310-pa15"
# - "py311-pa15"
# - "py312-pa15"
# - "py310-pa16"
# - "py311-pa16"
# - "py312-pa16"
- "py310-pa17"
# - "py311-pa17"
# - "py312-pa17"
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Set up pixi
uses: prefix-dev/setup-pixi@ba3bb36eb2066252b2363392b7739741bb777659
with:
environments: ${{ matrix.environment }}
- name: Build the wheel
run: pixi run -e ${{ matrix.environment }} meson setup -Dbuild_testing=true builddir .
- name: Build the wheel
run: pixi run -e ${{ matrix.environment }} ninja -C builddir
- name: Build the wheel
run: pixi run -e ${{ matrix.environment }} ninja -C builddir test
linux-tests:
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -202,11 +233,6 @@ jobs:
uses: prefix-dev/setup-pixi@ba3bb36eb2066252b2363392b7739741bb777659
with:
environments: ${{ matrix.environment }}
- run: pixi run -e ${{ matrix.environment }} meson setup builddir
- run: type builddir\meson-logs\meson-log.txt
if: always()
- run: pixi run -e ${{ matrix.environment }} ninja -C builddir
- run: pixi run -e ${{ matrix.environment }} ninja -C builddir test
- name: Build wheel
run: pixi run -e ${{ matrix.environment }} python -m build
- name: Install wheel
Expand Down
52 changes: 26 additions & 26 deletions cpp/cpp_odbc/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,29 @@ cpp_odbc = static_library(
include_directories: include_directories('Library'),
)

cpp_odbc_test_sources = [
'Test/cpp_odbc_test/level1_mock_api.cpp',
'Test/cpp_odbc_test/level2_mock_api.cpp',
]

cpp_odbc_tests = [
'column_description_test',
'connection_test',
'credentials_test',
'environment_test',
'error_test',
'make_environment_test',
'multi_value_buffer_test',
'statement_test',
]
foreach t: cpp_odbc_tests
e = executable(
t,
cpp_odbc_test_sources + ['Test/tests/' + t + '.cpp'],
dependencies: deps + [gtest, gtest_main, gmock],
link_with: [cpp_odbc],
include_directories: include_directories('Library', 'Test'),
)
test(t, e)
endforeach

if build_testing
cpp_odbc_test_sources = [
'Test/cpp_odbc_test/level1_mock_api.cpp',
'Test/cpp_odbc_test/level2_mock_api.cpp',
]
cpp_odbc_tests = [
'column_description_test',
'connection_test',
'credentials_test',
'environment_test',
'error_test',
'make_environment_test',
'multi_value_buffer_test',
'statement_test',
]
foreach t: cpp_odbc_tests
e = executable(
t,
cpp_odbc_test_sources + ['Test/tests/' + t + '.cpp'],
dependencies: deps + [gtest, gtest_main, gmock],
link_with: [cpp_odbc],
include_directories: include_directories('Library', 'Test'),
)
test(t, e)
endforeach
endif
105 changes: 52 additions & 53 deletions cpp/turbodbc/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -44,56 +44,55 @@ turbodbc = static_library(
)


turbodbc_test_sources = [
'Test/tests/mock_classes.cpp',
]

turbodbc_tests = [
'parameter_sets/bound_parameter_set_test',
'parameter_sets/set_field_test',
'descriptions/boolean_description_test',
'descriptions/date_description_test',
'descriptions/floating_point_description_test',
'descriptions/integer_description_test',
'descriptions/string_description_test',
'descriptions/timestamp_description_test',
'descriptions/unicode_description_test',
'field_translators/boolean_translator_test',
'field_translators/date_translator_test',
'field_translators/float64_translator_test',
'field_translators/int64_translator_test',
'field_translators/string_translator_test',
'field_translators/timestamp_translator_test',
'result_sets/bound_result_set_test',
# 'result_sets/double_buffered_result_set_test',
'result_sets/field_result_set_test',
'result_sets/result_set_test',
'result_sets/row_based_result_set_test',
'buffer_size_test',
'column_test',
'command_test',
'configuration_test',
'connection_test',
'description_test',
'errors_test',
'field_translator_test',
'make_description_of_description_test',
'make_description_of_type_test',
'make_description_of_value_test',
'make_field_translator_test',
'parameter_test',
'string_helpers_test',
'time_helpers_test',
]

foreach t: turbodbc_tests
e = executable(
t.replace('/', '_'),
turbodbc_test_sources + ['Test/tests/' + t + '.cpp'],
dependencies: [gtest, gtest_main, gmock],
link_with: [turbodbc],
include_directories: include_directories('Library', 'Test', '../cpp_odbc/Library'),
)
test(t, e)
endforeach

if build_testing
turbodbc_test_sources = [
'Test/tests/mock_classes.cpp',
]
turbodbc_tests = [
'parameter_sets/bound_parameter_set_test',
'parameter_sets/set_field_test',
'descriptions/boolean_description_test',
'descriptions/date_description_test',
'descriptions/floating_point_description_test',
'descriptions/integer_description_test',
'descriptions/string_description_test',
'descriptions/timestamp_description_test',
'descriptions/unicode_description_test',
'field_translators/boolean_translator_test',
'field_translators/date_translator_test',
'field_translators/float64_translator_test',
'field_translators/int64_translator_test',
'field_translators/string_translator_test',
'field_translators/timestamp_translator_test',
'result_sets/bound_result_set_test',
# 'result_sets/double_buffered_result_set_test',
'result_sets/field_result_set_test',
'result_sets/result_set_test',
'result_sets/row_based_result_set_test',
'buffer_size_test',
'column_test',
'command_test',
'configuration_test',
'connection_test',
'description_test',
'errors_test',
'field_translator_test',
'make_description_of_description_test',
'make_description_of_type_test',
'make_description_of_value_test',
'make_field_translator_test',
'parameter_test',
'string_helpers_test',
'time_helpers_test',
]
foreach t: turbodbc_tests
e = executable(
t.replace('/', '_'),
turbodbc_test_sources + ['Test/tests/' + t + '.cpp'],
dependencies: [gtest, gtest_main, gmock],
link_with: [turbodbc],
include_directories: include_directories('Library', 'Test', '../cpp_odbc/Library'),
)
test(t, e)
endforeach
endif
18 changes: 10 additions & 8 deletions cpp/turbodbc_arrow/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ turbodbc_arrow = static_library(
link_with: [turbodbc]
)

arrow_result_set_test = executable(
'arrow_result_set_test',
['Test/tests/arrow_result_set_test.cpp'],
dependencies: [py.dependency(embed: true), arrow, arrow_python, gtest, gtest_main, gmock],
link_with: [turbodbc_arrow],
include_directories: include_directories('Library', 'Test', '../cpp_odbc/Library', '../turbodbc/Library'),
)
test('arrow_result_set_test', arrow_result_set_test)
if build_testing
arrow_result_set_test = executable(
'arrow_result_set_test',
['Test/tests/arrow_result_set_test.cpp'],
dependencies: [py.dependency(embed: true), arrow, arrow_python, gtest, gtest_main, gmock],
link_with: [turbodbc_arrow],
include_directories: include_directories('Library', 'Test', '../cpp_odbc/Library', '../turbodbc/Library'),
)
test('arrow_result_set_test', arrow_result_set_test)
endif
12 changes: 8 additions & 4 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
project(
'turbodbc', 'cpp',
license: 'MIT',
meson_version: '>= 1.0.0',
meson_version: '>= 1.1.0',
default_options: [
'buildtype=release',
'cpp_std=c++17',
'warning_level=3',
'build_testing=false',
]
)

Expand All @@ -19,9 +20,12 @@ if target_machine.system() == 'windows'
endif
simdutf = dependency('simdutf')
arrow = dependency('arrow')
gtest = dependency('gtest')
gtest_main = dependency('gtest_main')
gmock = dependency('gmock')
build_testing = get_option('build_testing')
if build_testing
gtest = dependency('gtest')
gtest_main = dependency('gtest_main')
gmock = dependency('gmock')
endif

# unixodbc = dependency('unixodbc')
py = import('python').find_installation()
Expand Down
1 change: 1 addition & 0 deletions meson.options
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
option('build_testing', type : 'boolean', value : false)

0 comments on commit 9c9f8e3

Please sign in to comment.