Skip to content

Commit 177a927

Browse files
hodoulppatlefortremia
authored
Fix add_test calls and change temporary file creation. (#1522) (#1534)
* * Fix add_test in cmake files. This notation allows it to understand that the command portion is a target and to translate it to the proper executable. * Remove starting backslash if present from temporary filename. A starting backslash mean that it is safe to create it in the current working directory. * Implement a public TempFile class. * Change relevant tests to use TempFile class. Signed-off-by: Patrick Northon <[email protected]> * * Revert back changes for TempFile class. * Add comment on temporary file functions fix. Signed-off-by: Patrick Northon <[email protected]> * Add FIXME comments. Signed-off-by: Patrick Northon <[email protected]> * Add -C flag to ctest commands. Signed-off-by: Patrick Northon <[email protected]> * Add `-C Release` to ctest commands in `analysis_workflow.yml`. Signed-off-by: Patrick Northon <[email protected]> Co-authored-by: Patrick Hodoul <[email protected]> Co-authored-by: Rémi Achard <[email protected]> Signed-off-by: Patrick Hodoul <[email protected]> Co-authored-by: patlefort <[email protected]> Co-authored-by: Rémi Achard <[email protected]>
1 parent a64e4d5 commit 177a927

File tree

10 files changed

+18
-12
lines changed

10 files changed

+18
-12
lines changed

.github/workflows/analysis_workflow.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ jobs:
122122
-- -j$(nproc)
123123
working-directory: _build
124124
- name: Test
125-
run: ctest -V
125+
run: ctest -V -C Release
126126
working-directory: _build
127127

128128
# ---------------------------------------------------------------------------
@@ -174,7 +174,7 @@ jobs:
174174
run: build-wrapper-linux-x86-64 --out-dir bw_output make clean all
175175
working-directory: _build
176176
- name: Test
177-
run: ctest -V
177+
run: ctest -V -C Release
178178
working-directory: _build
179179
- name: Generate code coverage report
180180
run: share/ci/scripts/linux/run_gcov.sh

.github/workflows/ci_workflow.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ jobs:
271271
-- -j$(nproc)
272272
working-directory: _build
273273
- name: Test
274-
run: ctest -V
274+
run: ctest -V -C ${{ matrix.build-type }}
275275
working-directory: _build
276276
- name: Test CMake Consumer
277277
if: matrix.build-shared == 'ON'
@@ -407,7 +407,7 @@ jobs:
407407
-- -j$(sysctl -n hw.ncpu)
408408
working-directory: _build
409409
- name: Test
410-
run: ctest -V
410+
run: ctest -V -C ${{ matrix.build-type }}
411411
working-directory: _build
412412
- name: Test CMake Consumer
413413
if: matrix.build-shared == 'ON'
@@ -549,7 +549,7 @@ jobs:
549549
shell: bash
550550
working-directory: _build
551551
- name: Test
552-
run: ctest -V
552+
run: ctest -V -C ${{ matrix.build-type }}
553553
shell: bash
554554
working-directory: _build
555555
- name: Test CMake Consumer

src/OpenColorIO/Platform.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,9 @@ std::string CreateTempFilename(const std::string & filenameExt)
225225
throw Exception("Could not create a temporary file.");
226226
}
227227

228-
filename = tmpFilename;
228+
// Note that when a file name is pre-pended with a backslash and no path information, such as \fname21, this
229+
// indicates that the name is valid for the current working directory.
230+
filename = tmpFilename[0] == '\\' ? tmpFilename + 1 : tmpFilename;
229231

230232
#else
231233

src/OpenColorIO/Platform.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ void AlignedFree(void * memBlock);
8686
// Note: Temporary files should be at some point deleted by the OS (depending of the OS
8787
// and various platform specific settings). To be safe, add some code to remove
8888
// the file if created.
89+
// FIXME: Implement a function or class for temporary file creation useable by all tests.
8990
std::string CreateTempFilename(const std::string & filenameExt);
9091

9192
// Create an input file stream (std::ifstream) using a UTF-8 filename on any platform.

tests/cpu/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function(add_ocio_test NAME SOURCES PRIVATE_INCLUDES)
6666
set_target_properties(${TEST_BINARY} PROPERTIES
6767
COMPILE_FLAGS "${PLATFORM_COMPILE_FLAGS}")
6868

69-
add_test(${TEST_NAME} ${TEST_BINARY})
69+
add_test(NAME ${TEST_NAME} COMMAND ${TEST_BINARY})
7070
endfunction(add_ocio_test)
7171

7272
# Eventually we will factor out each test into it's own executable

tests/gpu/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ target_link_libraries(test_gpu_exec
5050
unittest_data
5151
)
5252

53-
add_test(test_gpu test_gpu_exec)
53+
add_test(NAME test_gpu COMMAND test_gpu_exec)
5454

5555
# Note: To avoid changing PATH from outside the cmake files.
5656
if(MSVC AND BUILD_SHARED_LIBS)

tests/gpu/GPUHelpers.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ std::string createTempFile(const std::string& fileExt, const std::string& fileCo
3434
throw OCIO::Exception("Could not create a temporary file");
3535
}
3636

37-
filename = tmpFilename;
37+
// Note that when a file name is pre-pended with a backslash and no path information, such as \fname21, this
38+
// indicates that the name is valid for the current working directory.
39+
filename = tmpFilename[0] == '\\' ? tmpFilename + 1 : tmpFilename;
3840
filename += fileExt;
3941

4042
#else

tests/gpu/GPUHelpers.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
#include <string>
1010

11-
11+
// FIXME: Duplicate function implemented in `src/OpenColorIO/Platform.h and cpp`.
12+
// Implement a function or class for temporary file creation useable by all tests.
1213
std::string createTempFile(const std::string& fileExt, const std::string& fileContent);
1314

1415

tests/osl/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ target_link_libraries(test_osl_exec
4242
OpenImageIO::OpenImageIO
4343
)
4444

45-
add_test(test_osl test_osl_exec)
45+
add_test(NAME test_osl COMMAND test_osl_exec)
4646

4747
list(APPEND ENVS "OSL_SHADERS_DIR=${OSL_SHADERS_DIR}")
4848
list(APPEND ENVS "TMP_SHADERS_DIR=${CMAKE_CURRENT_BINARY_DIR}")

tests/utils/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ target_link_libraries(test_utils_exec
2424
set_target_properties(test_utils_exec PROPERTIES
2525
COMPILE_FLAGS "${PLATFORM_COMPILE_FLAGS}")
2626

27-
add_test(test_utils_exec test_utils_exec)
27+
add_test(NAME test_utils_exec COMMAND test_utils_exec)

0 commit comments

Comments
 (0)