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

Updates rust_test to use main.rs as the root when use_libtest_harness is false #1518

Merged
merged 1 commit into from
Aug 29, 2022

Conversation

csmulhern
Copy link
Contributor

Fixes #1516.

Copy link
Collaborator

@UebelAndre UebelAndre left a comment

Choose a reason for hiding this comment

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

Seems like a test needs to be updated to accompany this change? Otherwise seems good to me 😄

(also, sorry for the delay!)

@csmulhern
Copy link
Contributor Author

Seems like a test needs to be updated to accompany this change? Otherwise seems good to me 😄

(also, sorry for the delay!)

Fixed!

(and no worries)

Copy link
Collaborator

@UebelAndre UebelAndre left a comment

Choose a reason for hiding this comment

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

Looks good to me but one clarifying question about the impact of this change.

@@ -36,7 +36,10 @@ def _use_libtest_harness_test():

rust_test(
name = "mytest_noharness",
srcs = ["mytest_noharness.rs"],
srcs = [
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this PR a breaking change? Do test targets with a single source file not using the test harness now require a main.rs or will they be able to function just as they did before?

@csmulhern
Copy link
Contributor Author

Test targets with a single source file not using the test harness function as they did before.

Test targets with multiple source files not using the test harness will break if they had not specified crate_root manually (i.e. they relied on the implicit use of lib.rs as the crate root, and defined a custom main function in their crate).

@UebelAndre
Copy link
Collaborator

Test targets with a single source file not using the test harness function as they did before.

Test targets with multiple source files not using the test harness will break if they had not specified crate_root manually (i.e. they relied on the implicit use of lib.rs as the crate root, and defined a custom main function in their crate).

Would you be willing to add a test case for that? Just a copy of mytest_noharness that continues to use a single source file? 😅

@csmulhern
Copy link
Contributor Author

Done!

Copy link
Collaborator

@UebelAndre UebelAndre left a comment

Choose a reason for hiding this comment

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

Thank you so much!

@UebelAndre UebelAndre enabled auto-merge (squash) August 29, 2022 16:52
@UebelAndre UebelAndre merged commit f5ed797 into bazelbuild:main Aug 29, 2022
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.

rust_test should look for main.rs instead of lib.rs when use_libtest_harness is false
2 participants