Added warnings in Deck for keywords of type IGNORE_WARNING and unrecognized keywords
This commit is contained in:
parent
f3a38425cb
commit
8e550b7f32
@ -12,7 +12,7 @@ add_test(NAME runParseWCONHIST WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} COMMA
|
||||
|
||||
add_executable(runParsePORO ParsePORO.cpp)
|
||||
target_link_libraries(runParsePORO Parser ${Boost_LIBRARIES})
|
||||
add_test(NAME runParsePORO WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} COMMAND runParsePORO)
|
||||
add_test(NAME runParsePORO WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} COMMAND runParsePORO)
|
||||
|
||||
add_executable(runParseACTION ParseACTION.cpp)
|
||||
target_link_libraries(runParseACTION Parser ${Boost_LIBRARIES})
|
||||
|
@ -38,7 +38,7 @@ using namespace Opm;
|
||||
BOOST_AUTO_TEST_CASE( parse_ACTION_OK ) {
|
||||
ParserPtr parser(new Parser( false ));
|
||||
boost::filesystem::path actionFile("testdata/integration_tests/ACTION/ACTION.txt");
|
||||
ParserKeywordConstPtr DIMENS( new ParserKeyword("DIMENS" , (size_t) 1 , IGNORE));
|
||||
ParserKeywordConstPtr DIMENS( new ParserKeyword("DIMENS" , (size_t) 1 , IGNORE_WARNING ));
|
||||
|
||||
BOOST_REQUIRE( parser->loadKeywordFromFile( boost::filesystem::path( std::string(KEYWORD_DIRECTORY) + std::string("/W/WCONHIST") )) );
|
||||
parser->addKeyword( DIMENS );
|
||||
@ -46,7 +46,7 @@ BOOST_AUTO_TEST_CASE( parse_ACTION_OK ) {
|
||||
BOOST_REQUIRE( parser->hasKeyword( "DIMENS" ));
|
||||
BOOST_REQUIRE( parser->hasKeyword( "WCONHIST" ));
|
||||
|
||||
DeckPtr deck = parser->parse(actionFile.string());
|
||||
DeckPtr deck = parser->parse(actionFile.string() , false);
|
||||
DeckKeywordConstPtr kw1 = deck->getKeyword("WCONHIST" , 0);
|
||||
BOOST_CHECK_EQUAL( 3U , kw1->size() );
|
||||
|
||||
@ -69,4 +69,19 @@ BOOST_AUTO_TEST_CASE( parse_ACTION_OK ) {
|
||||
|
||||
|
||||
BOOST_CHECK_EQUAL( false , deck->hasKeyword( "DIMENS" ));
|
||||
BOOST_CHECK_EQUAL( 2U , deck->numWarnings() );
|
||||
{
|
||||
const std::pair<std::string,std::pair<std::string,size_t> >& warning = deck->getWarning( 0 );
|
||||
const std::pair<std::string,size_t>& location = warning.second;
|
||||
BOOST_CHECK_EQUAL( actionFile.string() , location.first);
|
||||
BOOST_CHECK_EQUAL( 2U , location.second);
|
||||
}
|
||||
{
|
||||
const std::pair<std::string,std::pair<std::string,size_t> >& warning = deck->getWarning( 1 );
|
||||
const std::pair<std::string,size_t>& location = warning.second;
|
||||
BOOST_CHECK_EQUAL( actionFile.string() , location.first);
|
||||
BOOST_CHECK_EQUAL( 6U , location.second);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -110,10 +110,12 @@ namespace Opm {
|
||||
|
||||
if (hasKeyword(rawKeyword->getKeywordName())) {
|
||||
ParserKeywordConstPtr parserKeyword = m_parserKeywords.at(rawKeyword->getKeywordName());
|
||||
if (parserKeyword->getAction() == INTERNALIZE) {
|
||||
ParserKeywordActionEnum action = parserKeyword->getAction();
|
||||
if (action == INTERNALIZE) {
|
||||
DeckKeywordConstPtr deckKeyword = parserKeyword->parse(rawKeyword);
|
||||
deck->addKeyword(deckKeyword);
|
||||
}
|
||||
} else if (action == IGNORE_WARNING)
|
||||
deck->addWarning( "The keyword " + rawKeyword->getKeywordName() + " is ignored - this might potentially affect the results." , file.string() , rawKeyword->getLineNR());
|
||||
} else {
|
||||
DeckKeywordConstPtr deckKeyword(new DeckKeyword(rawKeyword->getKeywordName(), false));
|
||||
deck->addKeyword(deckKeyword);
|
||||
|
9
testdata/integration_tests/ACTION/ACTION.txt
vendored
9
testdata/integration_tests/ACTION/ACTION.txt
vendored
@ -1,4 +1,9 @@
|
||||
DIMENS
|
||||
|
||||
UNRECOGNIZED
|
||||
This Keyword should give a warning at line 2/
|
||||
|
||||
|
||||
DIMENS -- /This is flagged as IGNORE_WARNING - and should give a warning at line: 6
|
||||
10 10 10 /
|
||||
|
||||
WCONHIST
|
||||
@ -10,3 +15,5 @@ WCONHIST
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user