<!DOCTYPE html>
<html data-lt-installed="true">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body style="padding-bottom: 1px;">
<p>Hi, Sergey,</p>
<p>thanks for the patch! See comments below.<br>
</p>
<div class="moz-cite-prefix">On 23.09.2024 10:18, Sergey Kaplun
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:ad488f5df41ab008ff0596ea61a2bdc7451439e8.1727074292.git.skaplun@tarantool.org">
<pre class="moz-quote-pre" wrap="">It is useful to update the environment variable for some tests. For
CMake versions >= 3.22, we can use ENVIRONMENT_MODIFICATION [1] instead.
But unless we bump the CMake version, this macro is a workaround.
[1]: <a class="moz-txt-link-freetext" href="https://cmake.org/cmake/help/latest/prop_test/ENVIRONMENT_MODIFICATION.html">https://cmake.org/cmake/help/latest/prop_test/ENVIRONMENT_MODIFICATION.html</a>
Part of tarantool/tarantool#9898
---
test/tarantool-tests/CMakeLists.txt | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/test/tarantool-tests/CMakeLists.txt b/test/tarantool-tests/CMakeLists.txt
index 11a84496..4530c9fd 100644
--- a/test/tarantool-tests/CMakeLists.txt
+++ b/test/tarantool-tests/CMakeLists.txt
@@ -18,6 +18,29 @@ macro(BuildTestCLib lib sources)
set(LD_LIBRARY_PATH "${CMAKE_CURRENT_BINARY_DIR}:${LD_LIBRARY_PATH}" PARENT_SCOPE)
endmacro()
+# FIXME: This is used only due to ancient CMake requirements.
+# If we update to CMake >= 3.22, we can use
+# ENVIRONMENT_MODIFICATION [1] instead.
+# [1]: <a class="moz-txt-link-freetext" href="https://cmake.org/cmake/help/latest/prop_test/ENVIRONMENT_MODIFICATION.html">https://cmake.org/cmake/help/latest/prop_test/ENVIRONMENT_MODIFICATION.html</a></pre>
</blockquote>
I would add a small description for a macro.<br>
<blockquote type="cite"
cite="mid:ad488f5df41ab008ff0596ea61a2bdc7451439e8.1727074292.git.skaplun@tarantool.org">
<pre class="moz-quote-pre" wrap="">
+macro(AppendTestEnvVar testname var value)</pre>
</blockquote>
<p>I would rename macro to something like "ModifyTestEnv"</p>
<p>because it appends env var when variable with the same name was
not found</p>
<p>and modifies it when variable exist.</p>
<br>
<blockquote type="cite"
cite="mid:ad488f5df41ab008ff0596ea61a2bdc7451439e8.1727074292.git.skaplun@tarantool.org">
<pre class="moz-quote-pre" wrap="">
+ get_test_property(${testname} ENVIRONMENT old_env)
+ foreach(loopvar "${old_env}")
+ if(loopvar MATCHES "^${var}=(.*)")
+ set(envvar_found TRUE)
+ set(loopvar "${var}=${value}${CMAKE_MATCH_1}")
+ endif()
+ list(APPEND new_env "${loopvar}")
+ endforeach()
+ if(NOT "${envvar_found}")
+ list(APPEND new_env "${var}=${value}")
+ endif()
+ set_tests_properties(${testname} PROPERTIES ENVIRONMENT "${new_env}")
+
+ unset(envvar_found)
+ unset(old_env)
+ unset(new_env)
+endmacro()
+
add_subdirectory(ffi-ccall)
add_subdirectory(fix-bit-shift-generation)
add_subdirectory(gh-4427-ffi-sandwich)
</pre>
</blockquote>
</body>
<lt-container></lt-container>
</html>