Skip to content

Commit

Permalink
tests: registry: revert readonly permission after running tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaskrgr committed May 15, 2019
1 parent 1b4fab3 commit 235fcbe
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 235fcbe

Please sign in to comment.