From 38a0cfb74c031571c5cea671e2645d6c0dabb59d Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sat, 9 Jun 2012 14:44:35 +0100 Subject: [PATCH] When running tests, make the directory tree read-only Checks that tests will still work from the read-only 0install cache. --- release.py | 6 +++++- support.py | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/release.py b/release.py index e38f6c8..865cc46 100644 --- a/release.py +++ b/release.py @@ -4,6 +4,7 @@ import os, sys, subprocess, shutil, tempfile from zeroinstall import SafeException from zeroinstall.injector import reader, model, qdom +from zeroinstall.support import ro_rmtree from logging import info, warn import support, compile @@ -470,6 +471,9 @@ def do_release(local_iface, options): if status.src_tests_passed: print "Unit-tests already passed - not running again" else: + # Make directories read-only (checks tests don't write) + support.make_readonly_recursive(archive_name) + run_unit_tests(extracted_iface_path) status.src_tests_passed = True status.save() @@ -478,7 +482,7 @@ def do_release(local_iface, options): fail_candidate(archive_file) raise # Unpack it again in case the unit-tests changed anything - shutil.rmtree(archive_name) + ro_rmtree(archive_name) support.unpack_tarball(archive_file) # Generate feed for source diff --git a/support.py b/support.py index 6537188..bb6e4e2 100644 --- a/support.py +++ b/support.py @@ -225,3 +225,10 @@ def relative_path(ancestor, dst): assert relative_path('/foo', '/foo') == 'foo' assert relative_path('/foo', '/foo/bar') == 'foo/bar' + +def make_readonly_recursive(path): + for root, dirs, files in os.walk(path): + for d in dirs + files: + full = os.path.join(root, d) + mode = os.stat(full).st_mode + os.chmod(full, mode & 0o555) -- 2.11.4.GIT