Tests/CMakeLib: use cmsys::ifstream
This commit is contained in:
parent
87e76f8996
commit
3f9c4cdf89
@ -1,6 +1,6 @@
|
|||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
|
|
||||||
#include <fstream>
|
#include <cmsys/FStream.hxx>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -26,7 +26,10 @@ public:
|
|||||||
};
|
};
|
||||||
typedef std::vector<CommandType> TranslationUnitsType;
|
typedef std::vector<CommandType> TranslationUnitsType;
|
||||||
|
|
||||||
CompileCommandParser(std::ifstream* input) { this->Input = input; }
|
CompileCommandParser(std::istream& input)
|
||||||
|
: Input(input)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void Parse()
|
void Parse()
|
||||||
{
|
{
|
||||||
@ -109,8 +112,8 @@ private:
|
|||||||
|
|
||||||
void Next()
|
void Next()
|
||||||
{
|
{
|
||||||
this->C = char(Input->get());
|
this->C = char(Input.get());
|
||||||
if (this->Input->bad()) {
|
if (this->Input.bad()) {
|
||||||
ErrorExit("Unexpected end of file.");
|
ErrorExit("Unexpected end of file.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -131,13 +134,13 @@ private:
|
|||||||
TranslationUnitsType TranslationUnits;
|
TranslationUnitsType TranslationUnits;
|
||||||
CommandType Command;
|
CommandType Command;
|
||||||
std::string String;
|
std::string String;
|
||||||
std::ifstream* Input;
|
std::istream& Input;
|
||||||
};
|
};
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
std::ifstream file("compile_commands.json");
|
cmsys::ifstream file("compile_commands.json");
|
||||||
CompileCommandParser parser(&file);
|
CompileCommandParser parser(file);
|
||||||
parser.Parse();
|
parser.Parse();
|
||||||
for (CompileCommandParser::TranslationUnitsType::const_iterator
|
for (CompileCommandParser::TranslationUnitsType::const_iterator
|
||||||
it = parser.GetTranslationUnits().begin(),
|
it = parser.GetTranslationUnits().begin(),
|
||||||
|
@ -10,9 +10,12 @@
|
|||||||
See the License for more information.
|
See the License for more information.
|
||||||
============================================================================*/
|
============================================================================*/
|
||||||
#include "cmRST.h"
|
#include "cmRST.h"
|
||||||
|
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
|
|
||||||
|
#include <cmsys/FStream.hxx>
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
void reportLine(std::ostream& os, bool ret, std::string const& line, bool eol)
|
void reportLine(std::ostream& os, bool ret, std::string const& line, bool eol)
|
||||||
{
|
{
|
||||||
if (ret) {
|
if (ret) {
|
||||||
@ -52,8 +55,8 @@ int testRST(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Compare expected and actual outputs.
|
// Compare expected and actual outputs.
|
||||||
std::ifstream e_fin(e_name.c_str());
|
cmsys::ifstream e_fin(e_name.c_str());
|
||||||
std::ifstream a_fin(a_name.c_str());
|
cmsys::ifstream a_fin(a_name.c_str());
|
||||||
if (!e_fin) {
|
if (!e_fin) {
|
||||||
std::cerr << "Could not open input " << e_name << std::endl;
|
std::cerr << "Could not open input " << e_name << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user