[pacman-dev] CVS update of pacman-lib/pactest (tests/scriptlet001.py util.py)
Aaron Griffin
aaron at archlinux.org
Thu Mar 22 04:30:18 EDT 2007
Date: Thursday, March 22, 2007 @ 04:30:18
Author: aaron
Path: /home/cvs-pacman/pacman-lib/pactest
Added: tests/scriptlet001.py (1.1)
Modified: util.py (1.6 -> 1.7)
Quick pactest changes:
* Minor change to utils.py(grep) to make it cleaner
* Added scriptlet check to verify scriptlet events happen
-----------------------+
tests/scriptlet001.py | 15 +++++++++++++++
util.py | 14 +++++---------
2 files changed, 20 insertions(+), 9 deletions(-)
Index: pacman-lib/pactest/tests/scriptlet001.py
diff -u /dev/null pacman-lib/pactest/tests/scriptlet001.py:1.1
--- /dev/null Thu Mar 22 04:30:18 2007
+++ pacman-lib/pactest/tests/scriptlet001.py Thu Mar 22 04:30:18 2007
@@ -0,0 +1,15 @@
+# quick note here - chroot() is expected to fail. We're not checking the
+# validity of the scripts, only that they fire (or try to)
+self.description = "Scriptlet test (pre/post install)"
+
+p1 = pmpkg("dummy")
+p1.files = ['etc/dummy.conf']
+p1.install['pre_install'] = "ls /etc";
+p1.install['post_install'] = "ls /etc";
+self.addpkg(p1)
+
+self.args = "-U %s" % p1.filename()
+
+self.addrule("PACMAN_RETCODE=0")
+self.addrule("PACMAN_OUTPUT=pre_install")
+self.addrule("PACMAN_OUTPUT=post_install")
Index: pacman-lib/pactest/util.py
diff -u pacman-lib/pactest/util.py:1.6 pacman-lib/pactest/util.py:1.7
--- pacman-lib/pactest/util.py:1.6 Mon Mar 5 17:13:34 2007
+++ pacman-lib/pactest/util.py Thu Mar 22 04:30:18 2007
@@ -236,16 +236,12 @@
#
def grep(filename, pattern):
- found = 0
- fd = file(filename, "r")
- while 1 and not found:
- line = fd.readline()
- if not line:
- break
+ lines = file(filename, 'r').readlines()
+ for line in lines:
+ if not line: break
if line.find(pattern) != -1:
- found = 1
- fd.close()
- return found
+ return True
+ return False
def mkdir(dir):
if os.path.isdir(dir):
More information about the pacman-dev
mailing list