Skip to content

tests: Read tool args in test files #14144

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 2 commits into from
Jan 26, 2022

Conversation

dwijnand
Copy link
Member

@dwijnand dwijnand commented Dec 20, 2021

No description provided.

@dwijnand dwijnand marked this pull request as ready for review December 20, 2021 13:33
@som-snytt
Copy link
Contributor

Forgot to say thanks for picking up this handy idiom.

In return, I'm going to work on my ticket about test ignoring my options.

@dwijnand dwijnand force-pushed the tests/read-tool-args branch 2 times, most recently from a6a0804 to d6b01fe Compare December 20, 2021 14:37
@dwijnand dwijnand force-pushed the tests/read-tool-args branch from d6b01fe to eb4b8cb Compare January 11, 2022 13:22
@dwijnand dwijnand marked this pull request as draft January 13, 2022 09:28
@dwijnand dwijnand force-pushed the tests/read-tool-args branch from eb4b8cb to 643314d Compare January 14, 2022 10:17
@dwijnand dwijnand marked this pull request as ready for review January 15, 2022 10:44
@dwijnand dwijnand assigned nicolasstucki and unassigned dwijnand Jan 15, 2022
Copy link
Contributor

@nicolasstucki nicolasstucki left a comment

Choose a reason for hiding this comment

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

Otherwise LGRM

@@ -58,7 +59,8 @@ def toolArgsParse(lines: List[String]): List[String] = {
val endc = "*" + "/" // be forgiving of /* scalac: ... */
def stripped(s: String) = s.substring(s.indexOf(tag) + tag.length).stripSuffix(endc)
val args = lines.to(LazyList).take(10).filter { s =>
s.contains("// " + tag)
s.contains("//" + tag)
|| s.contains("// " + tag)
|| s.contains("/* " + tag)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these also be accepted?

  • "// " + tag with 2 or more spaces or a tab
  • "/*" + tag with no spaces

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should consider a regex

Copy link
Member Author

Choose a reason for hiding this comment

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

Less (ways) is more, IMO. I wouldn't have even added "/* ", but someone did back in scala/scala so I kept it.

Copy link
Contributor

Choose a reason for hiding this comment

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

They're called s'mores for a reason. I see partest doesn't look at opening comment. Could filter on tag and then on open comment preceding it. As sample UX, I learned yesterday that commenting out an // error line does not suppress the error expectation. So temporarily commenting out requires two edits. My takeaway is that a test can be forgiving, but should help disallow "my check file was not used" or "my options were not used" and I didn't know it and the test has been broken all along.

@dwijnand dwijnand merged commit 74d1b82 into scala:master Jan 26, 2022
@dwijnand dwijnand deleted the tests/read-tool-args branch January 26, 2022 09:07
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.

3 participants