Skip to content

Commit f727280

Browse files
committed
Unit tests added in CI
1 parent 18180cc commit f727280

7 files changed

Lines changed: 16 additions & 6 deletions

File tree

‎.github/workflows/cmake-ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ jobs:
1212
name: Call Cmake reusable workflow
1313
uses: LIHPC-Computational-Geometry/lihpccg-ci/.github/workflows/cmake-reusable.yml@main
1414
with:
15-
run-tests: false
15+
run-tests: true

‎CMakeLists.txt‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,4 @@ option (BUILD_SHARED_LIBS "Creation de bibliotheques dynamiques (defaut : ON)" O
1414

1515
add_subdirectory (src)
1616

17-
18-
19-
17+
enable_testing()

‎src/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ add_subdirectory (PythonUtil)
22
add_subdirectory (PythonScriptingTest)
33
add_subdirectory (tests)
44

5+
enable_testing()

‎src/tests/CMakeLists.txt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ include (${CMAKE_SOURCE_DIR}/cmake/workarounds.cmake)
44

55
set (ALL_EXECUTABLES hello script_gen python_runner)
66

7+
enable_testing()
8+
79
find_package (TkUtilScripting)
810
foreach (exe ${ALL_EXECUTABLES})
911
add_executable (${exe} ${exe}.cpp)
@@ -17,4 +19,7 @@ foreach (exe ${ALL_EXECUTABLES})
1719
INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
1820
endforeach (exe)
1921

22+
add_test(NAME hello COMMAND $<TARGET_FILE:hello> test.py) # will create a python file
23+
add_test(NAME python_runner COMMAND $<TARGET_FILE:python_runner> test.py) # execute the file previously created
24+
add_test(NAME script_gen COMMAND $<TARGET_FILE:script_gen> sgtest.py)
2025

‎src/tests/hello.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ int main (int argc, char* argv[], char* envp [])
3232
catch (const Exception& exc)
3333
{
3434
cout << "Exception : " << exc.getFullMessage ( ) << endl;
35+
return -1;
3536
}
3637
catch (...)
3738
{
3839
cout << "Exception non documentée." << endl;
40+
return -1;
3941
}
4042

4143
return 0;

‎src/tests/python_runner.cpp‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,20 @@ int main (int argc, char* argv[], char* envp [])
3333
pySession.execFile (argv [1]);
3434

3535
cout << "Sorties du script " << argv [1] << " :" << endl << endl;
36-
UTF8String outputs (pySession.getOutputs ( ));
37-
const string str = outputs.trim ( ).iso ( );
36+
UTF8String outputs (pySession.getOutputs ( ));
37+
const string str = outputs.trim ( ).iso ( );
3838
cout << str << endl;
3939
cout << endl << "Fin des sorties du script " << argv [1] << "." << endl;
4040
}
4141
catch (const Exception& exc)
4242
{
4343
cout << "Exception : " << exc.getFullMessage ( ) << endl;
44+
return -1;
4445
}
4546
catch (...)
4647
{
4748
cout << "Exception non documentée." << endl;
49+
return -1;
4850
}
4951

5052
return 0;

‎src/tests/script_gen.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,12 @@ int main (int argc, char* argv[], char* envp [])
187187
catch (const Exception& exc)
188188
{
189189
cout << "Exception : " << exc.getFullMessage ( ) << endl;
190+
return -1;
190191
}
191192
catch (...)
192193
{
193194
cout << "Exception non documentée." << endl;
195+
return -1;
194196
}
195197

196198
return 0;

0 commit comments

Comments
 (0)