summaryrefslogtreecommitdiffstats
path: root/Tests/Module/GenerateExportHeader/exportheader_test.cpp
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-12-11 00:01:50 (GMT)
committerStephen Kelly <steveire@gmail.com>2013-12-15 10:22:19 (GMT)
commit4017db13aa54527e979f80f059b9aab1b344734e (patch)
treeac32315a438fd81911dc859a7abecb971a20b590 /Tests/Module/GenerateExportHeader/exportheader_test.cpp
parenta2489ce49c0cbf5582a29ef8c4a0d9728994f465 (diff)
downloadCMake-4017db13aa54527e979f80f059b9aab1b344734e.zip
CMake-4017db13aa54527e979f80f059b9aab1b344734e.tar.gz
CMake-4017db13aa54527e979f80f059b9aab1b344734e.tar.bz2
Speed up the GenerateExportHeader unit test (#14453).
Instead of running many small tests with many cmake projects, simply compare the generated export header against a reference. Remove the helper macros and the try_compiles which are duplicates of the library build tests.
Diffstat (limited to 'Tests/Module/GenerateExportHeader/exportheader_test.cpp')
-rw-r--r--Tests/Module/GenerateExportHeader/exportheader_test.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/Tests/Module/GenerateExportHeader/exportheader_test.cpp b/Tests/Module/GenerateExportHeader/exportheader_test.cpp
index 55c3c1a..146374a 100644
--- a/Tests/Module/GenerateExportHeader/exportheader_test.cpp
+++ b/Tests/Module/GenerateExportHeader/exportheader_test.cpp
@@ -11,6 +11,52 @@
#define DOES_NOT_BUILD(function) function
#endif
+#include <fstream>
+#include <iostream>
+#include <stdlib.h>
+#include <string>
+
+void compare(const char* refName, const char* testName)
+{
+ std::ifstream ref;
+ ref.open(refName);
+ if (!ref.is_open())
+ {
+ std::cout << "Could not open \"" << refName << "\"." << std::endl;
+ exit(1);
+ }
+ std::ifstream test;
+ test.open(testName);
+ if (!test.is_open())
+ {
+ std::cout << "Could not open \"" << testName << "\"." << std::endl;
+ exit(1);
+ }
+
+ while (!ref.eof() && !test.eof())
+ {
+ std::string refLine;
+ std::string testLine;
+ std::getline(ref, refLine);
+ std::getline(test, testLine);
+ if (testLine.size() && testLine[testLine.size()-1] == ' ')
+ {
+ testLine = testLine.substr(0, testLine.size() - 1);
+ }
+ if (refLine != testLine)
+ {
+ std::cout << "Ref and test are not the same:\n Ref: \""
+ << refLine << "\"\n Test: \"" << testLine << "\"\n";
+ exit(1);
+ }
+ }
+ if (!ref.eof() || !test.eof())
+ {
+ std::cout << "Ref and test have differing numbers of lines.";
+ exit(1);
+ }
+}
+
int main()
{
{
@@ -78,5 +124,13 @@ int main()
libstatic_not_exported();
libstatic_excluded();
+#define STRINGIFY_IMPL(A) #A
+#define STRINGIFY(A) STRINGIFY_IMPL(A)
+
+ compare(STRINGIFY(SRC_DIR) "/libshared_export.h",
+ STRINGIFY(BIN_DIR) "/libshared/libshared_export.h");
+ compare(STRINGIFY(SRC_DIR) "/libstatic_export.h",
+ STRINGIFY(BIN_DIR) "/libstatic/libstatic_export.h");
+
return 0;
}