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

[jvm] Hook up the ability to run JUnit tests written in Scala #13868

Merged
merged 3 commits into from Dec 13, 2021

Conversation

stuhood
Copy link
Sponsor Member

@stuhood stuhood commented Dec 13, 2021

The scala_junit_tests target was added in #13130, and became compilable from the JUnit @rules in #13519. The final piece to enable actual usage is to allow the JUnit @rules to match non-Java sources.

This change adds the JunitTestSourceField marker, which is extended by JavaJunitTestSourceField and ScalaJunitTestSourceField, and tests that JUnit tests can be written in Scala.

[ci skip-rust]

…rceField for junit test files.

[ci skip-rust]
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]
@stuhood stuhood changed the title [jmv] Hook up the ability to run JUnit tests written in Scala [jvm] Hook up the ability to run JUnit tests written in Scala Dec 13, 2021
@stuhood stuhood enabled auto-merge (squash) December 13, 2021 22:19
Copy link
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

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

Neat!

# -----------------------------------------------------------------------------------------------


class JunitTestSourceField(SingleSourceField, metaclass=ABCMeta):
Copy link
Contributor

Choose a reason for hiding this comment

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

It's confusing imo for this to subclass SingleSourceField and then for the subclasses of this to also subclass JavaSourceField and ScalaSourceField. it works, but confusing.

Instead, I recommend calling this JunitTestSourceMixin, and it's nothing more than a marker type. Doesn't subclass anything, not even ABCMeta.

Copy link
Sponsor Member Author

@stuhood stuhood Dec 13, 2021

Choose a reason for hiding this comment

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

That won't work I don't think: this does actually need to be a SourcesField subclass, because it is used with a FieldSet.

Comment on lines -146 to -152
class JvmRequirementsField(SpecialCasedDependencies):
alias = "requirements"
required = True
help = (
"A sequence of addresses to targets compatible with `jvm_artifact` that specify the coordinates for "
"third-party JVM dependencies."
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, I was about to delete this :)

@stuhood stuhood merged commit b99c9e5 into pantsbuild:main Dec 13, 2021
@stuhood stuhood deleted the stuhood/junit-for-scala branch December 13, 2021 23:00
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.

None yet

2 participants