Bugfix for test harness with bad characters in hostname string:

Using a pre-existing CTest command option for removing such characters.
Just a cleaner implementation for this bugfix.
This commit is contained in:
Martin Beaudoin 2018-04-16 00:10:22 -04:00
parent 2adbd0457a
commit 14c43b4728
2 changed files with 4 additions and 8 deletions

View file

@ -52,18 +52,16 @@ function(GetHostName var)
execute_process(
COMMAND hostname
OUTPUT_VARIABLE thisHostname
OUTPUT_STRIP_TRAILING_WHITESPACE
)
else()
execute_process(
COMMAND hostname -f
OUTPUT_VARIABLE thisHostname
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
# Cleanup possible presence of \n or \r characters
string(REPLACE "\n" "" thisHostname ${thisHostname})
string(REPLACE "\r" "" thisHostname ${thisHostname})
set(${var} ${thisHostname} PARENT_SCOPE)
endfunction()

View file

@ -52,18 +52,16 @@ function(GetHostName var)
execute_process(
COMMAND hostname
OUTPUT_VARIABLE thisHostname
OUTPUT_STRIP_TRAILING_WHITESPACE
)
else()
execute_process(
COMMAND hostname -f
OUTPUT_VARIABLE thisHostname
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
# Cleanup possible presence of \n or \r characters
string(REPLACE "\n" "" thisHostname ${thisHostname})
string(REPLACE "\r" "" thisHostname ${thisHostname})
set(${var} ${thisHostname} PARENT_SCOPE)
endfunction()