Giter Club home page Giter Club logo

Comments (9)

epage avatar epage commented on June 2, 2024 1

I meant "strip them if they aren't included", not "unconditionally strip them". It could also likely be a user-controlled lint so people can control whether they want to error or allow it (#12235).

from cargo.

epage avatar epage commented on June 2, 2024 1

btw i have a solution in work. I am working to make it so published packages have all targets explicitly enumerated.

from cargo.

epage avatar epage commented on June 2, 2024

rand has package.include set:

include = ["src/", "LICENSE-*", "README.md", "CHANGELOG.md", "COPYRIGHT"]

This doesn't include benches/.

When you use auto-detected benches, cargo publish works just fine because it will auto-detect among the bundled files and be fine.

When you add [[bench]] tables, cargo knows to look for them but they were not included, and so things error.

Possible ways to improve the experience for this:

  • Make the error clearer by explicitly checking whether targets were included
  • Auto-strip certain types of targets, like [[bench]] and [[test]]

from cargo.

weihanglo avatar weihanglo commented on June 2, 2024

Auto-strip certain types of targets, like [[bench]] and [[test]]

I might be wrong, but doesn't crater run rely on tests being published to crates.io?

from cargo.

dhardy avatar dhardy commented on June 2, 2024

Isn't inclusion in the package a separate issue?

I would expect

[[bench]]
name = "uniform"
harness = false

to behave identically to

[[bench]]
name = "uniform"
path = "benches/uniform.rs"
harness = false

where benches/uniform.rs exists, given that the former is already supported by cargo bench.

from cargo.

epage avatar epage commented on June 2, 2024

Interesting, I hadn't realized that the presence of path makes a difference.

The reason is that without path, we have to do target auto-detection which fails. With path, we skip that and only error if the target is activated.

This makes me think we'll only be able to handle this by stripping these target as erroring would likely break some existing cases. We could still warn though and once that is user controllable, they could turn that into an error.

from cargo.

vincentdephily avatar vincentdephily commented on June 2, 2024

I think I'm hitting a variant of this, testing with cargo package. My Cargo.toml contains

[package]
exclude = ["benches"]
[[bench]]
# `benches/exec_compare.rs` is not meant to be run from cargo
name = "exec_compare"
bench = false

Which gives me

can't find `exec_compare` bench at `benches/exec_compare.rs` or `benches/exec_compare/main.rs`.
Please specify bench.path if you want to use a non-default path.

I can work around this by not excluding benches (but that's not the desired behavior), or by setting path="anything". The fact that even a bogus path value makes cargo happy is interesting.

from cargo.

heisen-li avatar heisen-li commented on June 2, 2024

At the time of upload,setting path but not verifying the validity of the path seems reasonable to me. But if bench = false is set, should existential checks be eliminated?

cargo book:

Setting targets to bench = false will stop them from being bencharmked by default.

I understand the implication here is that with bench = false set, Cargo will not execute benchmarks for crates with name=xx. Am I understanding this wrong?

from cargo.

weihanglo avatar weihanglo commented on June 2, 2024

@heisen-li have not checked the code but I believe this is about target path auto-discovery inconsistency when packaging, not compiling default targets.

from cargo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.