pub struct DnyRun {
pub main_code: String,
pub deps: String,
pub is_release: bool,
/* private fields */
}Available on crate feature
dyntest only.Expand description
单个临时 Cargo 工程的句柄:在 target/dyn_tests/dny_<id>/ 下生成工程并编译执行,Drop 时释放心跳锁。
§Feature Requirement
需要同时启用 "dyntest" 与 "std" 特性。
Fields§
§main_code: String待编译运行的 main.rs 源码。
deps: String[dependencies] 依赖声明片段。
is_release: bool是否以 --release 编译运行。
Implementations§
Source§impl DnyRun
impl DnyRun
Sourcepub fn clear_envs(&mut self) -> &mut Self
pub fn clear_envs(&mut self) -> &mut Self
Sourcepub fn cargo_config(&mut self, config: impl Into<String>) -> &mut Self
pub fn cargo_config(&mut self, config: impl Into<String>) -> &mut Self
Sourcepub fn clear_cargo_config(&mut self) -> &mut Self
pub fn clear_cargo_config(&mut self) -> &mut Self
Sourcepub fn sync_files(&self)
pub fn sync_files(&self)
Sourcepub fn build(&self, timeout: Option<Duration>) -> DnyResult
pub fn build(&self, timeout: Option<Duration>) -> DnyResult
执行 cargo build(is_release 为真时加 --release),超时则终止并记为 SystemError::Timeout;自身不 panic,失败均体现在返回的 DnyResult 中。
§Feature Requirement
需要同时启用 "dyntest" 与 "std" 特性。
§Examples
use lib_unknown::dyntest::DnyRun;
let res = DnyRun::new("fn main() {}", "").build(None);
assert!(res.ok);Sourcepub fn run_no_build(
&self,
timeout: Option<Duration>,
build_result: Option<DnyResult>,
) -> DnyResult
pub fn run_no_build( &self, timeout: Option<Duration>, build_result: Option<DnyResult>, ) -> DnyResult
不重新编译,直接运行已有产物(产物缺失时返回 SystemError::ProcessSpawnFailed 结果)。
build_result 用于透传编译耗时,无则置零。
§Feature Requirement
需要同时启用 "dyntest" 与 "std" 特性。
Sourcepub fn reset_main_code(&mut self, main_code: &str)
pub fn reset_main_code(&mut self, main_code: &str)
Sourcepub fn reset_deps(&mut self, deps: &str)
pub fn reset_deps(&mut self, deps: &str)
Auto Trait Implementations§
impl !RefUnwindSafe for DnyRun
impl !UnwindSafe for DnyRun
impl Freeze for DnyRun
impl Send for DnyRun
impl Sync for DnyRun
impl Unpin for DnyRun
impl UnsafeUnpin for DnyRun
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