Skip to content

Commit 736e2f6

Browse files
committed
ts: use cmake EVAL CODE in install_test_cmake
Signed-off-by: Xavier Delaruelle <[email protected]>
1 parent c1b4ca1 commit 736e2f6

File tree

2 files changed

+17
-61
lines changed

2 files changed

+17
-61
lines changed

testsuite/bin/install_test_cmake

Lines changed: 16 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ include(${initfile})
2828

2929
# execute command list
3030
set(code 0)
31-
set(runml 0)
31+
set(func "module")
3232
string(REPLACE ":" ";" cmdsplit "${cmdlist}")
3333
# empty command list, means one empty command
3434
list (LENGTH cmdlist cmdcnt)
@@ -38,70 +38,26 @@ else()
3838
foreach(cmd ${cmdsplit})
3939
# call ml procedure instead of module
4040
if("${cmd}" STREQUAL "ml")
41-
set(runml 1)
42-
# if command equals to NOARG string, means call with no arg passed
43-
elseif("${cmd}" STREQUAL "NOARG")
44-
if (${runml} EQUAL 0)
45-
module()
46-
else()
47-
ml()
48-
endif()
41+
set(func "ml")
4942
else()
50-
string(REPLACE "," ";" cmdelt "${cmd}")
51-
list (LENGTH cmdelt eltcnt)
52-
if(${eltcnt} GREATER 4)
53-
list(GET cmdelt 0 elt0)
54-
list(GET cmdelt 1 elt1)
55-
list(GET cmdelt 2 elt2)
56-
list(GET cmdelt 3 elt3)
57-
list(GET cmdelt 4 elt4)
58-
if (${runml} EQUAL 0)
59-
module("${elt0}" "${elt1}" "${elt2}" "${elt3}" "${elt4}")
60-
else()
61-
ml("${elt0}" "${elt1}" "${elt2}" "${elt3}" "${elt4}")
62-
endif()
63-
elseif(${eltcnt} GREATER 3)
64-
list(GET cmdelt 0 elt0)
65-
list(GET cmdelt 1 elt1)
66-
list(GET cmdelt 2 elt2)
67-
list(GET cmdelt 3 elt3)
68-
if (${runml} EQUAL 0)
69-
module("${elt0}" "${elt1}" "${elt2}" "${elt3}")
70-
else()
71-
ml("${elt0}" "${elt1}" "${elt2}" "${elt3}")
72-
endif()
73-
elseif(${eltcnt} GREATER 2)
74-
list(GET cmdelt 0 elt0)
75-
list(GET cmdelt 1 elt1)
76-
list(GET cmdelt 2 elt2)
77-
if (${runml} EQUAL 0)
78-
module("${elt0}" "${elt1}" "${elt2}")
79-
else()
80-
ml("${elt0}" "${elt1}" "${elt2}")
81-
endif()
82-
elseif(${eltcnt} GREATER 1)
83-
list(GET cmdelt 0 elt0)
84-
list(GET cmdelt 1 elt1)
85-
if (${runml} EQUAL 0)
86-
module("${elt0}" "${elt1}")
87-
else()
88-
ml("${elt0}" "${elt1}")
89-
endif()
90-
elseif(${eltcnt} GREATER 0)
91-
list(GET cmdelt 0 elt0)
92-
if (${runml} EQUAL 0)
93-
module("${elt0}")
94-
else()
95-
ml("${elt0}")
96-
endif()
97-
else()
43+
set(quotedArgs "")
44+
# if command equals to NOARG string, means call with no arg passed
45+
if(NOT "${cmd}" STREQUAL "NOARG")
46+
string(REPLACE "," ";" cmdelt "${cmd}")
47+
list (LENGTH cmdelt eltcnt)
9848
# empty arg list, means one empty arg
99-
if (${runml} EQUAL 0)
100-
module("")
49+
if (${eltcnt} EQUAL 0)
50+
string(APPEND quotedArgs "\"\"")
10151
else()
102-
ml("")
52+
foreach(elt IN LISTS cmdelt)
53+
if(NOT "${quotedArgs}" STREQUAL "")
54+
string(APPEND quotedArgs " ")
55+
endif()
56+
string(APPEND quotedArgs "[===[${elt}]===]")
57+
endforeach()
10358
endif()
10459
endif()
60+
cmake_language(EVAL CODE "${func}(${quotedArgs})")
10561
endif()
10662
if(NOT module_result AND NOT ${module_result} STREQUAL "")
10763
set(code 1)

testsuite/install.00-init/080-args.exp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ foreach shell $othlang_list {
103103
set postmsg "\nError: \nExecution halted"
104104
}
105105
cmake {
106-
set postmsg "\nCMake Error at testsuite/bin/install_test_cmake:115 \\\(message\\\):\n\n"
106+
set postmsg "\nCMake Error at testsuite/bin/install_test_cmake:71 \\\(message\\\):\n\n"
107107
}
108108
default {
109109
set postmsg {}

0 commit comments

Comments
 (0)