[devscripts] 02/03: sadt: Improve handling of non-executable test files
James McCoy
jamessan at debian.org
Thu Oct 30 04:13:21 UTC 2014
This is an automated email from the git hooks/post-receive script.
jamessan pushed a commit to branch master
in repository devscripts.
commit 2d19f1410beb66843e2a546b41cd8253400c94bb
Author: James McCoy <jamessan at debian.org>
Date: Thu Oct 30 00:02:46 2014 -0400
sadt: Improve handling of non-executable test files
Closes: #749729
Signed-off-by: James McCoy <jamessan at debian.org>
---
debian/changelog | 4 ++++
scripts/sadt | 13 ++++++++++++-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/debian/changelog b/debian/changelog
index dbef7a2..b8f8fdb 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,6 +12,10 @@ devscripts (2.14.11) UNRELEASED; urgency=medium
[ Jakub Wilk ]
* sadt:
+ Fix handling of rw-build-tree restriction
+ + Improve handling of non-executable test files. When rw-build-tree is in
+ effect, simply chmod the file. Otherwise, attempt to chmod the file
+ (skipping the test on failure) and restore the original permissions on
+ completion. (Closes: #749729)
-- Paul Wise <pabs at debian.org> Sun, 19 Oct 2014 17:27:24 +0800
diff --git a/scripts/sadt b/scripts/sadt
index 57b308f..964bdd7 100755
--- a/scripts/sadt
+++ b/scripts/sadt
@@ -42,6 +42,7 @@ def chmod_x(path):
new_mode = old_mode | ((old_mode & 0o444) >> 2)
if old_mode != new_mode:
os.chmod(path, new_mode)
+ return old_mode
def annotate_output(child):
queue = queuemod.Queue()
@@ -256,20 +257,30 @@ class TestGroup(object):
except Skip as exc:
progress.skip(str(exc))
raise
+ path = os.path.join(self.tests_directory, test)
+ original_mode = None
if rw_build_tree:
cwd = os.getcwd()
os.chdir(rw_build_tree)
+ chmod_x(path)
else:
cwd = None
+ if not os.access(path, os.X_OK):
+ try:
+ original_mode = chmod_x(path)
+ except OSError as exc:
+ progress.skip('{path} could not be made executable: {exc}'.format(path=path, exc=exc))
+ raise Skip
try:
self._run(test, progress, allow_stderr=options.allow_stderr)
finally:
+ if original_mode is not None:
+ os.chmod(path, original_mode)
if cwd is not None:
os.chdir(cwd)
def _run(self, test, progress, allow_stderr=False):
path = os.path.join(self.tests_directory, test)
- chmod_x(path)
tmpdir1 = tempfile.mkdtemp(prefix='sadt.')
tmpdir2 = tempfile.mkdtemp(prefix='sadt.')
environ = dict(os.environ)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git
More information about the devscripts-devel
mailing list