Skip to content

Commit c88937b

Browse files
committed
Fix bulding the integration tests with cargo build.
The binaries of the integration tests appear as [[bin]] binaries in Cargo so that they can be built with rustc in a future script. This means that they are automatically built with cargo build. That is broken since several of them currently lack main functions. This adds empty main functions to those files and puts the rest of the file content in a submodule marked with #[cfg(test)] to avoid compiler warnings during cargo build. The binaries now do nothing unless compiled with the --test argument. PiperOrigin-RevId: 497193671
1 parent 0fb21f8 commit c88937b

File tree

5 files changed

+340
-310
lines changed

5 files changed

+340
-310
lines changed

googletest/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ test = false
8888

8989
[[bin]]
9090
name = "simple_assertion_failure_with_assert_that"
91-
path = "tests/simple_assertion_failure_with_assert_that.rs"
91+
path = "integration_tests/simple_assertion_failure_with_assert_that.rs"
9292
test = false
9393

9494
[[bin]]

googletest/integration_tests/assert_predicate_with_failure.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,20 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use googletest::assert_pred;
15+
fn main() {}
1616

17-
#[test]
18-
fn assert_predicate_with_failure() {
19-
let a = 1;
20-
let b = 2;
21-
assert_pred!(eq_predicate(a, b));
22-
}
17+
#[cfg(test)]
18+
mod tests {
19+
use googletest::assert_pred;
20+
21+
#[test]
22+
fn assert_predicate_with_failure() {
23+
let a = 1;
24+
let b = 2;
25+
assert_pred!(eq_predicate(a, b));
26+
}
2327

24-
fn eq_predicate(a: i32, b: i32) -> bool {
25-
a == b
28+
fn eq_predicate(a: i32, b: i32) -> bool {
29+
a == b
30+
}
2631
}

0 commit comments

Comments
 (0)