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

Some tweaks to testing framework. #4594

Merged
merged 1 commit into from
Sep 11, 2024

Conversation

mwichmann
Copy link
Collaborator

Most interesting is an "API change" - the test methods test.must_exist() and test.must_exist_one_of() now take an optional message keyword argument which is passed on to fail_test if the test fails to add to the failure message on stderr - a couple of test checks already did this, so this is just an extension of an existing technique.

The regex used to test exception printing in TestCommonTests is now working for Python 3.13, and enabled conditionally - Python's "enhanced error reporting" changed again, in a way that made it easy to reuse the existing regex (if somebody wants to take a shot at unifying them, more power!). This only shows up in the (not-default) runtest.py testing/framework.

Also, one unexpected issue was found - one of the check routines does output = os.newline.join(output), but there is no os.newline. Could be that os.linesep was intended, but just changed it to the Python newline character.

Some annotations added, and some cleanup done on possibly unsafe uses - mainly that self.stderr() and selt.stdout() can return None, but several places in the code just did string operations on the return unconditionally. There's already precendent- other places did do a check before using, so just extended the concept to possibly vulnerable palces.

Test-framework only changed. Since this isn't user-visible, no additon to RELEASE.

Contributor Checklist:

  • I have created a new test or updated the unit tests to cover the new/changed functionality.
  • I have updated CHANGES.txt (and read the README.rst)
  • I have updated the appropriate documentation

@mwichmann mwichmann added the testsuite Things that only affect the SCons testing. Do not use just because a PR has tests. label Sep 10, 2024
Most interesting is an "api change" - the test methods test.must_exist()
and test.must_exist_one_of() now take an optional 'message' keyword
argument which is passed on to fail_test() if the test fails.

The regex used to test an exception is now working for Python 3.13,
and enabled conditionally - the "enhanced error reporting" changed, in
a way that made it easy to reuse the existing regex (if somebody wants
to take a shot at unifying them, more power!).

Also one unexpected issue was found - one of the check routines does
"output = os.newline.join(output)", but there is no os.newline.  Could use
os.linesep, but just changed it to the Python newline character.

Some annotations added, and some cleanup done on possibly unsafe uses
- mainly that self.stderr() and selt.stdout() *can* return None, but
several places in the code just did string operations on the return
unconditionally. There's already precendent- other places did do a check
before using, so just extended the concept to possibly vulnerable palces.

Signed-off-by: Mats Wichmann <[email protected]>
@bdbaddog bdbaddog merged commit 159f77e into SCons:master Sep 11, 2024
8 of 10 checks passed
@mwichmann mwichmann added this to the NextRelease milestone Sep 11, 2024
@mwichmann mwichmann deleted the testing/fw-message branch September 11, 2024 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testsuite Things that only affect the SCons testing. Do not use just because a PR has tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants