Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YAML Parser] Support parameter value parsing #471

Merged
merged 3 commits into from
Jul 12, 2019
Merged

Conversation

hidmic
Copy link
Contributor

@hidmic hidmic commented Jul 5, 2019

Closes #246. This pull request extends the YAML parser API to include:

/// \brief Parse a parameter value as a YAML string, updating params_st accordingly
/// \param[in] node_name is the name of the node to which the parameter belongs
/// \param[in] param_name is the name of the parameter whose value will be parsed
/// \param[in] yaml_value is the parameter value as a YAML string to be parsed
/// \param[inout] params_st points to the parameter struct
/// \return true on success and false on failure
RCL_YAML_PARAM_PARSER_PUBLIC
bool rcl_parse_yaml_value(
  const char * node_name,
  const char * param_name,
  const char * yaml_value,
  rcl_params_t * params_st);

This way, parameter addressing information can directly provided along with the parameter value as a YAML string to be parsed.

Depends on #470.

@hidmic hidmic requested a review from wjwwood July 5, 2019 20:49
Copy link
Member

@jacobperron jacobperron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Left a few comments below.
I would do a "rebase and merge" to keep the rcl dependency removal in a separate commit from the new function.

rcl_yaml_param_parser/test/test_parse_yaml.cpp Outdated Show resolved Hide resolved
rcl_yaml_param_parser/src/parser.c Outdated Show resolved Hide resolved
rcl_yaml_param_parser/src/parser.c Outdated Show resolved Hide resolved
rcl_yaml_param_parser/src/parser.c Outdated Show resolved Hide resolved
rcl_yaml_param_parser/src/parser.c Outdated Show resolved Hide resolved
rcl_yaml_param_parser/src/parser.c Outdated Show resolved Hide resolved
@jacobperron
Copy link
Member

I would do a "rebase and merge" to keep the rcl dependency removal in a separate commit from the new function.

Ah, nevermind, I see #470 🙃

@hidmic
Copy link
Contributor Author

hidmic commented Jul 10, 2019

@jacobperron had to rebase after changes got applied to #470, sorry about that. PTAL.

rcutils_allocator_t allocator = rcutils_get_default_allocator();
char * test_path = rcutils_join_path(cur_dir, "test", allocator);
char * path = rcutils_join_path(test_path, "correct_config.yaml", allocator);
fprintf(stderr, "cur_path: %s\n", path);
EXPECT_TRUE(rcutils_exists(path));
ASSERT_TRUE(rcutils_exists(path)) << "No test YAML file found at " << path;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we use ASSERT_*, I think we should make sure to free resources in the event that the assertion fails. We can use the helper OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT to make sure test_path, path, and params_hdl are cleaned up when the test exits.

I guess this should also be added to the other tests as needed.

Copy link
Contributor Author

@hidmic hidmic Jul 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it, but since it's a test I was less worried about memory freeing. But using OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT sounds like a much better plan.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, some folks went through and fixed a bunch of leaks detected by ASan jobs (for example). Even though they're just tests, it will make those jobs happy.

Copy link
Member

@jacobperron jacobperron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with green CI

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
- Improve test coverage using new getter API.
- Unify function return style and improve readability.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
@hidmic
Copy link
Contributor Author

hidmic commented Jul 12, 2019

Rebased to solve merge conflicts. Running CI (up to system_tests to make sure nothing broke downstream):

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@hidmic
Copy link
Contributor Author

hidmic commented Jul 12, 2019

Alright, CI is green! Merging.

@hidmic hidmic merged commit 5fde9c0 into master Jul 12, 2019
@delete-merged-branch delete-merged-branch bot deleted the hidmic/parse-yaml-value branch July 12, 2019 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[YAML parser] Support command line yaml parameter string
2 participants