Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: disable single-library mode for dist=false #1441

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions cargo-dist/src/announce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,12 +545,16 @@ fn select_packages(
// add that package as a release still, on the assumption it's a Library
if releases.is_empty() {
if let ReleaseType::Package { idx, version: _ } = announcing.release {
releases.push(ReleaseArtifacts {
package_idx: PackageIdx(idx),
executables: vec![],
cdylibs: vec![],
cstaticlibs: vec![],
});
let config = graph.package_config(PackageIdx(idx));

if config.dist != Some(false) {
releases.push(ReleaseArtifacts {
package_idx: PackageIdx(idx),
executables: vec![],
cdylibs: vec![],
cstaticlibs: vec![],
});
}
}
}

Expand Down
15 changes: 15 additions & 0 deletions cargo-dist/tests/gallery/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,21 @@ impl<'a> TestContext<'a, Tools> {
self.load_dist_results(test_name, true)
}

pub fn cargo_dist_build_tag(&self, test_name: &str, tag_name: &str) -> Result<DistResult> {
// If the dist target dir exists, delete it to avoid cross-contamination
let out_path = Utf8Path::new("target/distrib/");
if out_path.exists() {
LocalAsset::remove_dir_all(out_path)?;
}

eprintln!("running dist build --tag={tag_name}...");
self.tools
.cargo_dist
.output_checked(|cmd| cmd.arg("dist").arg("build").arg("--tag").arg(tag_name))?;

self.load_dist_results(test_name, true)
}

/// Run 'dist generate' and return paths to various files that were generated
pub fn cargo_dist_generate(&self, test_name: &str) -> Result<GenerateResult> {
self.cargo_dist_generate_prefixed(test_name, "")
Expand Down
37 changes: 37 additions & 0 deletions cargo-dist/tests/integration-tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1651,6 +1651,43 @@ targets = ["x86_64-pc-windows-msvc"]
.unwrap();
}

#[test]
// Should produce an error on `build` because the requested tag matches a package with dist=false
#[should_panic(expected = r#"This workspace doesn't have anything for dist to Release!"#)]
fn axolotlsay_dist_false() {
let test_name = _function_name!();
AXOLOTLSAY.run_test(|ctx| {
let dist_version = ctx.tools.cargo_dist.version().unwrap();
ctx.patch_cargo_toml(format!(r#"
[workspace.metadata.dist]
cargo-dist-version = "{dist_version}"
installers = ["shell", "powershell", "homebrew", "npm", "msi", "pkg"]
tap = "axodotdev/homebrew-packages"
publish-jobs = ["homebrew", "npm"]
targets = ["x86_64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-pc-windows-msvc", "aarch64-apple-darwin"]
install-success-msg = ">o_o< everything's installed!"
ci = ["github"]
unix-archive = ".tar.gz"
windows-archive = ".tar.gz"
npm-scope = "@axodotdev"
dist = false

[package.metadata.wix]
upgrade-guid = "B36177BE-EA4D-44FB-B05C-EDDABDAA95CA"
path-guid = "BFD25009-65A4-4D1E-97F1-0030465D90D6"

[package.metadata.dist.mac-pkg-config]
identifier = "dev.axo.axolotsay"

"#
))?;

ctx.cargo_dist_build_tag(test_name, "axolotlsay-v0.2.2")?;

Ok(())
}).unwrap()
}

#[test]
fn axolotlsay_disable_source_tarball() -> Result<(), miette::Report> {
let test_name = _function_name!();
Expand Down
Loading