Skip to content

Commit 003b029

Browse files
committed
tests: Validate call line in generated launcher script
Ensure the launcher batch file invokes the correct command by parsing and checking the `call` line. Validate expected architecture (`x86` or `x64`) and optional `-vcvars_ver` when using `vcvarsall.bat`. Improves coverage of wrapper generation logic.
1 parent 091adfa commit 003b029

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

tests/CMakeLists.txt

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ if(FUNCTIONS_ONLY_COMPONENT_REQUESTED)
233233
check_var_not_defined("Vcvars_MSVC_ARCH")
234234
check_var_not_defined("Vcvars_MSVC_VERSION")
235235
check_var_not_defined("Vcvars_PLATFORM_TOOLSET_VERSION")
236-
check_var_not_defined("Vcvars_LAUNCHER")
236+
check_var_not_defined("Vcvars_BATCH_FILE")
237237
check_var_not_defined("Vcvars_LAUNCHER")
238238
else()
239239
check_var_equals("Vcvars_FIND_VCVARSALL" "${EXPECTED_FIND_VCVARSALL}")
@@ -246,6 +246,30 @@ else()
246246

247247
check_file_exists("Vcvars_LAUNCHER")
248248
check_filename_matches("Vcvars_LAUNCHER" "${EXPECTED_LAUNCHER_FILENAME}")
249+
250+
# Extract and validate the call to vcvars batch script in the generated wrapper
251+
file(STRINGS ${Vcvars_LAUNCHER} _call REGEX "^call")
252+
list(GET _call 0 _call) # Ensure only the first match is considered
253+
string(STRIP "${_call}" _call)
254+
255+
if(Vcvars_FIND_VCVARSALL)
256+
if(Vcvars_MSVC_ARCH STREQUAL "64")
257+
set(expected_arch "x64")
258+
elseif(Vcvars_MSVC_ARCH STREQUAL "32")
259+
set(expected_arch "x86")
260+
else()
261+
set(expected_arch "")
262+
endif()
263+
set(expected_vcvars_ver "-vcvars_ver=${Vcvars_PLATFORM_TOOLSET_VERSION}")
264+
else()
265+
set(expected_arch "")
266+
set(expected_vcvars_ver "")
267+
endif()
268+
269+
set(expected_call "call \"${Vcvars_BATCH_FILE}\" ${expected_arch} ${expected_vcvars_ver}")
270+
string(STRIP "${expected_call}" expected_call)
271+
272+
check_var_equals(_call "${expected_call}")
249273
endif()
250274
]==]
251275
)

0 commit comments

Comments
 (0)