Skip to content

Commit 876ccbe

Browse files
authored
Configuration - Add support for Google Test framework in CMake Open-Cascade-SAS#443
Enhance Google Test integration and add support for test projects. Each Toolkit have GTests folder with place for new tests. For adding new tests needs to extend FILES.cmake files in each GTests folder. The single executable is created for each toolkit with all tests. The tests grouped by module and toolkit with :: as separator. Added option to download GTest by Cmake if not found. Add GTest for PLib_JacobiPolynomial with comprehensive test cases Add GTest for TCollection_AsciiString and TCollection_ExtendedString Set C++ standard to C++14 for GTest compatibility if required
1 parent 986af18 commit 876ccbe

File tree

82 files changed

+1596
-15
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1596
-15
lines changed

.github/actions/run-gtest/action.yml

+145
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
name: 'Run GTest Validation'
2+
description: 'Execute GTest suite and validate results'
3+
4+
inputs:
5+
platform:
6+
description: 'Platform (windows, macos, linux)'
7+
required: true
8+
compiler:
9+
description: 'Compiler (msvc, clang, gcc)'
10+
required: true
11+
install-artifact-name:
12+
description: 'Name of the artifact containing the installed files'
13+
required: true
14+
artifact-suffix:
15+
description: 'Suffix for the GTest results artifact name'
16+
required: true
17+
default: 'x64'
18+
19+
outputs:
20+
has-failures:
21+
description: 'Whether any tests failed'
22+
value: ${{ steps.check-failures.outputs.has_failures }}
23+
24+
runs:
25+
using: "composite"
26+
steps:
27+
- name: Download and extract install directory
28+
uses: actions/[email protected]
29+
with:
30+
name: ${{ inputs.install-artifact-name }}
31+
path: install
32+
33+
- name: Download and extract 3rdparty dependencies for Windows
34+
if: inputs.platform == 'windows'
35+
shell: pwsh
36+
run: |
37+
Invoke-WebRequest -Uri https://github.com/Open-Cascade-SAS/OCCT/releases/download/V7_9_0_beta1/3rdparty-vc14-64.zip -OutFile 3rdparty-vc14-64.zip
38+
Expand-Archive -Path 3rdparty-vc14-64.zip -DestinationPath .
39+
Remove-Item 3rdparty-vc14-64.zip
40+
41+
- name: Install macOS dependencies
42+
if: inputs.platform == 'macos'
43+
shell: bash
44+
run: |
45+
brew update
46+
brew install tcl-tk tbb gl2ps xerces-c \
47+
libxmu libxi libxft libxpm \
48+
glew freeimage draco glfw
49+
50+
- name: Install Linux dependencies
51+
if: inputs.platform == 'linux'
52+
shell: bash
53+
run: |
54+
sudo apt-get update && sudo apt-get install -y tcl-dev tk-dev cmake clang make libbtbb-dev libx11-dev libglu1-mesa-dev tcllib tcl-thread tcl libvtk9-dev libopenvr-dev libdraco-dev libfreeimage-dev libegl1-mesa-dev libgles2-mesa-dev libfreetype-dev
55+
56+
- name: Setup Xvfb and Mesa for Linux
57+
if: inputs.platform == 'linux'
58+
uses: ./.github/actions/setup-xvfb-mesa
59+
60+
- name: Set execute permissions on Unix platforms
61+
if: inputs.platform != 'windows'
62+
shell: bash
63+
run: |
64+
chmod +x install/bin/OpenCascadeGTest
65+
66+
- name: Run OpenCascadeGTest on Windows
67+
if: inputs.platform == 'windows'
68+
id: run-gtest-windows
69+
shell: cmd
70+
run: |
71+
cd install
72+
call env.bat ${{ inputs.compiler == 'msvc' && 'vc14' || 'clang' }} win64 release
73+
cd bin
74+
set GTEST_OUTPUT=""
75+
OpenCascadeGTest.exe --gtest_output=xml:gtest_results.xml > gtest_output.log 2>&1
76+
type gtest_output.log
77+
exit /b 0
78+
79+
- name: Run OpenCascadeGTest on Unix platforms
80+
if: inputs.platform != 'windows'
81+
id: run-gtest-unix
82+
shell: bash
83+
env:
84+
DISPLAY: ${{ inputs.platform == 'linux' && ':99' || '' }}
85+
LIBGL_ALWAYS_SOFTWARE: 1
86+
run: |
87+
cd install/bin
88+
source env.sh
89+
./OpenCascadeGTest --gtest_output=xml:gtest_results.xml > gtest_output.log 2>&1
90+
cat gtest_output.log
91+
92+
- name: Upload GTest results
93+
uses: actions/[email protected]
94+
with:
95+
name: gtest-results-${{ inputs.platform }}-${{ inputs.compiler }}-${{ inputs.artifact-suffix }}
96+
path: |
97+
install/bin/gtest_results.xml
98+
install/bin/gtest_output.log
99+
retention-days: 15
100+
101+
- name: Check for test failures on Windows
102+
if: inputs.platform == 'windows'
103+
id: check-failures-windows
104+
shell: pwsh
105+
run: |
106+
cd install/bin
107+
$log = Get-Content "gtest_output.log" -Raw
108+
if ($log -match "\[\s+FAILED\s+\]") {
109+
Write-Error "GTest failures detected in the output."
110+
echo "has_failures=true" >> $env:GITHUB_OUTPUT
111+
} else {
112+
Write-Output "No GTest failures detected."
113+
echo "has_failures=false" >> $env:GITHUB_OUTPUT
114+
}
115+
116+
- name: Check for test failures on Unix
117+
if: inputs.platform != 'windows'
118+
id: check-failures-unix
119+
shell: bash
120+
run: |
121+
cd install/bin
122+
if grep -q "\[ FAILED \]" gtest_output.log; then
123+
echo "::error::GTest failures detected in the output."
124+
echo "has_failures=true" >> $GITHUB_OUTPUT
125+
else
126+
echo "No GTest failures detected."
127+
echo "has_failures=false" >> $GITHUB_OUTPUT
128+
fi
129+
130+
- name: Set combined output
131+
id: check-failures
132+
shell: bash
133+
run: |
134+
if [ "${{ inputs.platform }}" == "windows" ]; then
135+
echo "has_failures=${{ steps.check-failures-windows.outputs.has_failures }}" >> $GITHUB_OUTPUT
136+
else
137+
echo "has_failures=${{ steps.check-failures-unix.outputs.has_failures }}" >> $GITHUB_OUTPUT
138+
fi
139+
140+
- name: Fail job if tests failed
141+
if: steps.check-failures.outputs.has_failures == 'true'
142+
shell: bash
143+
run: |
144+
echo "::error::GTest failures detected"
145+
exit 1

0 commit comments

Comments
 (0)