pub struct DnyTask {
pub tag: String,
pub main_code: String,
pub deps: String,
pub envs: HashMap<String, String>,
pub cargo_config: Option<String>,
pub is_release: bool,
}Available on crate feature
dyntest only.Expand description
单个动态测试任务:main.rs 内容、依赖与运行配置的 Builder。
§Feature Requirement
需要同时启用 "dyntest" 与 "std" 特性。
§Examples
use lib_unknown::dyntest::DnyTask;
let task = DnyTask::new("hello", r#"fn main() { println!("hi"); }"#)
.with_deps(r#"serde = "1""#)
.with_env("RUST_BACKTRACE", "1")
.with_release(false);
assert_eq!(task.tag, "hello");Fields§
§tag: String任务标识,用于结果回调用例区分;From 元组缺省时为 "unnamed_task"。
main_code: String待编译运行的 main.rs 源码。
deps: String追加到临时工程 [dependencies] 的依赖声明片段。
envs: HashMap<String, String>注入子进程的环境变量。
cargo_config: Option<String>写入临时工程 .cargo/config.toml 的配置,无则为 None。
is_release: bool是否以 --release 编译运行。
Implementations§
Source§impl DnyTask
impl DnyTask
Sourcepub fn with_cargo_config(self, config: impl Into<String>) -> Self
pub fn with_cargo_config(self, config: impl Into<String>) -> Self
Sourcepub fn with_release(self, release: bool) -> Self
pub fn with_release(self, release: bool) -> Self
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DnyTask
impl RefUnwindSafe for DnyTask
impl Send for DnyTask
impl Sync for DnyTask
impl Unpin for DnyTask
impl UnsafeUnpin for DnyTask
impl UnwindSafe for DnyTask
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more