Skip to content

Commit

Permalink
chore: Fix swf doctests working directory
Browse files Browse the repository at this point in the history
Rust 12-09 nightly changed the working dir of doctests to be the
workspace root instead of the subcrate root. This broke the
doctests for swf. Now do some setup to ensure the same working
directory on both stable and nightly.

cc rust-lang/cargo#8954
  • Loading branch information
Herschel committed Dec 10, 2020
1 parent 83fcd7b commit ec3f262
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions swf/src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use std::io::{self, Read};
///
/// # Example
/// ```
/// # std::env::set_current_dir(env!("CARGO_MANIFEST_DIR"));
/// let data = std::fs::read("tests/swfs/DefineSprite.swf").unwrap();
/// let swf = swf::read_swf(&data[..]).unwrap();
/// println!("Number of frames: {}", swf.header.num_frames);
Expand Down Expand Up @@ -74,6 +75,7 @@ pub fn read_swf<R: Read>(input: R) -> Result<Swf> {
///
/// # Example
/// ```
/// # std::env::set_current_dir(env!("CARGO_MANIFEST_DIR"));
/// let data = std::fs::read("tests/swfs/DefineSprite.swf").unwrap();
/// let swf_stream = swf::read_swf_header(&data[..]).unwrap();
/// println!("FPS: {}", swf_stream.header.frame_rate);
Expand Down Expand Up @@ -367,6 +369,7 @@ impl<R: Read> Reader<R> {
/// Reads the next SWF tag from the stream.
/// # Example
/// ```
/// # std::env::set_current_dir(env!("CARGO_MANIFEST_DIR"));
/// let data = std::fs::read("tests/swfs/DefineSprite.swf").unwrap();
/// let mut swf_stream = swf::read_swf_header(&data[..]).unwrap();
/// while let Ok(tag) = swf_stream.reader.read_tag() {
Expand Down

0 comments on commit ec3f262

Please sign in to comment.