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

Improvements around test_pidfile_contents #1328

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

The test previously admitted some good values as bad.  The implementation also
allowed some nonsense values to come out of the parser.
@exarkun
Copy link
Member Author

exarkun commented Aug 9, 2023

This still fails, at least because str.split and the \w regexp disagree about whether \u2000 is whitespace or not.

@@ -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")
Copy link
Member Author

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}")
Copy link
Member Author

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.

@coveralls
Copy link
Collaborator

Coverage Status

coverage: 94.541% (-0.02%) from 94.556% when pulling b744c76 on exarkun:4058.test_pidfile_contents into d0e1d8e on tahoe-lafs:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants