forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#131859 - chriskrycho:update-trpl, r=onur-ozkan
Update TRPL to add new Chapter 17: Async and Await - Add support to `rustbook` to pass through the `-L`/`--library-path` flag to `mdbook` so that references to the `trpl` crate - Build the `trpl` crate as part of the book tests. Make it straightforward to add other such book dependencies in the future if needed by implementing that in a fairly general way. - Update the submodule for the book to pull in the new chapter on async and await, as well as a number of other fixes. This will happen organically/automatically in a week, too, but this lets me group this change with the next one: - Update the compiler messages which reference the existing chapters 17–20, which are now chapters 18-21. There are only two, both previously referencing chapter 18. - Update the UI tests which reference the compiler message outputs.
- Loading branch information
Showing
82 changed files
with
297 additions
and
219 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
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
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
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
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 |
---|---|---|
|
@@ -31,6 +31,20 @@ fn main() { | |
(Defaults to the current directory when omitted)") | ||
.value_parser(clap::value_parser!(PathBuf)); | ||
|
||
// Note: we don't parse this into a `PathBuf` because it is comma separated | ||
// strings *and* we will ultimately pass it into `MDBook::test()`, which | ||
// accepts `Vec<&str>`. Although it is a bit annoying that `-l/--lang` and | ||
// `-L/--library-path` are so close, this is the same set of arguments we | ||
// would pass when invoking mdbook on the CLI, so making them match when | ||
// invoking rustbook makes for good consistency. | ||
let library_path_arg = arg!( | ||
-L --"library-path" <PATHS> | ||
"A comma-separated list of directories to add to the crate search\n\ | ||
path when building tests" | ||
) | ||
.required(false) | ||
.value_parser(parse_library_paths); | ||
|
||
let matches = Command::new("rustbook") | ||
.about("Build a book with mdBook") | ||
.author("Steve Klabnik <[email protected]>") | ||
|
@@ -48,11 +62,12 @@ fn main() { | |
.subcommand( | ||
Command::new("test") | ||
.about("Tests that a book's Rust code samples compile") | ||
.arg(dir_arg), | ||
.arg(dir_arg) | ||
.arg(library_path_arg), | ||
) | ||
.get_matches(); | ||
|
||
// Check which subcomamnd the user ran... | ||
// Check which subcommand the user ran... | ||
match matches.subcommand() { | ||
Some(("build", sub_matches)) => { | ||
if let Err(e) = build(sub_matches) { | ||
|
@@ -113,8 +128,12 @@ pub fn build(args: &ArgMatches) -> Result3<()> { | |
|
||
fn test(args: &ArgMatches) -> Result3<()> { | ||
let book_dir = get_book_dir(args); | ||
let library_paths = args | ||
.try_get_one::<Vec<String>>("library-path")? | ||
.map(|v| v.iter().map(|s| s.as_str()).collect::<Vec<&str>>()) | ||
.unwrap_or_default(); | ||
let mut book = load_book(&book_dir)?; | ||
book.test(vec![]) | ||
book.test(library_paths) | ||
} | ||
|
||
fn get_book_dir(args: &ArgMatches) -> PathBuf { | ||
|
@@ -132,12 +151,16 @@ fn load_book(book_dir: &Path) -> Result3<MDBook> { | |
Ok(book) | ||
} | ||
|
||
fn parse_library_paths(input: &str) -> Result<Vec<String>, String> { | ||
Ok(input.split(",").map(String::from).collect()) | ||
} | ||
|
||
fn handle_error(error: mdbook::errors::Error) -> ! { | ||
eprintln!("Error: {}", error); | ||
|
||
for cause in error.chain().skip(1) { | ||
eprintln!("\tCaused By: {}", cause); | ||
} | ||
|
||
::std::process::exit(101); | ||
std::process::exit(101); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.