From d68635e7c2bc38343a58a8f9cddf95960fa642be Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 1 Mar 2011 14:24:13 -0600 Subject: pactest: use actual regexes in OUTPUT rules I managed to just make deptest001.py fail by changing a DEBUG-level logger in commit b12be99c89. This should not be this fickle. Enhance the OUTPUT rule to use an actual Python re object when looking for matches, and make a lot of the rules use stronger patterns to match with. Signed-off-by: Dan McGee --- test/pacman/tests/deptest001.py | 8 ++++---- test/pacman/tests/ignore007.py | 2 +- test/pacman/tests/ldconfig001.py | 2 +- test/pacman/tests/ldconfig002.py | 2 +- test/pacman/tests/ldconfig003.py | 2 +- test/pacman/tests/query001.py | 2 +- test/pacman/tests/query002.py | 6 +++--- test/pacman/tests/query003.py | 2 +- test/pacman/tests/query004.py | 2 +- test/pacman/tests/query005.py | 6 +++--- test/pacman/tests/sync1100.py | 6 +++--- test/pacman/tests/sync1101.py | 2 +- test/pacman/tests/sync1103.py | 2 +- test/pacman/util.py | 11 +++++++---- 14 files changed, 29 insertions(+), 26 deletions(-) (limited to 'test/pacman') diff --git a/test/pacman/tests/deptest001.py b/test/pacman/tests/deptest001.py index 18569bea..620e4f5b 100644 --- a/test/pacman/tests/deptest001.py +++ b/test/pacman/tests/deptest001.py @@ -10,7 +10,7 @@ self.addpkg2db("local", lp3) self.args = "-T pkg1 pkg2 pkg3\>2.1 prov\>\=3.0" self.addrule("PACMAN_RETCODE=127") -self.addrule("!PACMAN_OUTPUT=pkg1") -self.addrule("PACMAN_OUTPUT=pkg2") -self.addrule("PACMAN_OUTPUT=pkg3") -self.addrule("!PACMAN_OUTPUT=prov") +self.addrule("!PACMAN_OUTPUT=^pkg1") +self.addrule("PACMAN_OUTPUT=^pkg2") +self.addrule("PACMAN_OUTPUT=^pkg3") +self.addrule("!PACMAN_OUTPUT=^prov") diff --git a/test/pacman/tests/ignore007.py b/test/pacman/tests/ignore007.py index bb5efdc9..90ff4ef6 100644 --- a/test/pacman/tests/ignore007.py +++ b/test/pacman/tests/ignore007.py @@ -18,4 +18,4 @@ self.args = "--ask=1 -S grp" self.addrule("PACMAN_RETCODE=0") self.addrule("!PKG_EXIST=%s" % pkg1.name) self.addrule("PKG_EXIST=%s" % pkg2.name) -self.addrule("PACMAN_OUTPUT=IgnorePkg") +self.addrule("PACMAN_OUTPUT=is in IgnorePkg") diff --git a/test/pacman/tests/ldconfig001.py b/test/pacman/tests/ldconfig001.py index 9ac2ff35..aa029ba5 100644 --- a/test/pacman/tests/ldconfig001.py +++ b/test/pacman/tests/ldconfig001.py @@ -9,4 +9,4 @@ self.addpkg(p) self.args = "--debug -U %s" % p.filename() self.addrule("PACMAN_RETCODE=0") -self.addrule("PACMAN_OUTPUT=ldconfig") +self.addrule("PACMAN_OUTPUT=running ldconfig") diff --git a/test/pacman/tests/ldconfig002.py b/test/pacman/tests/ldconfig002.py index 162f5831..c028ce38 100644 --- a/test/pacman/tests/ldconfig002.py +++ b/test/pacman/tests/ldconfig002.py @@ -13,4 +13,4 @@ self.args = "--debug -U %s" % p.filename() self.addrule("PACMAN_RETCODE=0") self.addrule("PKG_VERSION=dummy|1.0-2") -self.addrule("PACMAN_OUTPUT=ldconfig") +self.addrule("PACMAN_OUTPUT=running ldconfig") diff --git a/test/pacman/tests/ldconfig003.py b/test/pacman/tests/ldconfig003.py index 1b48efad..69618c68 100644 --- a/test/pacman/tests/ldconfig003.py +++ b/test/pacman/tests/ldconfig003.py @@ -11,4 +11,4 @@ self.args = "-S %s" % sp.name self.args = "--debug -S %s" % sp.name self.addrule("PACMAN_RETCODE=0") -self.addrule("PACMAN_OUTPUT=ldconfig") +self.addrule("PACMAN_OUTPUT=running ldconfig") diff --git a/test/pacman/tests/query001.py b/test/pacman/tests/query001.py index 8faf0e15..8c580126 100644 --- a/test/pacman/tests/query001.py +++ b/test/pacman/tests/query001.py @@ -7,4 +7,4 @@ self.addpkg2db("local", p) self.args = "-Q %s" % p.name self.addrule("PACMAN_RETCODE=0") -self.addrule("PACMAN_OUTPUT=%s" % p.name) +self.addrule("PACMAN_OUTPUT=^%s" % p.name) diff --git a/test/pacman/tests/query002.py b/test/pacman/tests/query002.py index 7d943644..72fd7c1e 100644 --- a/test/pacman/tests/query002.py +++ b/test/pacman/tests/query002.py @@ -16,6 +16,6 @@ self.addpkg2db("local", p) self.args = "-Qi %s" % p.name self.addrule("PACMAN_RETCODE=0") -self.addrule("PACMAN_OUTPUT=%s" % p.name) -self.addrule("PACMAN_OUTPUT=%s" % p.desc) -self.addrule("PACMAN_OUTPUT=2007") +self.addrule("PACMAN_OUTPUT=^Name.*%s" % p.name) +self.addrule("PACMAN_OUTPUT=^Description.*%s" % p.desc) +self.addrule("PACMAN_OUTPUT=^Build Date.*2007") diff --git a/test/pacman/tests/query003.py b/test/pacman/tests/query003.py index 41b8a45b..01468c7a 100644 --- a/test/pacman/tests/query003.py +++ b/test/pacman/tests/query003.py @@ -8,4 +8,4 @@ self.addpkg2db("local", p) self.args = "-Qs %s" % p.name self.addrule("PACMAN_RETCODE=0") -self.addrule("PACMAN_OUTPUT=%s" % p.name) +self.addrule("PACMAN_OUTPUT=^local/%s" % p.name) diff --git a/test/pacman/tests/query004.py b/test/pacman/tests/query004.py index 8faf0e15..8c580126 100644 --- a/test/pacman/tests/query004.py +++ b/test/pacman/tests/query004.py @@ -7,4 +7,4 @@ self.addpkg2db("local", p) self.args = "-Q %s" % p.name self.addrule("PACMAN_RETCODE=0") -self.addrule("PACMAN_OUTPUT=%s" % p.name) +self.addrule("PACMAN_OUTPUT=^%s" % p.name) diff --git a/test/pacman/tests/query005.py b/test/pacman/tests/query005.py index 0c0bc51e..23a78fcb 100644 --- a/test/pacman/tests/query005.py +++ b/test/pacman/tests/query005.py @@ -16,6 +16,6 @@ self.addpkg2db("local", p) self.args = "-Qi %s" % p.name self.addrule("PACMAN_RETCODE=0") -self.addrule("PACMAN_OUTPUT=%s" % p.name) -self.addrule("PACMAN_OUTPUT=%s" % p.desc) -self.addrule("PACMAN_OUTPUT=2007") +self.addrule("PACMAN_OUTPUT=^Name.*%s" % p.name) +self.addrule("PACMAN_OUTPUT=^Description.*%s" % p.desc) +self.addrule("PACMAN_OUTPUT=^Build Date.*2007") diff --git a/test/pacman/tests/sync1100.py b/test/pacman/tests/sync1100.py index 887b85e8..c7bb56aa 100644 --- a/test/pacman/tests/sync1100.py +++ b/test/pacman/tests/sync1100.py @@ -18,6 +18,6 @@ self.addpkg2db("sync", sp) self.args = "-Si %s" % sp.name self.addrule("PACMAN_RETCODE=0") -self.addrule("PACMAN_OUTPUT=%s" % sp.name) -self.addrule("PACMAN_OUTPUT=%s" % sp.desc) -self.addrule("PACMAN_OUTPUT=2007") +self.addrule("PACMAN_OUTPUT=^Name.*%s" % sp.name) +self.addrule("PACMAN_OUTPUT=^Description.*%s" % sp.desc) +self.addrule("PACMAN_OUTPUT=^Build Date.*2007") diff --git a/test/pacman/tests/sync1101.py b/test/pacman/tests/sync1101.py index e3ed0f0f..041ebc83 100644 --- a/test/pacman/tests/sync1101.py +++ b/test/pacman/tests/sync1101.py @@ -9,4 +9,4 @@ self.addpkg2db("sync", sp) self.args = "-Ss %s" % sp.name self.addrule("PACMAN_RETCODE=0") -self.addrule("PACMAN_OUTPUT=%s" % sp.name) +self.addrule("PACMAN_OUTPUT=^sync/%s" % sp.name) diff --git a/test/pacman/tests/sync1103.py b/test/pacman/tests/sync1103.py index 052c7236..28b83f7e 100644 --- a/test/pacman/tests/sync1103.py +++ b/test/pacman/tests/sync1103.py @@ -8,4 +8,4 @@ self.addpkg2db("sync", sp) self.args = "-Sl" self.addrule("PACMAN_RETCODE=0") -self.addrule("PACMAN_OUTPUT=%s" % sp.name) +self.addrule("PACMAN_OUTPUT=^sync %s" % sp.name) diff --git a/test/pacman/util.py b/test/pacman/util.py index 359b42bf..b771a345 100755 --- a/test/pacman/util.py +++ b/test/pacman/util.py @@ -17,6 +17,7 @@ import os +import re import hashlib import stat @@ -194,11 +195,13 @@ def which(filename): return None def grep(filename, pattern): - lines = file(filename, 'r').readlines() - for line in lines: - if not line: break - if line.find(pattern) != -1: + pat = re.compile(pattern) + myfile = open(filename, 'r') + for line in myfile: + if pat.search(line): + myfile.close() return True + myfile.close() return False def mkdir(path): -- cgit v1.2.3-70-g09d2