summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/GenerateExportHeader
diff options
context:
space:
mode:
authorOrgad Shaneh <orgads@gmail.com>2021-04-01 17:03:52 (GMT)
committerBrad King <brad.king@kitware.com>2021-04-26 18:27:34 (GMT)
commitddcd1469e8377fe258913a20aa47e65f71f8695b (patch)
treed18b6561383a8f4bc206dac848a15814b74ca642 /Tests/RunCMake/GenerateExportHeader
parentb3ca4f9ad18220b2f56cd6af7df5cf1e671d39a8 (diff)
downloadCMake-ddcd1469e8377fe258913a20aa47e65f71f8695b.zip
CMake-ddcd1469e8377fe258913a20aa47e65f71f8695b.tar.gz
CMake-ddcd1469e8377fe258913a20aa47e65f71f8695b.tar.bz2
MSYS: Add support for running under MSYS runtime environment
Detect MSYS as CYGWIN, with the required adaptations.
Diffstat (limited to 'Tests/RunCMake/GenerateExportHeader')
-rw-r--r--Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp b/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp
index dcaa4f2..ed8c35e 100644
--- a/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp
+++ b/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp
@@ -8,6 +8,14 @@
#include "libshared.h"
#include "libstatic.h"
+static void rtrim(std::string& str, char byte)
+{
+ const std::size_t size = str.size();
+ if (size && str[size - 1] == byte) {
+ str.resize(size - 1);
+ }
+}
+
void compare(const char* refName, const char* testName)
{
std::ifstream ref;
@@ -31,16 +39,14 @@ void compare(const char* refName, const char* testName)
// Some very old Borland runtimes (C++ Builder 5 WITHOUT Update 1) add a
// trailing null to the string that we need to strip before testing for a
// trailing space.
- if (refLine.size() && refLine[refLine.size() - 1] == 0) {
- refLine.resize(refLine.size() - 1);
- }
- if (testLine.size() && testLine[testLine.size() - 1] == 0) {
- testLine.resize(testLine.size() - 1);
- }
+ rtrim(refLine, 0);
+ rtrim(testLine, 0);
// The reference files never have trailing spaces:
- if (testLine.size() && testLine[testLine.size() - 1] == ' ') {
- testLine.resize(testLine.size() - 1);
- }
+ rtrim(testLine, ' ');
+ // Strip trailing CR. LF is not returned by getline, but CR is returned
+ // on some platforms.
+ rtrim(refLine, '\r');
+ rtrim(testLine, '\r');
if (refLine != testLine) {
std::cout << "Ref and test are not the same:\n Ref: \"" << refLine
<< "\"\n Test: \"" << testLine << "\"\n";