ENH: Add a test for cmGeneratedFileStream
This commit is contained in:
parent
0af5ef0e99
commit
308db351cc
@ -13,6 +13,7 @@ extern "C" {
|
|||||||
#include "cmDynamicLoader.h"
|
#include "cmDynamicLoader.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
#include "cmOrderLinkDirectories.h"
|
#include "cmOrderLinkDirectories.h"
|
||||||
|
#include "cmGeneratedFileStream.h"
|
||||||
|
|
||||||
int cm_passed = 0;
|
int cm_passed = 0;
|
||||||
int cm_failed = 0;
|
int cm_failed = 0;
|
||||||
@ -179,6 +180,71 @@ void TestDir(const char* filename)
|
|||||||
|
|
||||||
// ======================================================================
|
// ======================================================================
|
||||||
|
|
||||||
|
void TestCMGeneratedFileSTream()
|
||||||
|
{
|
||||||
|
cmGeneratedFileStream gm;
|
||||||
|
std::string file1 = std::string(BINARY_DIR) + std::string("/generatedFile1");
|
||||||
|
std::string file2 = std::string(BINARY_DIR) + std::string("/generatedFile2");
|
||||||
|
std::string file3 = std::string(BINARY_DIR) + std::string("/generatedFile3");
|
||||||
|
std::string file1tmp = file1 + ".tmp";
|
||||||
|
std::string file2tmp = file2 + ".tmp";
|
||||||
|
std::string file3tmp = file3 + ".tmp";
|
||||||
|
gm.Open(file1.c_str());
|
||||||
|
gm << "This is generated file 1";
|
||||||
|
gm.Close();
|
||||||
|
gm.Open(file2.c_str());
|
||||||
|
gm << "This is generated file 2";
|
||||||
|
gm.Close();
|
||||||
|
gm.Open(file3.c_str());
|
||||||
|
gm << "This is generated file 3";
|
||||||
|
gm.Close();
|
||||||
|
if ( cmSystemTools::FileExists(file1.c_str()) )
|
||||||
|
{
|
||||||
|
if ( cmSystemTools::FileExists(file2.c_str()) )
|
||||||
|
{
|
||||||
|
if ( cmSystemTools::FileExists(file3.c_str()) )
|
||||||
|
{
|
||||||
|
if ( cmSystemTools::FileExists(file1tmp.c_str()) )
|
||||||
|
{
|
||||||
|
cmFailed("Something wrong with cmGeneratedFileStream. Temporary file is still here: ", file1tmp.c_str());
|
||||||
|
}
|
||||||
|
else if ( cmSystemTools::FileExists(file2tmp.c_str()) )
|
||||||
|
{
|
||||||
|
cmFailed("Something wrong with cmGeneratedFileStream. Temporary file is still here: ", file2tmp.c_str());
|
||||||
|
}
|
||||||
|
else if ( cmSystemTools::FileExists(file3tmp.c_str()) )
|
||||||
|
{
|
||||||
|
cmFailed("Something wrong with cmGeneratedFileStream. Temporary file is still here: ", file3tmp.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmPassed("cmGeneratedFileStream works.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmFailed("Something wrong with cmGeneratedFileStream. Cannot find file: ", file3.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmFailed("Something wrong with cmGeneratedFileStream. Cannot find file: ", file2.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmFailed("Something wrong with cmGeneratedFileStream. Cannot find file: ", file1.c_str());
|
||||||
|
}
|
||||||
|
cmSystemTools::RemoveFile(file1.c_str());
|
||||||
|
cmSystemTools::RemoveFile(file2.c_str());
|
||||||
|
cmSystemTools::RemoveFile(file3.c_str());
|
||||||
|
cmSystemTools::RemoveFile(file1tmp.c_str());
|
||||||
|
cmSystemTools::RemoveFile(file2tmp.c_str());
|
||||||
|
cmSystemTools::RemoveFile(file3tmp.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ======================================================================
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
std::string lib = BINARY_DIR;
|
std::string lib = BINARY_DIR;
|
||||||
@ -1036,6 +1102,9 @@ int main()
|
|||||||
{
|
{
|
||||||
cmFailed("CMake cmOrderLinkDirectories failed.");
|
cmFailed("CMake cmOrderLinkDirectories failed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test the generated file stream.
|
||||||
|
TestCMGeneratedFileSTream();
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Summary
|
// Summary
|
||||||
|
@ -13,6 +13,7 @@ extern "C" {
|
|||||||
#include "cmDynamicLoader.h"
|
#include "cmDynamicLoader.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
#include "cmOrderLinkDirectories.h"
|
#include "cmOrderLinkDirectories.h"
|
||||||
|
#include "cmGeneratedFileStream.h"
|
||||||
|
|
||||||
int cm_passed = 0;
|
int cm_passed = 0;
|
||||||
int cm_failed = 0;
|
int cm_failed = 0;
|
||||||
@ -179,6 +180,71 @@ void TestDir(const char* filename)
|
|||||||
|
|
||||||
// ======================================================================
|
// ======================================================================
|
||||||
|
|
||||||
|
void TestCMGeneratedFileSTream()
|
||||||
|
{
|
||||||
|
cmGeneratedFileStream gm;
|
||||||
|
std::string file1 = std::string(BINARY_DIR) + std::string("/generatedFile1");
|
||||||
|
std::string file2 = std::string(BINARY_DIR) + std::string("/generatedFile2");
|
||||||
|
std::string file3 = std::string(BINARY_DIR) + std::string("/generatedFile3");
|
||||||
|
std::string file1tmp = file1 + ".tmp";
|
||||||
|
std::string file2tmp = file2 + ".tmp";
|
||||||
|
std::string file3tmp = file3 + ".tmp";
|
||||||
|
gm.Open(file1.c_str());
|
||||||
|
gm << "This is generated file 1";
|
||||||
|
gm.Close();
|
||||||
|
gm.Open(file2.c_str());
|
||||||
|
gm << "This is generated file 2";
|
||||||
|
gm.Close();
|
||||||
|
gm.Open(file3.c_str());
|
||||||
|
gm << "This is generated file 3";
|
||||||
|
gm.Close();
|
||||||
|
if ( cmSystemTools::FileExists(file1.c_str()) )
|
||||||
|
{
|
||||||
|
if ( cmSystemTools::FileExists(file2.c_str()) )
|
||||||
|
{
|
||||||
|
if ( cmSystemTools::FileExists(file3.c_str()) )
|
||||||
|
{
|
||||||
|
if ( cmSystemTools::FileExists(file1tmp.c_str()) )
|
||||||
|
{
|
||||||
|
cmFailed("Something wrong with cmGeneratedFileStream. Temporary file is still here: ", file1tmp.c_str());
|
||||||
|
}
|
||||||
|
else if ( cmSystemTools::FileExists(file2tmp.c_str()) )
|
||||||
|
{
|
||||||
|
cmFailed("Something wrong with cmGeneratedFileStream. Temporary file is still here: ", file2tmp.c_str());
|
||||||
|
}
|
||||||
|
else if ( cmSystemTools::FileExists(file3tmp.c_str()) )
|
||||||
|
{
|
||||||
|
cmFailed("Something wrong with cmGeneratedFileStream. Temporary file is still here: ", file3tmp.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmPassed("cmGeneratedFileStream works.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmFailed("Something wrong with cmGeneratedFileStream. Cannot find file: ", file3.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmFailed("Something wrong with cmGeneratedFileStream. Cannot find file: ", file2.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmFailed("Something wrong with cmGeneratedFileStream. Cannot find file: ", file1.c_str());
|
||||||
|
}
|
||||||
|
cmSystemTools::RemoveFile(file1.c_str());
|
||||||
|
cmSystemTools::RemoveFile(file2.c_str());
|
||||||
|
cmSystemTools::RemoveFile(file3.c_str());
|
||||||
|
cmSystemTools::RemoveFile(file1tmp.c_str());
|
||||||
|
cmSystemTools::RemoveFile(file2tmp.c_str());
|
||||||
|
cmSystemTools::RemoveFile(file3tmp.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ======================================================================
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
std::string lib = BINARY_DIR;
|
std::string lib = BINARY_DIR;
|
||||||
@ -1036,6 +1102,9 @@ int main()
|
|||||||
{
|
{
|
||||||
cmFailed("CMake cmOrderLinkDirectories failed.");
|
cmFailed("CMake cmOrderLinkDirectories failed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test the generated file stream.
|
||||||
|
TestCMGeneratedFileSTream();
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Summary
|
// Summary
|
||||||
|
@ -13,6 +13,7 @@ extern "C" {
|
|||||||
#include "cmDynamicLoader.h"
|
#include "cmDynamicLoader.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
#include "cmOrderLinkDirectories.h"
|
#include "cmOrderLinkDirectories.h"
|
||||||
|
#include "cmGeneratedFileStream.h"
|
||||||
|
|
||||||
int cm_passed = 0;
|
int cm_passed = 0;
|
||||||
int cm_failed = 0;
|
int cm_failed = 0;
|
||||||
@ -179,6 +180,71 @@ void TestDir(const char* filename)
|
|||||||
|
|
||||||
// ======================================================================
|
// ======================================================================
|
||||||
|
|
||||||
|
void TestCMGeneratedFileSTream()
|
||||||
|
{
|
||||||
|
cmGeneratedFileStream gm;
|
||||||
|
std::string file1 = std::string(BINARY_DIR) + std::string("/generatedFile1");
|
||||||
|
std::string file2 = std::string(BINARY_DIR) + std::string("/generatedFile2");
|
||||||
|
std::string file3 = std::string(BINARY_DIR) + std::string("/generatedFile3");
|
||||||
|
std::string file1tmp = file1 + ".tmp";
|
||||||
|
std::string file2tmp = file2 + ".tmp";
|
||||||
|
std::string file3tmp = file3 + ".tmp";
|
||||||
|
gm.Open(file1.c_str());
|
||||||
|
gm << "This is generated file 1";
|
||||||
|
gm.Close();
|
||||||
|
gm.Open(file2.c_str());
|
||||||
|
gm << "This is generated file 2";
|
||||||
|
gm.Close();
|
||||||
|
gm.Open(file3.c_str());
|
||||||
|
gm << "This is generated file 3";
|
||||||
|
gm.Close();
|
||||||
|
if ( cmSystemTools::FileExists(file1.c_str()) )
|
||||||
|
{
|
||||||
|
if ( cmSystemTools::FileExists(file2.c_str()) )
|
||||||
|
{
|
||||||
|
if ( cmSystemTools::FileExists(file3.c_str()) )
|
||||||
|
{
|
||||||
|
if ( cmSystemTools::FileExists(file1tmp.c_str()) )
|
||||||
|
{
|
||||||
|
cmFailed("Something wrong with cmGeneratedFileStream. Temporary file is still here: ", file1tmp.c_str());
|
||||||
|
}
|
||||||
|
else if ( cmSystemTools::FileExists(file2tmp.c_str()) )
|
||||||
|
{
|
||||||
|
cmFailed("Something wrong with cmGeneratedFileStream. Temporary file is still here: ", file2tmp.c_str());
|
||||||
|
}
|
||||||
|
else if ( cmSystemTools::FileExists(file3tmp.c_str()) )
|
||||||
|
{
|
||||||
|
cmFailed("Something wrong with cmGeneratedFileStream. Temporary file is still here: ", file3tmp.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmPassed("cmGeneratedFileStream works.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmFailed("Something wrong with cmGeneratedFileStream. Cannot find file: ", file3.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmFailed("Something wrong with cmGeneratedFileStream. Cannot find file: ", file2.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmFailed("Something wrong with cmGeneratedFileStream. Cannot find file: ", file1.c_str());
|
||||||
|
}
|
||||||
|
cmSystemTools::RemoveFile(file1.c_str());
|
||||||
|
cmSystemTools::RemoveFile(file2.c_str());
|
||||||
|
cmSystemTools::RemoveFile(file3.c_str());
|
||||||
|
cmSystemTools::RemoveFile(file1tmp.c_str());
|
||||||
|
cmSystemTools::RemoveFile(file2tmp.c_str());
|
||||||
|
cmSystemTools::RemoveFile(file3tmp.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ======================================================================
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
std::string lib = BINARY_DIR;
|
std::string lib = BINARY_DIR;
|
||||||
@ -1036,6 +1102,9 @@ int main()
|
|||||||
{
|
{
|
||||||
cmFailed("CMake cmOrderLinkDirectories failed.");
|
cmFailed("CMake cmOrderLinkDirectories failed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test the generated file stream.
|
||||||
|
TestCMGeneratedFileSTream();
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Summary
|
// Summary
|
||||||
|
Loading…
x
Reference in New Issue
Block a user