Skip to content

Commit

Permalink
builder tests: expect single target for CI build
Browse files Browse the repository at this point in the history
  • Loading branch information
jsha authored and syphar committed Nov 14, 2022
1 parent 602a39e commit f4828ff
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 26 deletions.
70 changes: 44 additions & 26 deletions src/docbuilder/rustwide_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -911,16 +911,6 @@ mod tests {
.map(|v| v.as_str().unwrap().to_owned())
.collect();
targets.sort();
assert_eq!(
targets,
vec![
"i686-pc-windows-msvc",
"i686-unknown-linux-gnu",
"x86_64-apple-darwin",
"x86_64-pc-windows-msvc",
"x86_64-unknown-linux-gnu",
]
);

let web = env.frontend();

Expand All @@ -947,26 +937,51 @@ mod tests {
web,
)?;

// other targets too
for target in DEFAULT_TARGETS {
let target_docs_present = storage.exists_in_archive(
&doc_archive,
&format!("{}/{}/index.html", target, crate_path),
)?;
assert!(!storage.exists_in_archive(
&doc_archive,
&format!("{}/{}/index.html", default_target, crate_path),
)?);

let default_target_url = format!(
"/{}/{}/{}/{}/index.html",
crate_, version, default_target, crate_path
);
assert_redirect(
&default_target_url,
&format!("/{}/{}/{}/index.html", crate_, version, crate_path),
web,
)?;

let target_url = format!(
"/{}/{}/{}/{}/index.html",
crate_, version, target, crate_path
// Non-dist toolchains only have a single target, and of course
// if include_default_targets is false we won't have this full list
// of targets.
if builder.toolchain.as_dist().is_some() && env.config().include_default_targets {
assert_eq!(
targets,
vec![
"i686-pc-windows-msvc",
"i686-unknown-linux-gnu",
"x86_64-apple-darwin",
"x86_64-pc-windows-msvc",
"x86_64-unknown-linux-gnu",
]
);

if target == &default_target {
assert!(!target_docs_present);
assert_redirect(
&target_url,
&format!("/{}/{}/{}/index.html", crate_, version, crate_path),
web,
// other targets too
for target in DEFAULT_TARGETS {
if target == &default_target {
continue;
}
let target_docs_present = storage.exists_in_archive(
&doc_archive,
&format!("{}/{}/index.html", target, crate_path),
)?;
} else {

let target_url = format!(
"/{}/{}/{}/{}/index.html",
crate_, version, target, crate_path
);

assert!(target_docs_present);
assert_success(&target_url, web)?;
}
Expand Down Expand Up @@ -1061,6 +1076,9 @@ mod tests {
let crate_ = "windows-win";
let version = "2.4.1";
let mut builder = RustwideBuilder::init(env).unwrap();
if builder.toolchain.as_ci().is_some() {
return Ok(());
}
assert!(builder.build_package(crate_, version, PackageKind::CratesIo)?);

let storage = env.storage();
Expand Down
2 changes: 2 additions & 0 deletions src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ impl TestEnvironment {
// are actually different.
config.cache_control_stale_while_revalidate = Some(86400);

config.include_default_targets = true;

config
}

Expand Down

0 comments on commit f4828ff

Please sign in to comment.