diff options
author | Steven Knight <knight@baldmt.com> | 2004-07-08 16:25:24 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2004-07-08 16:25:24 (GMT) |
commit | 729de7d1d05cf7fa9264573c889ef12e2aceaf6d (patch) | |
tree | 6aaabcf326c1db9d60c1403c98ab7cebaca04bb4 /etc | |
parent | b7323556133cd1b757f11411adb53342dcbb1f28 (diff) | |
download | SCons-729de7d1d05cf7fa9264573c889ef12e2aceaf6d.zip SCons-729de7d1d05cf7fa9264573c889ef12e2aceaf6d.tar.gz SCons-729de7d1d05cf7fa9264573c889ef12e2aceaf6d.tar.bz2 |
Fix errors when there are dangling symlinks. (Gary Oberbrunner)
Diffstat (limited to 'etc')
-rw-r--r-- | etc/TestCmd.py | 26 | ||||
-rw-r--r-- | etc/TestCommon.py | 19 |
2 files changed, 38 insertions, 7 deletions
diff --git a/etc/TestCmd.py b/etc/TestCmd.py index ca89ed9..48aa204 100644 --- a/etc/TestCmd.py +++ b/etc/TestCmd.py @@ -88,6 +88,8 @@ things. Here is an overview of them: test.stderr() test.stderr(run) + test.symlink(target, link) + test.match(actual, expected) test.match_exact("actual 1\nactual 2\n", "expected 1\nexpected 2\n") @@ -173,8 +175,8 @@ version. # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. __author__ = "Steven Knight <knight at baldmt dot com>" -__revision__ = "TestCmd.py 0.6.D001 2004/03/20 17:39:42 knight" -__version__ = "0.6" +__revision__ = "TestCmd.py 0.7.D001 2004/07/08 10:02:13 knight" +__version__ = "0.7" import os import os.path @@ -494,6 +496,8 @@ class TestCmd: """ if not self._dirlist: return + os.chdir(self._cwd) + self.workdir = None if condition is None: condition = self.condition if self._preserve[condition]: @@ -507,8 +511,6 @@ class TestCmd: shutil.rmtree(dir, ignore_errors = 1) self._dirlist = [] - self.workdir = None - os.chdir(self._cwd) try: global _Cleanup _Cleanup.remove(self) @@ -752,7 +754,21 @@ class TestCmd: count = count + 1 return count - def unlink (self, file): + def symlink(self, target, link): + """Creates a symlink to the specified target. + The link name may be a list, in which case the elements are + concatenated with the os.path.join() method. The link is + assumed to be under the temporary working directory unless it + is an absolute path name. The target is *not* assumed to be + under the temporary working directory. + """ + if is_List(link): + link = apply(os.path.join, tuple(link)) + if not os.path.isabs(link): + link = os.path.join(self.workdir, link) + os.symlink(target, link) + + def unlink(self, file): """Unlinks the specified file name. The file name may be a list, in which case the elements are concatenated with the os.path.join() method. The file is 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 |