summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorKen Martin <ken.martin@kitware.com>2001-06-21 21:52:54 (GMT)
committerKen Martin <ken.martin@kitware.com>2001-06-21 21:52:54 (GMT)
commitbda5baa566ffffeda6c2dad0d2df98bbff4ca966 (patch)
treec05e118b764c6d3fd13767a8deb4614df378347b /Source
parent2b895779c2b8294b7c34272ed81674afa460808e (diff)
downloadCMake-bda5baa566ffffeda6c2dad0d2df98bbff4ca966.zip
CMake-bda5baa566ffffeda6c2dad0d2df98bbff4ca966.tar.gz
CMake-bda5baa566ffffeda6c2dad0d2df98bbff4ca966.tar.bz2
new test driver
Diffstat (limited to 'Source')
-rw-r--r--Source/cmaketest.cxx61
-rw-r--r--Source/cmaketest.h.in3
2 files changed, 64 insertions, 0 deletions
diff --git a/Source/cmaketest.cxx b/Source/cmaketest.cxx
new file mode 100644
index 0000000..e341205
--- /dev/null
+++ b/Source/cmaketest.cxx
@@ -0,0 +1,61 @@
+#include "cmaketest.h"
+#include "cmSystemTools.h"
+
+// this is a test driver program for cmake.
+main (int argc, char *argv[])
+{
+ if (argc < 4)
+ {
+ cerr << "Usage: " << argv[0] << " test-src-dir test-bin-dir test-executable\n";
+ return 1;
+ }
+
+ // does the directory exist ?
+ if (!cmSystemTools::FileIsDirectory(argv[2]))
+ {
+ cmSystemTools::MakeDirectory(argv[2]);
+ }
+
+ /**
+ * Run an executable command and put the stdout in output.
+ */
+ std::string output;
+
+ // change to the tests directory and run cmake
+ std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
+ cmSystemTools::ChangeDirectory(argv[2]);
+ std::string ccmd = CMAKE_COMMAND;
+ ccmd += " ";
+ ccmd += argv[1];
+ if (!cmSystemTools::RunCommand(ccmd.c_str(), output))
+ {
+ cerr << "Error: cmake execution failed\n";
+ cerr << output.c_str() << "\n";
+ // return to the original directory
+ cmSystemTools::ChangeDirectory(cwd.c_str());
+ return 1;
+ }
+
+ // now build the test
+ if (!cmSystemTools::RunCommand(MAKECOMMAND, output))
+ {
+ cerr << "Error: " MAKECOMMAND " execution failed\n";
+ cerr << output.c_str() << "\n";
+ // return to the original directory
+ cmSystemTools::ChangeDirectory(cwd.c_str());
+ return 1;
+ }
+
+ // now run the compiled test
+ if (!cmSystemTools::RunCommand(argv[3], output))
+ {
+ cerr << "Error: " << argv[3] << " execution failed\n";
+ // return to the original directory
+ cmSystemTools::ChangeDirectory(cwd.c_str());
+ return 1;
+ }
+
+ // return to the original directory
+ cmSystemTools::ChangeDirectory(cwd.c_str());
+ return 0;
+}
diff --git a/Source/cmaketest.h.in b/Source/cmaketest.h.in
new file mode 100644
index 0000000..74f1ec7
--- /dev/null
+++ b/Source/cmaketest.h.in
@@ -0,0 +1,3 @@
+#define CMAKE_COMMAND "${CMAKE_COMMAND}"
+#define MAKECOMMAND "${MAKECOMMAND}"
+