add example to tests

This commit is contained in:
Bill Hoffman 2001-12-19 15:26:21 -05:00
parent 8cae04446a
commit 384cf0c7f3
2 changed files with 17 additions and 3 deletions

View File

@ -91,7 +91,12 @@ IF(BUILD_TESTING)
${CMake_BINARY_DIR}/Tests/Complex ${CMake_BINARY_DIR}/Tests/Complex
complex complex
${CMake_BINARY_DIR}/Tests/Complex/bin ) ${CMake_BINARY_DIR}/Tests/Complex/bin )
ADD_TEST(Example ${CMake_BINARY_DIR}/Source/cmaketest
${CMake_SOURCE_DIR}/Example
${CMake_BINARY_DIR}/Example
helloDemo
${CMake_BINARY_DIR}/Example/Demo
HELLO )
ENDIF (DART_ROOT) ENDIF (DART_ROOT)
ENDIF(BUILD_TESTING) ENDIF(BUILD_TESTING)

View File

@ -28,6 +28,11 @@ int main (int argc, char *argv[])
{ {
executableDirectory = argv[4]; executableDirectory = argv[4];
} }
const char* projectName = executableName;
if(argc > 5)
{
projectName = argv[5];
}
/** /**
* Run an executable command and put the stdout in output. * Run an executable command and put the stdout in output.
@ -37,6 +42,7 @@ int main (int argc, char *argv[])
// change to the tests directory and run cmake // change to the tests directory and run cmake
// use the cmake object instead of calling cmake // use the cmake object instead of calling cmake
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
std::cout << "Changing into directory: " << binaryDirectory << "\n";
cmSystemTools::ChangeDirectory(binaryDirectory); cmSystemTools::ChangeDirectory(binaryDirectory);
cmake cm; cmake cm;
std::vector<std::string> args; std::vector<std::string> args;
@ -57,7 +63,7 @@ int main (int argc, char *argv[])
std::string generator = "-G"; std::string generator = "-G";
generator += CMAKE_GENERATOR; generator += CMAKE_GENERATOR;
args.push_back(generator); args.push_back(generator);
std::cout << "Generating build files...\n";
if (cm.Generate(args) != 0) if (cm.Generate(args) != 0)
{ {
std::cerr << "Error: cmake execution failed\n"; std::cerr << "Error: cmake execution failed\n";
@ -65,6 +71,7 @@ int main (int argc, char *argv[])
cmSystemTools::ChangeDirectory(cwd.c_str()); cmSystemTools::ChangeDirectory(cwd.c_str());
return 1; return 1;
} }
std::cout << "Done Generating build files.\n";
cmListFileCache::GetInstance()->ClearCache(); cmListFileCache::GetInstance()->ClearCache();
// now build the test // now build the test
std::string makeCommand = MAKEPROGRAM; std::string makeCommand = MAKEPROGRAM;
@ -97,7 +104,7 @@ int main (int argc, char *argv[])
} }
#endif #endif
makeCommand += " "; makeCommand += " ";
makeCommand += executableName; makeCommand += projectName;
makeCommand += ".dsw /MAKE \"ALL_BUILD - Debug\" /REBUILD"; makeCommand += ".dsw /MAKE \"ALL_BUILD - Debug\" /REBUILD";
} }
else else
@ -105,6 +112,7 @@ int main (int argc, char *argv[])
// assume a make sytle program // assume a make sytle program
makeCommand += " all"; makeCommand += " all";
} }
std::cout << "Running make command: " << makeCommand.c_str() << " ...\n";
if (!cmSystemTools::RunCommand(makeCommand.c_str(), output)) if (!cmSystemTools::RunCommand(makeCommand.c_str(), output))
{ {
std::cerr << "Error: " << makeCommand.c_str() << " execution failed\n"; std::cerr << "Error: " << makeCommand.c_str() << " execution failed\n";
@ -168,6 +176,7 @@ int main (int argc, char *argv[])
#if defined(_WIN32) && !defined(__CYGWIN__) #if defined(_WIN32) && !defined(__CYGWIN__)
cmSystemTools::ConvertToWindowsSlashes(fullPath); cmSystemTools::ConvertToWindowsSlashes(fullPath);
#endif #endif
std::cout << "Running test executable: " << fullPath.c_str() << "\n";
if (!cmSystemTools::RunCommand(fullPath.c_str(), output)) if (!cmSystemTools::RunCommand(fullPath.c_str(), output))
{ {
std::cerr << "Error: " << fullPath.c_str() << " execution failed\n"; std::cerr << "Error: " << fullPath.c_str() << " execution failed\n";