,
{
self.0.arg("--cfg").arg(cfg);
self
}
/// Test the given file, and panics on failure.
pub fn test_file(&mut self, path: P)
where
P: AsRef,
{
let process = self.0.arg("--test").arg(path.as_ref()).spawn();
let result = process
.expect("rustdoc is runnable")
.wait()
.expect("rustdoc can run");
assert!(
result.success(),
format!("Failed to run rustdoc tests on '{:?}'", path.as_ref())
);
}
}
impl Default for Assert {
/// Create an `Assert` instance with the following default parameters:
///
/// * `--library-path` set to the current *deps* directory (`target/debug/deps` or
/// `target/release/deps` depending on the test compilation mode).
///
fn default() -> Self {
let mut assert = Self::new();
let current_exe = std::env::current_exe()
.and_then(|p| p.canonicalize())
.expect("could not get path to test executable");
assert.library_path(current_exe.parent().expect("parent exists"));
assert
}
}
/// Test a single file with default parameters.
pub fn assert_file(documentation: P)
where
P: AsRef,
{
Assert::default().test_file(documentation);
}
docmatic-0.1.2/tests/test_readme.rs 0100666 0001750 0001750 00000000135 13270173571 0015533 0 ustar 00 0000000 0000000 extern crate docmatic;
#[test]
fn test_readme() {
docmatic::assert_file("README.md");
}