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

Migration to RustRover blocked due to no support for "Including the same file in multiple places" #10874

Open
ChrisWhealy opened this issue Oct 3, 2023 · 1 comment

Comments

@ChrisWhealy
Copy link

Environment

  • RustRover 2023.2 EAP
  • Build #RR-232.9921.62, built on September 15, 2023
  • Runtime version: 17.0.8+7-b1000.22 x86_64
  • VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
  • macOS 13.5.2

Problem description

This is a blocker for my migration to Rust Rover...

I have a build script that generates a module containing lots of Rust structs and enums. This works nicely.

However, I want to keep the tests for the generated code separate from the business logic that uses the code, so rather than having an inline test module at the end of the business logic module, I create a separate unit_tests.rs module containing all the tests, then simply finish the business logic module with:

#[cfg(test)]
pub mod unit_tests;

All my Rust projects that use build scripts are structured this way because it makes the code easier to work with as there are often significantly more source lines of code related to testing than there are related to the business logic.

A consequence of this is that the same include!() macro call must be made in both main.rs and unit_tests.rs.

This code structure works fine in VS Code, but RR only evaluates the include!() macro in unit_tests.rs, then throws its toys out of the pram when it encounters the include!() macro call in main.rs

Steps to reproduce

See the coding https://github.com/lighthouse-no/parse-sap-odata-demo

@dima74
Copy link
Member

dima74 commented Nov 9, 2023

@ChrisWhealy As a workaround while it is not fixed, please consider replacing in src/unit_tests.rs:

include!(concat!(env!("OUT_DIR"), "/gwsample_basic.rs"));
use gwsample_basic::*;

to

use super::gwsample_basic::*;

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

No branches or pull requests

2 participants