Skip to content

Commit

Permalink
Re-add removed test
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-mccall committed Oct 29, 2024
1 parent e5a23d5 commit 534a8ab
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 0 deletions.
47 changes: 47 additions & 0 deletions test/empty_suite/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
load("//rust:defs.bzl", "rust_library", "rust_test", "rust_test_suite")

# This package has a rust_test_suite containing no tests.
# (This could happen if the srcs were seleceted via a glob).
#
# We test that the test suite exists and is empty, bypassing test_suite's
# special-case behavior for empty suites.

rust_library(
name = "code",
srcs = ["src/code.rs"],
edition = "2018",
)

rust_test(
name = "unrelated_unittest",
crate = "code",
edition = "2018",
)

rust_test(
name = "unrelated_test",
srcs = ["src/unrelated_test.rs"],
edition = "2018",
deps = [":code"],
)

rust_test_suite(
name = "suite",
srcs = [],
edition = "2018",
)

# This verifies the suite exists, and calculates its contents.
genquery(
name = "deps",
expression = "deps(//test/empty_suite:suite, 1) - //test/empty_suite:suite",
scope = [":suite"],
)

# Test that the suite is empty.
sh_test(
name = "deps_test",
srcs = ["verify_empty.sh"],
args = ["$(location :deps)"],
data = [":deps"],
)
7 changes: 7 additions & 0 deletions test/empty_suite/src/code.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pub fn hello() {}

#[cfg(test)]
#[test]
fn test_unit() {
hello()
}
4 changes: 4 additions & 0 deletions test/empty_suite/src/unrelated_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#[test]
pub fn test_hello() {
code::hello()
}
7 changes: 7 additions & 0 deletions test/empty_suite/verify_empty.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
# Verifies that argv[1] is an empty file.

set -eux

test -f $1
test ! -s $1

0 comments on commit 534a8ab

Please sign in to comment.