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 BE4CEC9EDC1; Mon, 23 Sep 2024 10:51:41 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org BE4CEC9EDC1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1727077901; bh=uLewhju36T0KZMyAxXAGtWCLj/PBSmr6kdKaqfC21cE=; 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=bwu3TMuyNeRfqdcyr3/yiQVWrlzk8JJu35PqS07O/shoRu9h/OGRDp73gyUYzuL/p BSuFW+02jMPKVWs37oLz8myK7xbpF89gcd+wMxm6Gq9gsQFsuo2cAzc8YklUEqdAqc 9bdJ8BiC9vX/RfIlndZbkIUA2hkcTHnDHtisDzK4= Received: from smtp43.i.mail.ru (smtp43.i.mail.ru [95.163.41.66]) (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 6C3DCC9EDC1 for ; Mon, 23 Sep 2024 10:51:40 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6C3DCC9EDC1 Received: by smtp43.i.mail.ru with esmtpa (envelope-from ) id 1ssdr9-0000000HBkq-1RMc; Mon, 23 Sep 2024 10:51:39 +0300 Content-Type: multipart/alternative; boundary="------------E7QGC45fvOZVaAwui8v31KGD" Message-ID: <329f67f8-a7b7-4753-96e2-bbc4f2574de3@tarantool.org> Date: Mon, 23 Sep 2024 10:51:39 +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: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD96E52E9D942F25A5FFB5298A2356FE39D3E08E4B42EB1EF1300894C459B0CD1B92B5B57C8613B33DB3B57D43774AF49B25FFBF618E8A41AE1853BC932A38E5C9609DF98A5C5F6EC85 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE705B79473340BE836C2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6778DA827A17800CE743AE26858062A689EA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38B043BF0FB74779F365B1E904B3B8C20713E677F275A81BB0D806CE8493E1D6C83A471835C12D1D9774AD6D5ED66289B5278DA827A17800CE71AE4D56B06699BBC9FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C390BCC82C2C62A6D1117882F4460429728AD0CFFFB425014E868A13BD56FB6657D81D268191BDAD3DC09775C1D3CA48CF0E073B7150C52A2EBA3038C0950A5D36C8A9BA7A39EFB766D91E3A1F190DE8FDBA3038C0950A5D36D5E8D9A59859A8B60F784CBF0D2551B676E601842F6C81A1F004C906525384303E02D724532EE2C3F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7CA60C52B68663E2D543847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A58DFBCEAC097045705002B1117B3ED6960B0A5AC4DBAA7283C89B063BDC7FAC35823CB91A9FED034534781492E4B8EEADD0953842B444AAC3BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF3AB639B84164491CD1597EDC7C4D00EF28CEEB7CFEF7F6518EED21990C06DA5D6DD3C4C1BE61872BFD4E6A0B424C2B4874A77023F94D77A19C0AE0A861E0A52B1C6BDF94B66197A65F4332CA8FE04980913E6812662D5F2AB9AF64DB4688768036DF5FE9C0001AF333F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojcsBYxvRMKexMeLTe7kfS9w== X-Mailru-Sender: 520A125C2F17F0B1E52FEF5D219D61402B5B57C8613B33DB3B57D43774AF49B28E8C7A96B889FDC70152A3D17938EB451EB5A0BCEC6A560B3DDE9B364B0DF289BE2DA36745F2EEB5CEBA01FB949A1F1EEAB4BC95F72C04283CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH 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. --------------E7QGC45fvOZVaAwui8v31KGD Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, Sergey, thanks for the patch! See comments below. On 23.09.2024 10:18, 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 | 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]:https://cmake.org/cmake/help/latest/prop_test/ENVIRONMENT_MODIFICATION.html I would add a small description for a macro. > +macro(AppendTestEnvVar testname var value) I would rename macro to something like "ModifyTestEnv" because it appends env var when variable with the same name was not found and modifies it when variable exist. > + 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) --------------E7QGC45fvOZVaAwui8v31KGD Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

Hi, Sergey,

thanks for the patch! See comments below.

On 23.09.2024 10:18, 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 | 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]: https://cmake.org/cmake/help/latest/prop_test/ENVIRONMENT_MODIFICATION.html
I would add a small description for a macro.
+macro(AppendTestEnvVar testname var value)

I would rename macro to something like "ModifyTestEnv"

because it appends env var when variable with the same name was not found

and modifies it when variable exist.


+  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)
--------------E7QGC45fvOZVaAwui8v31KGD--