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
complex
${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(BUILD_TESTING)

View File

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