Skip to content

Tests: Re-design skip-function-bodies.swift test #68758

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

Merged
merged 1 commit into from
Sep 26, 2023

Conversation

tshortli
Copy link
Contributor

The skip-function-bodies.swift test previously relied on -emit-sorted-sil to control the order of SIL emission for matching CHECK: lines. I found that this made the test too difficult to evolve, so I've re-written the test to instead check SILGen's output by extracting just the string_literal lines and then sorting them. This makes it much more straightforward to add new test cases at the right location in the file.

There are a number of additional improvements to the test:

  • SILGen without any function body skipping is now checked as a baseline to ensure that all the checks are in the right order. Previously, most of the negative CHECK lines were not properly ordered in the file, so they could have missed regressions.
  • Every declaration in the test has a set of exhaustive CHECK lines covering each of the outputs explicitly. While more verbose, it should be clearer what is expected for every declaration.
  • Module interfaces are emitted with the proper flags and are typechecked to verify they are valid.
  • Superfluous diagnostics (e.g. unused variables) have been minimized to improve the experience of debugging failures.

The skip-function-bodies.swift test previously relied on `-emit-sorted-sil` to
control the order of SIL emission for matching CHECK: lines. I found that this
made the test too difficult to evolve, so I've re-written the test to instead
check SILGen's output by extracting just the `string_literal` lines and then
sorting them. This makes it much more straightforward to add new test cases at
the right location in the file.

There are a number of additional improvements to the test:
- SILGen without any function body skipping is now checked as a baseline to
  ensure that all the checks are in the right order. Previously, most of the
  negative CHECK lines were not properly ordered in the file, so they could have
  missed regressions.
- Every declaration in the test has a set of exhaustive CHECK lines covering
  each of the outputs explicitly. While more verbose, it should be clearer what
  is expected for every declaration.
- Module interfaces are emitted with the proper flags and are typechecked to
  verify they are valid.
- Superfluous diagnostics (e.g. unused variables) have been minimized to
  improve the experience of debugging failures.
@tshortli tshortli force-pushed the rewrite-skip-function-bodies-test branch from 03c2c24 to 43e36cc Compare September 26, 2023 17:22
@tshortli
Copy link
Contributor Author

@swift-ci please smoke test and merge

@swift-ci swift-ci merged commit 7efc3c8 into swiftlang:main Sep 26, 2023
@tshortli
Copy link
Contributor Author

Reverting here since this broke Windows CI but was auto-merged anyways: #68770

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.

2 participants