Added ParseContext::PARSE_MISSING_INCLUDE
This commit is contained in:
@@ -62,9 +62,12 @@ namespace Opm {
|
||||
addKey(PARSE_RANDOM_SLASH);
|
||||
addKey(PARSE_MISSING_DIMS_KEYWORD);
|
||||
addKey(PARSE_EXTRA_DATA);
|
||||
addKey(PARSE_MISSING_INCLUDE);
|
||||
|
||||
addKey(UNSUPPORTED_SCHEDULE_GEO_MODIFIER);
|
||||
addKey(UNSUPPORTED_COMPORD_TYPE);
|
||||
addKey(UNSUPPORTED_INITIAL_THPRES);
|
||||
|
||||
addKey(INTERNAL_ERROR_UNINITIALIZED_THPRES);
|
||||
}
|
||||
|
||||
@@ -230,6 +233,7 @@ namespace Opm {
|
||||
const std::string ParseContext::PARSE_RANDOM_SLASH = "PARSE_RANDOM_SLASH";
|
||||
const std::string ParseContext::PARSE_MISSING_DIMS_KEYWORD = "PARSE_MISSING_DIMS_KEYWORD";
|
||||
const std::string ParseContext::PARSE_EXTRA_DATA = "PARSE_EXTRA_DATA";
|
||||
const std::string ParseContext::PARSE_MISSING_INCLUDE = "PARSE_MISSING_INCLUDE";
|
||||
|
||||
const std::string ParseContext::UNSUPPORTED_SCHEDULE_GEO_MODIFIER = "UNSUPPORTED_SCHEDULE_GEO_MODIFIER";
|
||||
const std::string ParseContext::UNSUPPORTED_COMPORD_TYPE = "UNSUPPORTED_COMPORD_TYPE";
|
||||
|
||||
@@ -160,6 +160,14 @@ namespace Opm {
|
||||
*/
|
||||
const static std::string PARSE_EXTRA_DATA;
|
||||
|
||||
/*
|
||||
If an include file is not found we can configure the parser
|
||||
to contine reading; of course the resulting deck can
|
||||
obviously be quite broken.
|
||||
*/
|
||||
const static std::string PARSE_MISSING_INCLUDE;
|
||||
|
||||
|
||||
/*
|
||||
Some property modfiers can be modified in the Schedule
|
||||
section; this effectively means that Eclipse supports time
|
||||
|
||||
@@ -303,7 +303,9 @@ void ParserState::loadFile(const boost::filesystem::path& inputFile) {
|
||||
try {
|
||||
inputFileCanonical = boost::filesystem::canonical(inputFile);
|
||||
} catch (boost::filesystem::filesystem_error fs_error) {
|
||||
throw std::runtime_error(std::string("Parser::loadFile fails: ") + fs_error.what());
|
||||
std::string msg = "Could not open file: " + inputFile.string();
|
||||
parseContext.handleError( ParseContext::PARSE_MISSING_INCLUDE , deck->getMessageContainer() , msg);
|
||||
return;
|
||||
}
|
||||
|
||||
const auto closer = []( std::FILE* f ) { std::fclose( f ); };
|
||||
@@ -314,9 +316,9 @@ void ParserState::loadFile(const boost::filesystem::path& inputFile) {
|
||||
|
||||
// make sure the file we'd like to parse is readable
|
||||
if( !ufp ) {
|
||||
throw std::runtime_error(std::string("Input file '") +
|
||||
inputFileCanonical.string() +
|
||||
std::string("' is not readable"));
|
||||
std::string msg = "Could not read from file: " + inputFile.string();
|
||||
parseContext.handleError( ParseContext::PARSE_MISSING_INCLUDE , deck->getMessageContainer() , msg);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -32,6 +32,21 @@
|
||||
|
||||
#ifdef OPM_PARSER_BUILD_HAVE_SYMLINK
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ParserKeyword_includeInvalid) {
|
||||
boost::filesystem::path inputFilePath("testdata/parser/includeInvalid.data");
|
||||
|
||||
Opm::ParserPtr parser(new Opm::Parser());
|
||||
Opm::ParseContext parseContext;
|
||||
|
||||
parseContext.update(Opm::ParseContext::PARSE_MISSING_INCLUDE , Opm::InputError::THROW_EXCEPTION );
|
||||
BOOST_CHECK_THROW(parser->parseFile(inputFilePath.string() , parseContext) , std::invalid_argument);
|
||||
|
||||
parseContext.update(Opm::ParseContext::PARSE_MISSING_INCLUDE , Opm::InputError::IGNORE );
|
||||
BOOST_CHECK_NO_THROW(parser->parseFile(inputFilePath.string() , parseContext));
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Verify_find_includes_Data_file_is_a_symlink) {
|
||||
boost::filesystem::path inputFilePath("testdata/parser/includeSymlinkTestdata/symlink1/case_symlink.data");
|
||||
Opm::ParserPtr parser(new Opm::Parser());
|
||||
@@ -75,12 +90,9 @@ BOOST_AUTO_TEST_CASE(ParserKeyword_includeValid) {
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ParserKeyword_includeInvalid) {
|
||||
boost::filesystem::path inputFilePath("testdata/parser/includeInvalid.data");
|
||||
|
||||
Opm::ParserPtr parser(new Opm::Parser());
|
||||
BOOST_CHECK_THROW(parser->parseFile(inputFilePath.string() , Opm::ParseContext()), std::runtime_error);
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ParserKeyword_includeWrongCase) {
|
||||
boost::filesystem::path inputFile1Path("testdata/parser/includeWrongCase1.data");
|
||||
@@ -94,9 +106,12 @@ BOOST_AUTO_TEST_CASE(ParserKeyword_includeWrongCase) {
|
||||
// exactly the same spelling as their names on disk. Eclipse seems
|
||||
// to be a bit more relaxed when it comes to this, so we might
|
||||
// have to change the current behavior one not-so-fine day...
|
||||
BOOST_CHECK_THROW(parser->parseFile(inputFile1Path.string(), Opm::ParseContext()), std::runtime_error);
|
||||
BOOST_CHECK_THROW(parser->parseFile(inputFile2Path.string(), Opm::ParseContext()), std::runtime_error);
|
||||
BOOST_CHECK_THROW(parser->parseFile(inputFile3Path.string(), Opm::ParseContext()), std::runtime_error);
|
||||
Opm::ParseContext parseContext;
|
||||
parseContext.update(Opm::ParseContext::PARSE_MISSING_INCLUDE , Opm::InputError::THROW_EXCEPTION );
|
||||
|
||||
BOOST_CHECK_THROW(parser->parseFile(inputFile1Path.string(), parseContext), std::invalid_argument);
|
||||
BOOST_CHECK_THROW(parser->parseFile(inputFile2Path.string(), parseContext), std::invalid_argument);
|
||||
BOOST_CHECK_THROW(parser->parseFile(inputFile3Path.string(), parseContext), std::invalid_argument);
|
||||
#else
|
||||
// for case-insensitive filesystems, the include statement will
|
||||
// always work regardless of how the capitalization of the
|
||||
|
||||
@@ -292,8 +292,11 @@ BOOST_AUTO_TEST_CASE( quoted_comments ) {
|
||||
|
||||
BOOST_AUTO_TEST_CASE( PATHS_has_global_scope ) {
|
||||
Parser parser;
|
||||
parser.newDeckFromFile( "testdata/parser/PATHSInInclude.data", ParseContext() );
|
||||
BOOST_CHECK_THROW( parser.newDeckFromFile( "testdata/parser/PATHSInIncludeInvalid.data", ParseContext() ), std::runtime_error );
|
||||
ParseContext parseContext;
|
||||
|
||||
parseContext.update( ParseContext::PARSE_MISSING_INCLUDE , Opm::InputError::THROW_EXCEPTION);
|
||||
parser.newDeckFromFile( "testdata/parser/PATHSInInclude.data", parseContext );
|
||||
BOOST_CHECK_THROW( parser.newDeckFromFile( "testdata/parser/PATHSInIncludeInvalid.data", ParseContext() ), std::invalid_argument );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( handle_empty_title ) {
|
||||
|
||||
Reference in New Issue
Block a user