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
Improvements around test_pidfile_contents #1328
base: master
Are you sure you want to change the base?
Conversation
The test previously admitted some good values as bad. The implementation also allowed some nonsense values to come out of the parser.
This still fails, at least because |
@@ -264,17 +265,49 @@ def test_non_numeric_pid(self): | |||
self.assertThat(runs, Equals([])) | |||
self.assertThat(result_code, Equals(1)) | |||
|
|||
good_file_content_re = re.compile(r"\w[0-9]*\w[0-9]*\w") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I greatly elaborated this regular expression and removed some subtle inconsistencies with the real parser but note that apart from getting much longer a significant change here is going from \w
("word character") to \s
("whitespace character") - a pretty dramatic inconsistency, I think.
@@ -49,6 +53,8 @@ def parse_pidfile(pidfile): | |||
pidfile | |||
) | |||
) | |||
if pid <= 0 or starttime < 0: | |||
raise InvalidPidFile(f"Found value out of bounds: pid={pid} time={starttime}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even though these values pass through our simple parser above, we know that they are semantically nonsensical so we can exclude them here rather than letting them reach other parts of the system.
https://tahoe-lafs.org/trac/tahoe-lafs/ticket/3983
https://tahoe-lafs.org/trac/tahoe-lafs/ticket/3984
https://tahoe-lafs.org/trac/tahoe-lafs/ticket/4058