Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add rustdoc test support and change logger output
We add the missing component for tests here which is doctests! We now have rustdoc integrated with it's own module like rustc. This commit does a few things in particular: - Add support to run rustdoc tests - Add a doctest to Rustc for testing purposes - Changes the logging output to be more consistent with cargo's minus coloring - Removes some logging from building test binaries so as not to be confusing as to what's going on which is building test binaries, not the freight library per se
- Loading branch information
Showing
5 changed files
with
129 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,9 @@ | ||
/target | ||
.direnv | ||
|
||
|
||
# Added by cargo | ||
# | ||
# already existing elements were commented out | ||
|
||
#/target |
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,40 @@ | ||
use super::Result; | ||
use crate::rustc::Edition; | ||
use std::path::Path; | ||
use std::path::PathBuf; | ||
use std::process::Command; | ||
|
||
pub struct RustDoc { | ||
edition: Edition, | ||
crate_name: String, | ||
lib_path: PathBuf, | ||
} | ||
|
||
impl RustDoc { | ||
pub fn new( | ||
edition: Edition, | ||
crate_name: impl Into<String>, | ||
lib_path: impl Into<PathBuf>, | ||
) -> Self { | ||
Self { | ||
edition, | ||
crate_name: crate_name.into(), | ||
lib_path: lib_path.into(), | ||
} | ||
} | ||
pub fn test(&self, path: impl AsRef<Path>) -> Result<()> { | ||
let path = path.as_ref(); | ||
Command::new("rustdoc") | ||
.arg("--test") | ||
.arg(path) | ||
.arg("--crate-name") | ||
.arg(&self.crate_name) | ||
.arg("--edition") | ||
.arg(self.edition.to_string()) | ||
.arg("-L") | ||
.arg(&self.lib_path) | ||
.spawn()? | ||
.wait()?; | ||
Ok(()) | ||
} | ||
} |