~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/__init__.py

  • Committer: Martin Pool
  • Date: 2005-06-22 08:07:30 UTC
  • Revision ID: mbp@sourcefrog.net-20050622080730-b5d1f2f51af71245
- new TestBase.build_tree helper method

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
 
78
78
 
79
79
    def backtick(self, cmd, retcode=0):
 
80
        """Run a command and return its output"""
80
81
        cmd = self.formcmd(cmd)
81
82
        child = Popen(cmd, stdout=PIPE, stderr=self.TEST_LOG)
82
83
        outd, errd = child.communicate()
93
94
 
94
95
 
95
96
 
 
97
    def build_tree(self, shape):
 
98
        """Build a test tree according to a pattern.
 
99
 
 
100
        shape is a sequence of file specifications.  If the final
 
101
        character is '/', a directory is created.
 
102
 
 
103
        This doesn't add anything to a branch.
 
104
        """
 
105
        # XXX: It's OK to just create them using forward slashes on windows?
 
106
        for name in shape:
 
107
            assert isinstance(name, basestring)
 
108
            if name[-1] == '/':
 
109
                os.mkdir(name[:-1])
 
110
            else:
 
111
                f = file(name, 'wt')
 
112
                print >>f, "contents of", name
 
113
                f.close()
 
114
 
96
115
 
97
116
    def log(self, msg):
98
117
        """Log a message to a progress file"""