Skip to content

Commit 5593045

Browse files
authored
Auto merge of #3002 - untitaker:trunchate-cargo-config, r=alexcrichton
Trunchate cargo config properly None
2 parents cd8ad10 + da3db83 commit 5593045

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/cargo/util/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,5 +732,6 @@ pub fn set_config(cfg: &Config,
732732
let contents = toml::Value::Table(toml).to_string();
733733
try!(file.seek(SeekFrom::Start(0)));
734734
try!(file.write_all(contents.as_bytes()));
735+
try!(file.file().set_len(contents.len() as u64));
735736
Ok(())
736737
}

tests/registry.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,19 @@ fn login_with_no_cargo_dir() {
580580
execs().with_status(0));
581581
}
582582

583+
#[test]
584+
fn login_with_differently_sized_token() {
585+
// Verify that the configuration file gets properly trunchated.
586+
let home = paths::home().join("new-home");
587+
t!(fs::create_dir(&home));
588+
assert_that(cargo_process().arg("login").arg("lmaolmaolmao").arg("-v"),
589+
execs().with_status(0));
590+
assert_that(cargo_process().arg("login").arg("lmao").arg("-v"),
591+
execs().with_status(0));
592+
assert_that(cargo_process().arg("login").arg("lmaolmaolmao").arg("-v"),
593+
execs().with_status(0));
594+
}
595+
583596
#[test]
584597
fn bad_license_file() {
585598
Package::new("foo", "1.0.0").publish();

0 commit comments

Comments
 (0)