def test_getCommand_multi_exe(self):
     self.set_which_results({
         'xeyes': [r'c:\program files\xeyes.com', r'c:\program files\xeyes.exe'],
         'xeyes.exe': [r'c:\program files\xeyes.exe'],
     })
     # this one will work out differently depending on platform..
     if runtime.platformType == 'win32':
         self.assertEqual(utils.getCommand('xeyes'), r'c:\program files\xeyes.exe')
     else:
         self.assertEqual(utils.getCommand('xeyes'), r'c:\program files\xeyes.com')
 def test_getCommand_multi_exe(self):
     self.set_which_results({
         'xeyes': [r'c:\program files\xeyes.com', r'c:\program files\xeyes.exe'],
         'xeyes.exe': [r'c:\program files\xeyes.exe'],
     })
     # this one will work out differently depending on platform..
     if runtime.platformType == 'win32':
         self.assertEqual(
             utils.getCommand('xeyes'), r'c:\program files\xeyes.exe')
     else:
         self.assertEqual(
             utils.getCommand('xeyes'), r'c:\program files\xeyes.com')
Example #3
0
 def test_getCommand_single_exe(self):
     self.set_which_results({
         'xeyes': ['/usr/bin/xeyes'],
         # it should not select this option, since only one matched
         # to begin with
         'xeyes.exe': [r'c:\program files\xeyes.exe'],
     })
     self.assertEqual(utils.getCommand('xeyes'), '/usr/bin/xeyes')
Example #4
0
 def test_getCommand_single_exe(self):
     self.set_which_results({
         'xeyes': ['/usr/bin/xeyes'],
         # it should not select this option, since only one matched
         # to begin with
         'xeyes.exe': [r'c:\program files\xeyes.exe'],
     })
     self.assertEqual(utils.getCommand('xeyes'), '/usr/bin/xeyes')
Example #5
0
 def getCommand(self, name):
     """Wrapper around utils.getCommand that will output a resonable
     error message and raise AbandonChain if the command cannot be
     found"""
     if name not in self._commandPaths:
         try:
             self._commandPaths[name] = utils.getCommand(name)
         except RuntimeError:
             self.sendStatus({'stderr': "could not find '%s'\n" % name})
             self.sendStatus({'stderr': "PATH is '%s'\n" % os.environ.get('PATH', '')})
             raise AbandonChain(-1)
     return self._commandPaths[name]
Example #6
0
    def doPatch(self, res):
        patchlevel = self.patch[0]
        diff = self.patch[1]
        root = None
        if len(self.patch) >= 3:
            root = self.patch[2]
        command = [
            utils.getCommand("patch"),
            '-p%d' % patchlevel,
            '--remove-empty-files',
            '--force',
            '--forward',
            '-i',
            '.buildbot-diff',
        ]
        dir = os.path.join(self.builder.basedir, self.workdir)
        # Mark the directory so we don't try to update it later, or at least try
        # to revert first.
        open(os.path.join(dir, ".buildbot-patched"), "w").write("patched\n")

        # write the diff to a file, for reading later
        open(os.path.join(dir, ".buildbot-diff"), "w").write(diff)

        # Update 'dir' with the 'root' option. Make sure it is a subdirectory
        # of dir.
        if (root and os.path.abspath(os.path.join(dir, root)).startswith(
                os.path.abspath(dir))):
            dir = os.path.join(dir, root)

        # now apply the patch
        c = runprocess.RunProcess(self.builder,
                                  command,
                                  dir,
                                  sendRC=False,
                                  timeout=self.timeout,
                                  maxTime=self.maxTime,
                                  logEnviron=self.logEnviron,
                                  usePTY=False)
        self.command = c
        d = c.start()

        # clean up the temp file
        def cleanup(x):
            try:
                os.unlink(os.path.join(dir, ".buildbot-diff"))
            except OSError:
                pass
            return x

        d.addBoth(cleanup)

        d.addCallback(self._abandonOnFailure)
        return d
Example #7
0
 def getCommand(self, name):
     """Wrapper around utils.getCommand that will output a resonable
     error message and raise AbandonChain if the command cannot be
     found"""
     if name not in self._commandPaths:
         try:
             self._commandPaths[name] = utils.getCommand(name)
         except RuntimeError:
             self.sendStatus({'stderr': "could not find '%s'\n" % name})
             self.sendStatus(
                 {'stderr': "PATH is '%s'\n" % os.environ.get('PATH', '')})
             raise AbandonChain(-1)
     return self._commandPaths[name]
Example #8
0
    def doPatch(self, res):
        patchlevel = self.patch[0]
        diff = self.patch[1]
        root = None
        if len(self.patch) >= 3:
            root = self.patch[2]
        command = [
            utils.getCommand("patch"),
            '-p%d' % patchlevel,
            '--remove-empty-files',
            '--force',
            '--forward',
            '-i', '.buildbot-diff',
        ]
        dir = os.path.join(self.builder.basedir, self.workdir)
        # Mark the directory so we don't try to update it later, or at least try
        # to revert first.
        open(os.path.join(dir, ".buildbot-patched"), "w").write("patched\n")

        # write the diff to a file, for reading later
        open(os.path.join(dir, ".buildbot-diff"), "w").write(diff)

        # Update 'dir' with the 'root' option. Make sure it is a subdirectory
        # of dir.
        if (root and
            os.path.abspath(os.path.join(dir, root)
                            ).startswith(os.path.abspath(dir))):
            dir = os.path.join(dir, root)

        # now apply the patch
        c = runprocess.RunProcess(self.builder, command, dir,
                                  sendRC=False, timeout=self.timeout,
                                  maxTime=self.maxTime, logEnviron=self.logEnviron,
                                  usePTY=False)
        self.command = c
        d = c.start()

        # clean up the temp file
        def cleanup(x):
            try:
                os.unlink(os.path.join(dir, ".buildbot-diff"))
            except OSError:
                pass
            return x
        d.addBoth(cleanup)

        d.addCallback(self._abandonOnFailure)
        return d
Example #9
0
 def test_getCommand_multi(self):
     self.set_which_results({
         'xeyes': ['/usr/bin/xeyes', '/usr/X11/bin/xeyes'],
     })
     self.assertEqual(utils.getCommand('xeyes'), '/usr/bin/xeyes')
Example #10
0
 def test_getCommand_empty(self):
     self.set_which_results({
         'xeyes': [],
     })
     self.assertRaises(RuntimeError, lambda: utils.getCommand('xeyes'))
Example #11
0
 def test_getCommand_multi(self):
     self.set_which_results({
         'xeyes': ['/usr/bin/xeyes', '/usr/X11/bin/xeyes'],
     })
     self.assertEqual(utils.getCommand('xeyes'), '/usr/bin/xeyes')
Example #12
0
 def test_getCommand_empty(self):
     self.set_which_results({
         'xeyes': [],
     })
     self.assertRaises(RuntimeError, lambda: utils.getCommand('xeyes'))