mirror of
https://github.com/rust-lang/cargo
synced 2024-08-25 10:35:53 +00:00
fix(add): Don't panic with --offline
For some reason, I defined my own `--offline` flag and it didn't get updated with the global `--offline` flag, so it started failing. Fixes #10814
This commit is contained in:
parent
2aa12cbb92
commit
18f7dfe0f5
|
@ -81,9 +81,6 @@ Example uses:
|
|||
.takes_value(true)
|
||||
.value_name("SPEC")
|
||||
.help("Package to modify"),
|
||||
clap::Arg::new("offline")
|
||||
.long("offline")
|
||||
.help("Run without accessing the network")
|
||||
])
|
||||
.arg_quiet()
|
||||
.arg_dry_run("Don't actually write the manifest")
|
||||
|
|
|
@ -56,6 +56,7 @@ mod namever;
|
|||
mod no_args;
|
||||
mod no_default_features;
|
||||
mod no_optional;
|
||||
mod offline_empty_cache;
|
||||
mod optional;
|
||||
mod overwrite_default_features;
|
||||
mod overwrite_default_features_with_no_default_features;
|
||||
|
|
1
tests/testsuite/cargo_add/offline_empty_cache/in
Symbolic link
1
tests/testsuite/cargo_add/offline_empty_cache/in
Symbolic link
|
@ -0,0 +1 @@
|
|||
../add-basic.in
|
25
tests/testsuite/cargo_add/offline_empty_cache/mod.rs
Normal file
25
tests/testsuite/cargo_add/offline_empty_cache/mod.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
use cargo_test_support::compare::assert_ui;
|
||||
use cargo_test_support::prelude::*;
|
||||
use cargo_test_support::Project;
|
||||
|
||||
use crate::cargo_add::init_registry;
|
||||
use cargo_test_support::curr_dir;
|
||||
|
||||
#[cargo_test]
|
||||
fn offline_empty_cache() {
|
||||
init_registry();
|
||||
let project = Project::from_template(curr_dir!().join("in"));
|
||||
let project_root = project.root();
|
||||
let cwd = &project_root;
|
||||
|
||||
snapbox::cmd::Command::cargo_ui()
|
||||
.arg("add")
|
||||
.arg_line("--offline my-package")
|
||||
.current_dir(cwd)
|
||||
.assert()
|
||||
.code(101)
|
||||
.stdout_matches_path(curr_dir!().join("stdout.log"))
|
||||
.stderr_matches_path(curr_dir!().join("stderr.log"));
|
||||
|
||||
assert_ui().subset_matches(curr_dir!().join("out"), &project_root);
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
[workspace]
|
||||
|
||||
[package]
|
||||
name = "cargo-list-test-fixture"
|
||||
version = "0.0.0"
|
1
tests/testsuite/cargo_add/offline_empty_cache/stderr.log
Normal file
1
tests/testsuite/cargo_add/offline_empty_cache/stderr.log
Normal file
|
@ -0,0 +1 @@
|
|||
error: the crate `my-package` could not be found in registry index.
|
Loading…
Reference in a new issue