Skip to content

Commit 3758e0d

Browse files
committed
start adding cache test
1 parent ce2bedc commit 3758e0d

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/docbuilder/rustwide_builder.rs

+37
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const USER_AGENT: &str = "docs.rs builder (https://github.com/rust-lang/docs.rs)
3434
const COMPONENTS: &[&str] = &["llvm-tools-preview", "rustc-dev", "rustfmt"];
3535
const DUMMY_CRATE_NAME: &str = "empty-library";
3636
const DUMMY_CRATE_VERSION: &str = "1.0.0";
37+
const DUMMY_CRATE_PUBLISHER_ID: &str = "2299951"; // pietroalbini
3738

3839
#[derive(Debug)]
3940
pub enum PackageKind<'a> {
@@ -1129,6 +1130,42 @@ mod tests {
11291130
})
11301131
}
11311132

1133+
#[test]
1134+
#[ignore]
1135+
fn test_artifact_cache() {
1136+
wrapper(|env| {
1137+
let crate_ = DUMMY_CRATE_NAME;
1138+
let version = DUMMY_CRATE_VERSION;
1139+
let expected_cache_dir = env
1140+
.config()
1141+
.prefix
1142+
.join("artifact_cache")
1143+
.join(DUMMY_CRATE_PUBLISHER_ID);
1144+
1145+
let mut builder = RustwideBuilder::init(env).unwrap();
1146+
1147+
// first build creates the cache
1148+
assert!(!expected_cache_dir.exists());
1149+
assert!(builder.build_package(crate_, version, PackageKind::CratesIo)?);
1150+
assert!(expected_cache_dir.exists());
1151+
1152+
// cache dir doesn't contain doc output
1153+
assert!(!expected_cache_dir.join("doc").exists());
1154+
1155+
// but seems to be a normal cargo target directory
1156+
for expected_file in &["CACHEDIR.TAG", "debug"] {
1157+
assert!(expected_cache_dir.join(expected_file).exists());
1158+
}
1159+
1160+
// do a second build
1161+
assert!(builder.build_package(crate_, version, PackageKind::CratesIo)?);
1162+
1163+
// FIXME: how would I know if the cache was used?
1164+
1165+
Ok(())
1166+
});
1167+
}
1168+
11321169
#[test]
11331170
#[ignore]
11341171
fn test_proc_macro() {

0 commit comments

Comments
 (0)