From 235fcbecc2f317a458b82a3ed3d8f8696a5bddd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Wed, 15 May 2019 20:05:37 +0200 Subject: [PATCH] tests: registry: revert readonly permission after running tests. Fixes #6943 --- tests/testsuite/registry.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/testsuite/registry.rs b/tests/testsuite/registry.rs index b846d85eece..a3aae80b606 100644 --- a/tests/testsuite/registry.rs +++ b/tests/testsuite/registry.rs @@ -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)); } }