-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The
compile_data
attribute can now be gathered from dependencies
- Loading branch information
1 parent
c9345d3
commit 41370be
Showing
8 changed files
with
53 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
load("//rust:defs.bzl", "rust_library", "rust_test") | ||
|
||
# Note that this is the only target which assigns the `compile_data` attribute | ||
rust_library( | ||
name = "compile_data", | ||
srcs = ["compile_data.rs"], | ||
compile_data = ["compile_data.txt"], | ||
edition = "2018", | ||
) | ||
|
||
rust_test( | ||
name = "compile_data_unit_test", | ||
crate = ":compile_data", | ||
) | ||
|
||
rust_test( | ||
name = "compile_data_integration_test", | ||
srcs = ["compile_data_test.rs"], | ||
edition = "2018", | ||
deps = [":compile_data"], | ||
) |
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,9 @@ | ||
/// Data loaded from compile data | ||
pub const COMPILE_DATA: &'static str = include_str!("compile_data.txt"); | ||
|
||
/// A test that is expected to be compiled from a target that does not | ||
/// directly populate the `compile_data` attribute | ||
#[test] | ||
fn test_compile_data_contents() { | ||
assert_eq!(COMPILE_DATA, "compile data contents\n"); | ||
} |
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 @@ | ||
compile data contents |
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,9 @@ | ||
use compile_data::COMPILE_DATA; | ||
|
||
#[test] | ||
fn test_compile_data_contents() { | ||
// This would confirm that the constant that's compiled into the `compile_data` | ||
// crate matches the data loaded at compile time here. Where `compile_data.txt` | ||
// would have only been provided by the `compile_data` crate itself. | ||
assert_eq!(COMPILE_DATA, include_str!("compile_data.txt")); | ||
} |