2011-12-24 00:08:47 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2011 Kitware, Inc., Insight Software Consortium
|
|
|
|
|
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
|
|
|
#include "cmGeneratedFileStream.h"
|
|
|
|
#include "cmSystemTools.h"
|
|
|
|
|
2016-09-01 21:04:35 +03:00
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
#define cmFailed(m1, m2) \
|
2016-09-05 23:09:49 +03:00
|
|
|
std::cout << "FAILED: " << (m1) << (m2) << "\n"; \
|
2016-05-16 17:34:04 +03:00
|
|
|
failed = 1
|
2011-12-24 00:08:47 +04:00
|
|
|
|
2016-08-17 02:49:57 +03:00
|
|
|
int testGeneratedFileStream(int /*unused*/, char* /*unused*/ [])
|
2011-12-24 00:08:47 +04:00
|
|
|
{
|
|
|
|
int failed = 0;
|
|
|
|
cmGeneratedFileStream gm;
|
|
|
|
std::string file1 = "generatedFile1";
|
|
|
|
std::string file2 = "generatedFile2";
|
|
|
|
std::string file3 = "generatedFile3";
|
|
|
|
std::string file4 = "generatedFile4";
|
|
|
|
std::string file1tmp = file1 + ".tmp";
|
|
|
|
std::string file2tmp = file2 + ".tmp";
|
|
|
|
std::string file3tmp = file3 + ".tmp";
|
|
|
|
std::string file4tmp = file4 + ".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();
|
|
|
|
gm.Open(file4.c_str());
|
|
|
|
gm << "This is generated file 4";
|
|
|
|
gm.Close();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileExists(file1.c_str())) {
|
|
|
|
if (cmSystemTools::FileExists(file2.c_str())) {
|
|
|
|
if (cmSystemTools::FileExists(file3.c_str())) {
|
|
|
|
if (cmSystemTools::FileExists(file4.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 if (cmSystemTools::FileExists(file4tmp.c_str())) {
|
|
|
|
cmFailed("Something wrong with cmGeneratedFileStream. Temporary "
|
|
|
|
"file is still here: ",
|
|
|
|
file4tmp.c_str());
|
|
|
|
} else {
|
2011-12-24 00:08:47 +04:00
|
|
|
std::cout << "cmGeneratedFileStream works\n";
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
|
|
|
cmFailed(
|
|
|
|
"Something wrong with cmGeneratedFileStream. Cannot find file: ",
|
|
|
|
file4.c_str());
|
2011-12-24 00:08:47 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
|
|
|
cmFailed("Something wrong with cmGeneratedFileStream. Found file: ",
|
|
|
|
file3.c_str());
|
2011-12-24 00:08:47 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
|
|
|
cmFailed(
|
|
|
|
"Something wrong with cmGeneratedFileStream. Cannot find file: ",
|
|
|
|
file2.c_str());
|
2011-12-24 00:08:47 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
|
|
|
cmFailed("Something wrong with cmGeneratedFileStream. Cannot find file: ",
|
|
|
|
file1.c_str());
|
|
|
|
}
|
2016-05-26 23:52:22 +03:00
|
|
|
cmSystemTools::RemoveFile(file1);
|
|
|
|
cmSystemTools::RemoveFile(file2);
|
|
|
|
cmSystemTools::RemoveFile(file3);
|
|
|
|
cmSystemTools::RemoveFile(file4);
|
|
|
|
cmSystemTools::RemoveFile(file1tmp);
|
|
|
|
cmSystemTools::RemoveFile(file2tmp);
|
|
|
|
cmSystemTools::RemoveFile(file3tmp);
|
|
|
|
cmSystemTools::RemoveFile(file4tmp);
|
2011-12-24 00:08:47 +04:00
|
|
|
|
|
|
|
return failed;
|
|
|
|
}
|