summaryrefslogtreecommitdiffstats
path: root/etc/TestCommon.py
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-07-08 16:25:24 (GMT)
committerSteven Knight <knight@baldmt.com>2004-07-08 16:25:24 (GMT)
commit729de7d1d05cf7fa9264573c889ef12e2aceaf6d (patch)
tree6aaabcf326c1db9d60c1403c98ab7cebaca04bb4 /etc/TestCommon.py
parentb7323556133cd1b757f11411adb53342dcbb1f28 (diff)
downloadSCons-729de7d1d05cf7fa9264573c889ef12e2aceaf6d.zip
SCons-729de7d1d05cf7fa9264573c889ef12e2aceaf6d.tar.gz
SCons-729de7d1d05cf7fa9264573c889ef12e2aceaf6d.tar.bz2
Fix errors when there are dangling symlinks. (Gary Oberbrunner)
Diffstat (limited to 'etc/TestCommon.py')
-rw-r--r--etc/TestCommon.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/etc/TestCommon.py b/etc/TestCommon.py
index bf84ed3..8f4f22c 100644
--- a/etc/TestCommon.py
+++ b/etc/TestCommon.py
@@ -32,6 +32,8 @@ TestCommon object; see the TestCmd documentation for details.
Here is an overview of the methods and keyword arguments that are
provided by the TestCommon class:
+ test.must_contain('file', 'required text\n')
+
test.must_exist('file1', ['file2', ...])
test.must_match('file', "expected contents\n")
@@ -73,8 +75,8 @@ The TestCommon module also provides the following variables
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
__author__ = "Steven Knight <knight at baldmt dot com>"
-__revision__ = "TestCommon.py 0.6.D002 2004/03/29 06:21:41 knight"
-__version__ = "0.6"
+__revision__ = "TestCommon.py 0.7.D001 2004/07/08 10:02:13 knight"
+__version__ = "0.7"
import os
import os.path
@@ -182,6 +184,19 @@ class TestCommon(TestCmd):
apply(TestCmd.__init__, [self], kw)
os.chdir(self.workdir)
+ def must_contain(self, file, required):
+ """Ensures that the specified file contains the required text.
+ """
+ file_contents = self.read(file)
+ contains = (string.find(file_contents, required) != -1)
+ if not contains:
+ print "File `%s' does not contain required string." % file
+ print "Required string ====="
+ print required
+ print "%s contents =====" % file
+ print file_contents
+ self.fail_test(not contains)
+
def must_exist(self, *files):
"""Ensures that the specified file(s) must exist. An individual
file be specified as a list of directory names, in which case the