Skip to content

Commit

Permalink
Fixing python tests crashing on newer CPython releases
Browse files Browse the repository at this point in the history
  • Loading branch information
gershnik committed Aug 14, 2024
1 parent dc36ce2 commit 10f46d4
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 32 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
permissions: write-all
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Get release Name
shell: python
Expand All @@ -27,7 +27,7 @@ jobs:
run: tar -czf intrusive_shared_ptr-${{ env.RELEASE_NAME }}.tar.gz --transform 's/inc/intrusive_shared_ptr\/inc/' inc

- name: Make release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
id: create_release
with:
draft: true
Expand Down
57 changes: 29 additions & 28 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,29 @@ jobs:
- os: macos-latest
- os: windows-latest
- os: ubuntu-latest
cc: gcc-11
cxx: g++-11
compiler: gcc
version: 11
- os: ubuntu-latest
cc: gcc-12
cxx: g++-12
compiler: gcc
version: 12
- os: ubuntu-latest
cc: gcc-13
cxx: g++-13
compiler: gcc
version: 13
- os: ubuntu-latest
cc: clang-13
cxx: clang++-13
compiler: clang
version: 13
- os: ubuntu-latest
cc: clang-14
cxx: clang++-14
compiler: clang
version: 14
- os: ubuntu-latest
cc: clang-15
cxx: clang++-15
compiler: clang
version: 15
- os: ubuntu-latest
compiler: clang
version: 16
- os: ubuntu-latest
compiler: clang
version: 17

steps:
- name: Checkout
Expand All @@ -46,31 +52,26 @@ jobs:
shell: bash
run: |
if [[ '${{ matrix.os }}' == 'ubuntu-latest' ]]; then
if [[ '${{ matrix.cc }}' == 'clang-15' ]]; then
sudo apt-get update
sudo apt-get install -y clang-15 clang++-15
fi
if [[ '${{ matrix.cc }}' == 'gcc-12' ]]; then
sudo apt-get update
sudo apt-get install -y gcc-12 g++-12
if [[ '${{ matrix.compiler }}' == 'clang' ]]; then
wget https://apt.llvm.org/llvm.sh
chmod u+x llvm.sh
sudo ./llvm.sh ${{ matrix.version }}
echo "CC=clang-${{ matrix.version }}" >> $GITHUB_ENV
echo "CXX=clang++-${{ matrix.version }}" >> $GITHUB_ENV
fi
if [[ '${{ matrix.cc }}' == 'gcc-13' ]]; then
if [[ '${{ matrix.compiler }}' == 'gcc' ]]; then
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install -y gcc-13 g++-13
sudo apt-get install -y gcc-${{ matrix.version }} g++-${{ matrix.version }}
echo "CC=gcc-${{ matrix.version }}" >> $GITHUB_ENV
echo "CXX=g++-${{ matrix.version }}" >> $GITHUB_ENV
fi
fi
- name: Configure
shell: bash
run: |
if [[ '${{ matrix.cc }}' != '' ]]; then
export CC=${{ matrix.cc }}
fi
if [[ '${{ matrix.cxx }}' != '' ]]; then
export CXX=${{ matrix.cxx }}
fi
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
- name: Build and Test
Expand Down
17 changes: 15 additions & 2 deletions test/test_main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
#define CATCH_CONFIG_RUNNER
#include "catch.hpp"

#if ISPTR_USE_PYTHON
#include <Python.h>
#endif

int main(int argc, char** argv)
{
return Catch::Session().run( argc, argv );
}
#if ISPTR_USE_PYTHON
Py_Initialize();
#endif
int ret = Catch::Session().run( argc, argv );
#if ISPTR_USE_PYTHON
if (Py_FinalizeEx() < 0) {
return 120;
}
#endif
return ret;
}

0 comments on commit 10f46d4

Please sign in to comment.