Changes related to service method integration tests#277
Changes related to service method integration tests#277gdadunashvili wants to merge 9 commits intoeclipse-score:mainfrom
Conversation
bemerybmw
left a comment
There was a problem hiding this comment.
The final merge commit can be removed?
score/mw/com/test/common_test_resources/command_line_parser.cpp
Outdated
Show resolved
Hide resolved
| param_name.data(), po::value<std::string>(), ("specify " + std::string{param_doc}).data()); | ||
| } | ||
|
|
||
| po::variables_map args; |
There was a problem hiding this comment.
This should use the CommandLineArgsMapType alias.
There was a problem hiding this comment.
Now CommandLineArgsMapType is a std::unordered map and boost command line options does not escape the body of this function
| using CommandLineArgsMapType = boost::program_options::variables_map; | ||
|
|
||
| template <typename ParsedType> | ||
| auto GetValueIfProvided(const boost::program_options::variables_map& args, const std::string& arg_string) |
There was a problem hiding this comment.
please add docstrings to these functions and mention when they should be used.
|
|
||
| namespace score::mw::com::test | ||
| { | ||
| auto ParseCommandLineArguments(int argc, |
There was a problem hiding this comment.
This code is extracted from SctfTestRunner? IMO, SctfTestRunner should be updated to use this, otherwise we have two ways of parsing command line arguments. And if we then want to for example remove the boost dependency in the future, we only have that dependency in this target and so only have to refactor this code and not the SctfTestRunner.
There was a problem hiding this comment.
I addressed this issue
| std::string error_msg = "could not find the requested parameter: " + arg_string; | ||
| if constexpr (std::is_same_v<ParsedType, std::string>) | ||
| { | ||
| return (args.count(arg_string) > 0U) ? args[arg_string].as<std::string>() |
There was a problem hiding this comment.
This check is duplicated in each if. Can't we just check if args.count(arg_string) == 0U once at the start?
|
|
||
| using CommandLineArgsMapType = boost::program_options::variables_map; | ||
|
|
||
| template <typename ParsedType> |
There was a problem hiding this comment.
Instead of templating with ParsedType and then checking within the function that it's a string, int or float, why not template with:
enum class ParsedType
{
INVALID,
INT,
STRING,
FLOAT
}
There was a problem hiding this comment.
Doing this is not possible since the return type can not be deduced anymore. Also since I changed the implementation to from_chars there are not internal branches anymore
| } // namespace detail | ||
|
|
||
| template <typename... Args> | ||
| void fail_test(Args&&... args) |
There was a problem hiding this comment.
Please add function docs
|
|
||
| namespace detail | ||
| { | ||
| void fail_test_(std::stringstream&& strstr); |
There was a problem hiding this comment.
Why lowercase and trailing underscore? Why not FailTest or FailTestImpl or something like that?
|
|
||
| void fail_test_(std::stringstream&& strstr) | ||
| { | ||
| std::move(strstr) << "\033[0m \033[1m\033[41mTEST FAILED\033[0m\n"; |
There was a problem hiding this comment.
Why are you moving here?
b526473 to
2cb49ec
Compare
|
|
||
| using CommandLineArgsMapType = std::unordered_map<std::string, std::string>; | ||
|
|
||
| /// \brief Get a value reperesednted as a string, from an arguments map and parse it into the appropriate type |
There was a problem hiding this comment.
| /// \brief Get a value reperesednted as a string, from an arguments map and parse it into the appropriate type | |
| /// \brief Get a value represented as a string, from an arguments map and parse it into the appropriate type |
| param_name.data(), po::value<std::string>(), ("specify " + std::string{param_doc}).data()); | ||
| } | ||
|
|
||
| po::variables_map args; |
|
|
||
| /// \brief Get a value reperesednted as a string, from an arguments map and parse it into the appropriate type | ||
| /// | ||
| /// \tparam ParsedType Target type of the parsed argument. Must be std::string, integral or floating point type. |
There was a problem hiding this comment.
| /// \tparam ParsedType Target type of the parsed argument. Must be std::string, integral or floating point type. | |
| /// \tparam ReturnType Target type of the parsed argument. Must be std::string, integral or floating point type. |
This function can safely terminate a test and offers the ability to consume variadic number of printable arguments to print them as an error message
methods tests reuse the same configuration with slight variations, like changing the applicationID or asil_level, but leavidng the rest unchanged. This can lead to many duplicated json files which only slightly differ and are hard to maintain. This config_generator bazel rule together with the config_generator.py and base_mw_com_config.json provides a way to generate config files on the fly during the build step.
Handler scopes need to be reinitiated by PrepareOffer in case they were expired by StopOffer before
2cb49ec to
8da71a5
Compare
These are changes that are related to integration tests for methods.
Either bugfixes that were discovered through methods tests, or infrastructure code that will be used by integration tests