-
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.
Merge branch 'main' into auth-for-downloads
- Loading branch information
Showing
8 changed files
with
121 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
load("//cargo:cargo_build_script.bzl", "cargo_build_script") | ||
load("//rust:defs.bzl", "rust_test_suite") | ||
load( | ||
"//rust:rust.bzl", | ||
"rust_library", | ||
"rust_test", | ||
) | ||
|
||
cargo_build_script( | ||
name = "build_script", | ||
srcs = ["build.rs"], | ||
) | ||
|
||
rust_library( | ||
name = "demo_lib", | ||
srcs = [ | ||
"src/lib.rs", | ||
], | ||
deps = [":build_script"], | ||
) | ||
|
||
rust_test( | ||
name = "demo_lib_test", | ||
crate = ":demo_lib", | ||
) | ||
|
||
rust_test_suite( | ||
name = "suite", | ||
srcs = glob(["tests/**"]), | ||
# Add the 'crate' argument, which will be passed as a kwarg | ||
# to the underlying rust_test rules. This will make OUT_DIR | ||
# available when compiling integration tests. | ||
crate = ":demo_lib", | ||
) |
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,11 @@ | ||
use std::env; | ||
use std::fs::File; | ||
use std::io::prelude::*; | ||
use std::path::PathBuf; | ||
|
||
fn main() -> std::io::Result<()> { | ||
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); | ||
let mut file = File::create(out_path.join("test_content.txt"))?; | ||
file.write_all(b"Test content")?; | ||
Ok(()) | ||
} |
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,18 @@ | ||
#[cfg(test)] | ||
mod tests { | ||
use std::env; | ||
|
||
#[test] | ||
fn can_find_the_out_dir_file() { | ||
// The file contents must be included via a macro. | ||
let contents = include_str!(concat!(env!("OUT_DIR"), "/test_content.txt")); | ||
assert_eq!("Test content", contents); | ||
} | ||
|
||
#[test] | ||
fn no_out_dir_at_runtime() { | ||
// Cargo seems to set this at runtime as well, although the documentation | ||
// says it's only available at compile time. | ||
assert!(env::var("OUT_DIR").is_err()); | ||
} | ||
} |
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,15 @@ | ||
use std::env; | ||
|
||
#[test] | ||
fn can_find_the_out_dir_file() { | ||
// The file contents must be included via a macro. | ||
let contents = include_str!(concat!(env!("OUT_DIR"), "/test_content.txt")); | ||
assert_eq!("Test content", contents); | ||
} | ||
|
||
#[test] | ||
fn no_out_dir_at_runtime() { | ||
// Cargo seems to set this at runtime as well, although the documentation | ||
// says it's only available at compile time. | ||
assert!(env::var("OUT_DIR").is_err()); | ||
} |
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