mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
cargo run: on nightly, advertise the default-run feature
This commit is contained in:
parent
04c90d38af
commit
d1372315b3
@ -392,7 +392,7 @@ thread_local!(
|
|||||||
/// - this is an `#[test]` that called `enable_nightly_features`
|
/// - this is an `#[test]` that called `enable_nightly_features`
|
||||||
/// - this is a integration test that uses `ProcessBuilder`
|
/// - this is a integration test that uses `ProcessBuilder`
|
||||||
/// that called `masquerade_as_nightly_cargo`
|
/// that called `masquerade_as_nightly_cargo`
|
||||||
fn nightly_features_allowed() -> bool {
|
pub fn nightly_features_allowed() -> bool {
|
||||||
if ENABLE_NIGHTLY_FEATURES.with(|c| c.get()) {
|
if ENABLE_NIGHTLY_FEATURES.with(|c| c.get()) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
pub use self::dependency::Dependency;
|
pub use self::dependency::Dependency;
|
||||||
pub use self::features::{CliUnstable, Edition, Feature, Features};
|
pub use self::features::{CliUnstable, Edition, Feature, Features};
|
||||||
pub use self::features::{maybe_allow_nightly_features, enable_nightly_features};
|
pub use self::features::{
|
||||||
|
maybe_allow_nightly_features,
|
||||||
|
enable_nightly_features,
|
||||||
|
nightly_features_allowed
|
||||||
|
};
|
||||||
pub use self::manifest::{EitherManifest, VirtualManifest};
|
pub use self::manifest::{EitherManifest, VirtualManifest};
|
||||||
pub use self::manifest::{LibKind, Manifest, Target, TargetKind};
|
pub use self::manifest::{LibKind, Manifest, Target, TargetKind};
|
||||||
pub use self::package::{Package, PackageSet};
|
pub use self::package::{Package, PackageSet};
|
||||||
|
@ -2,7 +2,7 @@ use std::path::Path;
|
|||||||
|
|
||||||
use ops;
|
use ops;
|
||||||
use util::{self, CargoResult, ProcessError};
|
use util::{self, CargoResult, ProcessError};
|
||||||
use core::{TargetKind, Workspace};
|
use core::{TargetKind, Workspace, nightly_features_allowed};
|
||||||
|
|
||||||
pub fn run(
|
pub fn run(
|
||||||
ws: &Workspace,
|
ws: &Workspace,
|
||||||
@ -53,12 +53,22 @@ pub fn run(
|
|||||||
if bins.len() > 1 {
|
if bins.len() > 1 {
|
||||||
if !options.filter.is_specific() {
|
if !options.filter.is_specific() {
|
||||||
let names: Vec<&str> = bins.into_iter().map(|bin| bin.0).collect();
|
let names: Vec<&str> = bins.into_iter().map(|bin| bin.0).collect();
|
||||||
bail!(
|
if nightly_features_allowed() {
|
||||||
"`cargo run` requires that a project only have one \
|
bail!(
|
||||||
executable; use the `--bin` option to specify which one \
|
"`cargo run` could not determine which binary to run. \
|
||||||
to run\navailable binaries: {}",
|
Use the `--bin` option to specify a binary, \
|
||||||
names.join(", ")
|
or (on nightly) the `default-run` manifest key.\n\
|
||||||
)
|
available binaries: {}",
|
||||||
|
names.join(", ")
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
bail!(
|
||||||
|
"`cargo run` requires that a project only have one \
|
||||||
|
executable; use the `--bin` option to specify which one \
|
||||||
|
to run\navailable binaries: {}",
|
||||||
|
names.join(", ")
|
||||||
|
)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
bail!(
|
bail!(
|
||||||
"`cargo run` can run at most one executable, but \
|
"`cargo run` can run at most one executable, but \
|
||||||
|
@ -282,6 +282,17 @@ fn too_many_bins() {
|
|||||||
to specify which one to run\navailable binaries: [..]\n",
|
to specify which one to run\navailable binaries: [..]\n",
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
assert_that(
|
||||||
|
p.cargo("run").masquerade_as_nightly_cargo(),
|
||||||
|
// Using [..] here because the order is not stable
|
||||||
|
execs().with_status(101).with_stderr(
|
||||||
|
"[ERROR] `cargo run` could not determine which binary to run. \
|
||||||
|
Use the `--bin` option to specify a binary, or (on \
|
||||||
|
nightly) the `default-run` manifest key.\
|
||||||
|
\navailable binaries: [..]\n",
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user