-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add an option to skip building binaries when there are integration tests #12980
Comments
Thanks for the report. At this moment, some workarounds I can think of:
|
Another workaround is to create a |
@xxchan to help us better understand the problem, you specifically are having,
|
Good question. I guess you are asking why we have both bins and integration tests and run into this problem. In our example,
I think there were no specific reasons when it was introduced, unit tests should also work. However, recently we are preferring integration tests and adding
No specific reasons also. I think this way is natural to reuse common lib to build different binaries. It would be more troublesome to add a new package. Our workspace is quite large, so I guess developers tend not to add more packages when we can put related stuff in a package. It just works. |
I would like to bring this up again. My use-case consists of
Let's say this is my only integration test. (I would clearly see that as an integration test, as it is testing the binary as a whole).
Running
Where point 1 is useless, and could be really slow/expensive, even more so in (potentially slow) cloud CI/CD tools. Automatically compiling a binary for integration tests is of course generally the correct thing to do, as devs will most-likely be able to simply launch it and test against it. I would like to propose an optional annotation, available on integration-tests, instructing cargo that that specific test does not need a compiled binary, as in:
With a logic in cargo as of: "if all integration-test specify that the binary named X is not needed , do not compile the binary before executing tests" |
As @lpotthast brings up, another way of working around this is to use a workspace. While their case is a little different, it sounds like for @xxchan that they are mixing For @lpotthast it sounds like things are a little different, that their "integration" tests are being built and run on the host but inside of them, they then perform a cross-compilation and execution of the bin. In that case, another workaround is to instead build the binary and tests for the cross-compiled architecture and run all of them in the container.
This gets messy and is unlikely to happen. One way to implement this is for the compiler to emit a message that a test requires the integration test (or not). If we were to be most optimal, we'd then need to re-implement test harness filtering to know whether it is needed for this run and then decide whether to build the binary. This defers a major decision of the build graph to late in the process and creates a level of compiler, test harness, and cargo integration we likely don't want. Another way to implement this is for cargo to build the test and then run it in discovery mode, see anything needs the binary, and then build it. This defers the build graph decision even later and still increases the API surfave area of the test harness. |
Skipping the final link could be a workaround also for #3501, particularly with |
Problem
https://doc.rust-lang.org/cargo/reference/cargo-targets.html#integration-tests
#7958
We want to skip it because we don't use this feature, and our project is very slow to compile.
Here we wasted a lot of time to build the unnecessary bins.
Some other users may have other reasons e.g., #7958 (comment).
Proposed Solution
I feel this is kind of similar to disable auto-discovery https://doc.rust-lang.org/cargo/reference/cargo-targets.html#target-auto-discovery
So maybe we can add an option like
build-bins-for-integration-tests
(Can't come up with a good name, sorry)Notes
No response
The text was updated successfully, but these errors were encountered: