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

Make the 'library' lines in tests use a substitution. #4278

Merged
merged 3 commits into from
Sep 10, 2024

Conversation

jonmeow
Copy link
Contributor

@jonmeow jonmeow commented Sep 5, 2024

This opens the door for replacing all library ... lines in toolchain test files with library "[[@TEST_NAME]]";. That's technically more typing in a lot of cases, but OTOH means we can just do some copy-paste boilerplate and stop carefully writing library names.

Also cleans up the test setup, because it's getting messy. I'm trying to make it easier to see the divisions of tests and the output associated with them. StringSwitch looked like a way to do this, with a few edits to make it work nicely.

Copy link
Contributor

@chandlerc chandlerc left a comment

Choose a reason for hiding this comment

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

Nice, some fairly minor comments inline.

@zygoloid - also curious if you think this will be a help with boiler plate by making it (much) more regular?

static constexpr llvm::StringLiteral TestName = "[[@TEST_NAME]]";
auto keyword = llvm::StringRef(*content).substr(keyword_pos);
if (keyword.starts_with(TestName)) {
keyword = TestName;
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious why this is assigned here, it doesn't seem to be used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cleaned up

Copy link
Contributor

@zygoloid zygoloid left a comment

Choose a reason for hiding this comment

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

@zygoloid - also curious if you think this will be a help with boiler plate by making it (much) more regular?

I think it'll make copy-pasting files within a split-file test easier. I think this would be a win (but a small one).

// Replaces the content keywords.
//
// TEST_NAME is the only content keyword at present, but we do validate that
// other names
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing end of sentence?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

Choose a reason for hiding this comment

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

Has this change been pushed yet? (I don't see the updated file here.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

re-pushed

@zygoloid zygoloid added this pull request to the merge queue Sep 10, 2024
Merged via the queue into carbon-language:trunk with commit 2e299f5 Sep 10, 2024
8 checks passed
@jonmeow jonmeow deleted the lib branch September 10, 2024 20:48
github-merge-queue bot pushed a commit that referenced this pull request Sep 10, 2024
Applies #4278 TEST_NAME substitution to tests. Note I've tried to
structure commits as:

1. Do all the replacements.
2. autoupdate (nothing else) -- this shows incorrect updates.
3. Fix up manually, including autoupdates to get back to original
output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants