Skip to content
This repository has been archived by the owner on Jan 27, 2020. It is now read-only.

Have IO and Exit Code asserts use the same lookup #16

Merged
merged 2 commits into from
Feb 28, 2019

Conversation

pbaughman
Copy link
Contributor

@pbaughman pbaughman commented Feb 23, 2019

  • Gave all of these methods similar signatures. They can all take ExecuteProcess actions or strings to identify a process
  • New util to handle the lookup of process actions in one place

New file is apex_launchtest/util/proc_lookup.py. All of the other assert methods use this to translate strings into ExecuteProcess actions. AssertInStdout was the most 'advanced' assert, so most of the logic in proc_lookup was taken from there

Bugfix

  • While testing this, I also found a bug in proc_info_handler.py. A method name was wrong, and it had parenthesis in the wrong place

Closes

@pbaughman pbaughman self-assigned this Feb 23, 2019
@pbaughman pbaughman mentioned this pull request Feb 23, 2019
2 tasks
@pbaughman
Copy link
Contributor Author

@wjwwood @hidmic This makes all of the assert methods have the same signature (with slightly different defaults). Can one of you do a quick review of this before I merge? Thanks!

Copy link
Collaborator

@wjwwood wjwwood left a comment

Choose a reason for hiding this comment

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

The changes look good to me. There are a lot of style issues if I were reviewing a pr for launch itself (which is not the case here).

I had a few style/nitpick comments inline.

In the end, it's pretty subjective, and so up to you and not a blocker for my 👍 for this review.


@hidmic might have more useful feedback for the actual API design, as he's been working in the launch testing mindset more than me lately.

@@ -64,7 +64,7 @@ def generate_test_description(ready_fn):
class TestTerminatingProcessStops(unittest.TestCase):

def test_proc_terminates(self):
self.proc_info.assertWaitForShutdown(process=dut_process, timeout=10)
self.proc_info.assertWaitForShutdown(proc=dut_process, timeout=10)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems like a step backwards to me...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let me clarify, in my opinion we are going from a good argument/variable name (process) to a less good one (proc). Of course that's in my opinion, due to my preference to avoid abbreviation where ever possible. It makes it easier to search for keywords and it helps people for whom English is not their first language.

There might other places where an abbreviation is being used now where it wasn't before, but that's only one I commented on, even though the same logic would apply in each of those cases.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is obviously subject and we're inconsistent in the ROS 2 project, because we have things like cmd_args or env. So, it's really just in this case, the change here seems like a step backward, but again it's very subjective.

Copy link
Contributor Author

@pbaughman pbaughman Feb 26, 2019

Choose a reason for hiding this comment

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

It's this way because of flake8 (indirectly). When this was apex_rostest, the argument was 'node'. When I changed everything to be apex_launchtest, node became proc instead of 'process' so I wouldn't have to reformat a bunch of lines that were close to the character limit.

It's good feedback about searching and ESL - I can make everything 'process' instead of 'proc' There were other breaking changes in here, so it doesn't make it any more breaking


for proc in resolved_procs: # Nominally just one matching proc
for output in proc_output[proc]:
if msg in output.text.decode('ascii'):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know this isn't new to the pr, but I am curious why this is needed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

To be more specific, why 'ascii' is used, rather than passing no arguments (which is something we do in launch), which will get you 'utf-8':

https://docs.python.org/3/library/stdtypes.html#bytes.decode

Copy link
Contributor Author

@pbaughman pbaughman Feb 26, 2019

Choose a reason for hiding this comment

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

This is a leftover from hacking around with the process_io event. You're correct that it should probably be "passing no arguments" I'll open an issue to update this in a different PR

#17

return list(
map(
lambda x: x.action,
[self._process_name_dict[name][0] for name in self._process_name_dict]
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the reason for the map()? Couldn't you just:

return [processes[0].action for processes in self._process_name_dict.values()]

Also, the [some_dict[name]... for name in some_dict] is a bit weird, as opposed to [value... for value in some_dict.values()].

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, you're right. This is kind of a logic puzzle right now.

Pete Baughman added 2 commits February 27, 2019 10:32
  - Gave all of these methods the same signature.  They can all take ExecuteProcess actions or strings
  - New util to handle the lookup of process actions in one place
@pbaughman
Copy link
Contributor Author

@wjwwood Comments addressed.

@pbaughman pbaughman merged commit e0f07a2 into master Feb 28, 2019
@pbaughman pbaughman deleted the ISSUE7_simplify_asserts branch February 28, 2019 01:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants