From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 7BA63EA8231; Tue, 24 Sep 2024 14:08:03 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7BA63EA8231 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1727176083; bh=lcXGO2U/zEmB0s0fB8cA9jSK+x55WSAdPTgb7XExw54=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=TsYI9Y8H79gvicadxu99d2YZcTpXPSFk2YCy5VBReuRQ6T372AsprNZWViMiBpui2 xKjvsc7DlibiIidNZdGifgvm+jwW+DJqWq8E2JjJ5f0M3o0zuhjfFJt2+8ftr1ScoX 7tdQnXDa+xyVv7NoPwKVVa7+vmdXzaOjPSzuy1T8= Received: from smtp53.i.mail.ru (smtp53.i.mail.ru [95.163.41.90]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 4A5B6EA8200 for ; Tue, 24 Sep 2024 14:07:57 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4A5B6EA8200 Received: by smtp53.i.mail.ru with esmtpa (envelope-from ) id 1st3Oe-000000037J8-1qQl; Tue, 24 Sep 2024 14:07:56 +0300 Content-Type: multipart/alternative; boundary="------------TSlil3pzNOmC08DrpVN6fqQF" Message-ID: Date: Tue, 24 Sep 2024 14:07:56 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Sergey Kaplun , Maxim Kokryashkin Cc: tarantool-patches@dev.tarantool.org References: In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD968D81A599CAF0ABB2409C8D41EAF75A5EEC3640FF91A1832182A05F5380850402BA856C96A5AD613A6D5EE0DB6E1EC8DD3BA53426FC0DF4ABA1C620C1488912C810A56970F496ED6 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE77E5C269A77776DF2EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637D636C6B786B38B6A8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8E11E2209D076E7E3A107BEF57730041522D704D40D61A59FCC7F00164DA146DAFE8445B8C89999728AA50765F7900637F924B32C592EA89F389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC897AD43380FEE24CAF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947C4E7D9683544204AF6E0066C2D8992A164AD6D5ED66289B523666184CF4C3C14F6136E347CC761E07725E5C173C3A84C3B74263D4D5690889BA3038C0950A5D36B5C8C57E37DE458B330BD67F2E7D9AF16D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE74F0F518E68DBD4F843847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A53783F3DB314B8A2B5002B1117B3ED6962618ADDDF90231E8D57BAD45EC4C5DE1823CB91A9FED034534781492E4B8EEAD21D4E6D365FE45D1BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF151DF9F4E9714A82B1D32C3E2DF4251FB1BE4CB78D6ACE62D150665E9721CF59DCB9935FD7D73207A4322FFB9F042FEF83F5760AC2882A9F59C9D00A60233BA3A450B0008B3AD2995F4332CA8FE04980913E6812662D5F2AB9AF64DB4688768036DF5FE9C0001AF333F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojamSMdo1tbG97MIvR5k35qg== X-Mailru-Sender: 520A125C2F17F0B1E52FEF5D219D61406F4094FED3D257285128132E2D9E07690DD0DFF25D80C0720152A3D17938EB451EB5A0BCEC6A560B3DDE9B364B0DF289BE2DA36745F2EEB5CEBA01FB949A1F1EEAB4BC95F72C04283CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v2 luajit 3/7] cmake: introduce AppendTestEnvVar macro X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This is a multi-part message in MIME format. --------------TSlil3pzNOmC08DrpVN6fqQF Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, Sergey LGTM On 24.09.2024 13:29, Sergey Kaplun wrote: > 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]:https://cmake.org/cmake/help/latest/prop_test/ENVIRONMENT_MODIFICATION.html > > Part of tarantool/tarantool#9898 > --- > test/tarantool-tests/CMakeLists.txt | 28 ++++++++++++++++++++++++++++ > 1 file changed, 28 insertions(+) > > diff --git a/test/tarantool-tests/CMakeLists.txt b/test/tarantool-tests/CMakeLists.txt > index 11a84496..ff402dc0 100644 > --- a/test/tarantool-tests/CMakeLists.txt > +++ b/test/tarantool-tests/CMakeLists.txt > @@ -18,6 +18,34 @@ 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]:https://cmake.org/cmake/help/latest/prop_test/ENVIRONMENT_MODIFICATION.html > +# This macro appends to the given test's environment variable the > +# given value. If the variable doesn't exist, it is created equal > +# to the given argument. > +macro(AppendTestEnvVar testname var value) > + get_test_property(${testname} ENVIRONMENT old_env) > + foreach(loopvar ${old_env}) > + # XXX: `foreach()` unescapes ";" in string, escape them back. > + string(REPLACE ";" "\;" loopvar "${loopvar}") > + 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) --------------TSlil3pzNOmC08DrpVN6fqQF Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

Hi, Sergey


LGTM

On 24.09.2024 13:29, Sergey Kaplun wrote:
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]: https://cmake.org/cmake/help/latest/prop_test/ENVIRONMENT_MODIFICATION.html

Part of tarantool/tarantool#9898
---
 test/tarantool-tests/CMakeLists.txt | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/test/tarantool-tests/CMakeLists.txt b/test/tarantool-tests/CMakeLists.txt
index 11a84496..ff402dc0 100644
--- a/test/tarantool-tests/CMakeLists.txt
+++ b/test/tarantool-tests/CMakeLists.txt
@@ -18,6 +18,34 @@ 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]: https://cmake.org/cmake/help/latest/prop_test/ENVIRONMENT_MODIFICATION.html
+# This macro appends to the given test's environment variable the
+# given value. If the variable doesn't exist, it is created equal
+# to the given argument.
+macro(AppendTestEnvVar testname var value)
+  get_test_property(${testname} ENVIRONMENT old_env)
+  foreach(loopvar ${old_env})
+    # XXX: `foreach()` unescapes ";" in string, escape them back.
+    string(REPLACE ";" "\;" loopvar "${loopvar}")
+    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)
--------------TSlil3pzNOmC08DrpVN6fqQF--