diff --git a/src/docbuilder/rustwide_builder.rs b/src/docbuilder/rustwide_builder.rs index 7d604bedc..97a144929 100644 --- a/src/docbuilder/rustwide_builder.rs +++ b/src/docbuilder/rustwide_builder.rs @@ -34,6 +34,7 @@ const USER_AGENT: &str = "docs.rs builder (https://github.com/rust-lang/docs.rs) const COMPONENTS: &[&str] = &["llvm-tools-preview", "rustc-dev", "rustfmt"]; const DUMMY_CRATE_NAME: &str = "empty-library"; const DUMMY_CRATE_VERSION: &str = "1.0.0"; +const DUMMY_CRATE_PUBLISHER_ID: &str = "2299951"; // pietroalbini #[derive(Debug)] pub enum PackageKind<'a> { @@ -1129,6 +1130,42 @@ mod tests { }) } + #[test] + #[ignore] + fn test_artifact_cache() { + wrapper(|env| { + let crate_ = DUMMY_CRATE_NAME; + let version = DUMMY_CRATE_VERSION; + let expected_cache_dir = env + .config() + .prefix + .join("artifact_cache") + .join(DUMMY_CRATE_PUBLISHER_ID); + + let mut builder = RustwideBuilder::init(env).unwrap(); + + // first build creates the cache + assert!(!expected_cache_dir.exists()); + assert!(builder.build_package(crate_, version, PackageKind::CratesIo)?); + assert!(expected_cache_dir.exists()); + + // cache dir doesn't contain doc output + assert!(!expected_cache_dir.join("doc").exists()); + + // but seems to be a normal cargo target directory + for expected_file in &["CACHEDIR.TAG", "debug"] { + assert!(expected_cache_dir.join(expected_file).exists()); + } + + // do a second build + assert!(builder.build_package(crate_, version, PackageKind::CratesIo)?); + + // FIXME: how would I know if the cache was used? + + Ok(()) + }); + } + #[test] #[ignore] fn test_proc_macro() {