-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Build rust_test targets using a crate name different from the…
… underlying lib" (#2815) This reverts commit b4ccc97. That commit makes a behavior change, and thus should have been protected by a feature flag. This will be done in a future PR.
- Loading branch information
Showing
8 changed files
with
99 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
load(":rust_test_outputs.bzl", "rust_test_outputs_test_suite") | ||
|
||
############################ UNIT TESTS ############################# | ||
rust_test_outputs_test_suite(name = "rust_test_outputs_test_suite") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub fn main() {} |
64 changes: 64 additions & 0 deletions
64
test/unit/rust_test_outputs_are_in_subdirectory/rust_test_outputs.bzl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
"""Tests for rust_test outputs directory.""" | ||
|
||
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") | ||
load("//rust:defs.bzl", "rust_binary", "rust_common", "rust_test") | ||
|
||
def _rust_test_outputs_test(ctx): | ||
env = analysistest.begin(ctx) | ||
tut = analysistest.target_under_test(env) | ||
|
||
output = tut[rust_common.crate_info].output | ||
|
||
asserts.true(env, output.dirname.split("/")[-1].startswith("test-")) | ||
|
||
return analysistest.end(env) | ||
|
||
rust_test_outputs_test = analysistest.make( | ||
_rust_test_outputs_test, | ||
) | ||
|
||
def _rust_test_outputs_targets(): | ||
rust_binary( | ||
name = "bin_outputs", | ||
srcs = ["foo.rs"], | ||
edition = "2018", | ||
) | ||
|
||
rust_test( | ||
name = "test_outputs_with_srcs", | ||
srcs = ["foo.rs"], | ||
edition = "2018", | ||
) | ||
|
||
rust_test_outputs_test( | ||
name = "rust_test_outputs_using_srcs_attr", | ||
target_under_test = ":test_outputs_with_srcs", | ||
) | ||
|
||
rust_test( | ||
name = "test_outputs_with_crate", | ||
crate = "bin_outputs", | ||
edition = "2018", | ||
) | ||
|
||
rust_test_outputs_test( | ||
name = "rust_test_outputs_using_crate_attr", | ||
target_under_test = ":test_outputs_with_crate", | ||
) | ||
|
||
def rust_test_outputs_test_suite(name): | ||
"""Entry-point macro called from the BUILD file. | ||
Args: | ||
name: Name of the macro. | ||
""" | ||
|
||
_rust_test_outputs_targets() | ||
|
||
native.test_suite( | ||
name = name, | ||
tests = [ | ||
":rust_test_outputs_using_srcs_attr", | ||
":rust_test_outputs_using_crate_attr", | ||
], | ||
) |