Skip to content

Commit

Permalink
Auto merge of #6947 - matthiaskrgr:test_permission_fix, r=alexcrichton
Browse files Browse the repository at this point in the history
tests: registry: revert readonly permission after running tests.

Fixes #6943
  • Loading branch information
bors committed May 15, 2019
2 parents 1ae512d + 235fcbe commit c4fcfb7
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions tests/testsuite/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2003,25 +2003,28 @@ fn readonly_registry_still_works() {

p.cargo("generate-lockfile").run();
p.cargo("fetch --locked").run();
chmod_readonly(&paths::home());
chmod_readonly(&paths::home(), true);
p.cargo("build").run();
// make sure we un-readonly the files afterwards so "cargo clean" can remove them (#6934)
chmod_readonly(&paths::home(), false);

fn chmod_readonly(path: &Path) {

fn chmod_readonly(path: &Path, readonly: bool) {
for entry in t!(path.read_dir()) {
let entry = t!(entry);
let path = entry.path();
if t!(entry.file_type()).is_dir() {
chmod_readonly(&path);
chmod_readonly(&path, readonly);
} else {
set_readonly(&path);
set_readonly(&path, readonly);
}
}
set_readonly(path);
set_readonly(path, readonly);
}

fn set_readonly(path: &Path) {
fn set_readonly(path: &Path, readonly: bool) {
let mut perms = t!(path.metadata()).permissions();
perms.set_readonly(true);
perms.set_readonly(readonly);
t!(fs::set_permissions(path, perms));
}
}

0 comments on commit c4fcfb7

Please sign in to comment.