,
81 | {
82 | self.0.arg("--cfg").arg(cfg);
83 | self
84 | }
85 |
86 | /// Test the given file, and panics on failure.
87 | pub fn test_file(&mut self, path: P)
88 | where
89 | P: AsRef,
90 | {
91 | let process = self.0.arg("--test").arg(path.as_ref()).spawn();
92 |
93 | let result = process
94 | .expect("rustdoc is runnable")
95 | .wait()
96 | .expect("rustdoc can run");
97 |
98 | assert!(
99 | result.success(),
100 | format!("Failed to run rustdoc tests on '{:?}'", path.as_ref())
101 | );
102 | }
103 | }
104 |
105 | impl Default for Assert {
106 | /// Create an `Assert` instance with the following default parameters:
107 | ///
108 | /// * `--library-path` set to the current *deps* directory (`target/debug/deps` or
109 | /// `target/release/deps` depending on the test compilation mode).
110 | ///
111 | fn default() -> Self {
112 | let mut assert = Self::new();
113 | let current_exe = std::env::current_exe()
114 | .and_then(|p| p.canonicalize())
115 | .expect("could not get path to test executable");
116 | assert.library_path(current_exe.parent().expect("parent exists"));
117 | assert
118 | }
119 | }
120 |
121 | /// Test a single file with default parameters.
122 | pub fn assert_file(documentation: P)
123 | where
124 | P: AsRef,
125 | {
126 | Assert::default().test_file(documentation);
127 | }
128 |
--------------------------------------------------------------------------------
/tests/test_readme.rs:
--------------------------------------------------------------------------------
1 | extern crate docmatic;
2 |
3 | #[test]
4 | fn test_readme() {
5 | docmatic::assert_file("README.md");
6 | }
7 |
--------------------------------------------------------------------------------