예제 #1
0
  def test_prep_no_command(self):
    with self.assertRaises(TaskError):
      a = self.make_target('a', dependencies=[], target_type=PrepCommand,
                           prep_executable='no_such_executable!$^!$&!$#^$#%!%@!', prep_args=[])

      context = self.context(target_roots=[a])
      task = RunPrepCommand(context=context, workdir='')
      task.execute()
예제 #2
0
  def test_prep_command_fails(self):
    with self.assertRaises(TaskError):
      a = self.make_target('a', dependencies=[], target_type=PrepCommand,
                           prep_executable='mv', prep_args=['/non/existent/file/name',
                                                            '/bogus/destination/place'])

      context = self.context(target_roots=[a])
      task = RunPrepCommand(context=context, workdir='')
      task.execute()
예제 #3
0
  def test_prep_environ(self):
    with temporary_dir() as workdir:
      a = self.make_target('a', dependencies=[], target_type=PrepCommand,
                           prep_executable='echo',
                           prep_args=['-n', 'test_prep_env_var=fleem'],
                           prep_environ=True)

      context = self.context(target_roots=[a])
      task = RunPrepCommand(context=context, workdir=workdir)
      task.execute()
      self.assertEquals('fleem', os.environ['test_prep_env_var'])
예제 #4
0
파일: test_prep.py 프로젝트: sikopet/pants
    def test_prep_no_command(self):
        with self.assertRaises(TaskError):
            a = self.make_target(
                'a',
                dependencies=[],
                target_type=PrepCommand,
                prep_executable='no_such_executable!$^!$&!$#^$#%!%@!',
                prep_args=[])

            context = self.context(target_roots=[a])
            task = RunPrepCommand(context=context, workdir='')
            task.execute()
예제 #5
0
파일: test_prep.py 프로젝트: sikopet/pants
    def test_prep_environ(self):
        with temporary_dir() as workdir:
            a = self.make_target('a',
                                 dependencies=[],
                                 target_type=PrepCommand,
                                 prep_executable='echo',
                                 prep_args=['-n', 'test_prep_env_var=fleem'],
                                 prep_environ=True)

            context = self.context(target_roots=[a])
            task = RunPrepCommand(context=context, workdir=workdir)
            task.execute()
            self.assertEquals('fleem', os.environ['test_prep_env_var'])
예제 #6
0
  def test_prep_order(self):
    with temporary_dir() as workdir:
      with temporary_dir() as tmp:
        files = [os.path.join(tmp, 'file%s' % i) for i in range(3)]
        touch(files[0])
        a = self.make_target('a', dependencies=[], target_type=PrepCommand,
                             prep_executable='mv', prep_args=[files[0], files[1]])
        b = self.make_target('b', dependencies=[a], target_type=PrepCommand,
                             prep_executable='mv', prep_args=[files[1], files[2]])

        context = self.context(target_roots=[b])
        task = RunPrepCommand(context=context, workdir=workdir)
        task.execute()
        self.assertTrue(os.path.exists(files[2]))
예제 #7
0
파일: test_prep.py 프로젝트: sikopet/pants
    def test_prep_command_fails(self):
        with self.assertRaises(TaskError):
            a = self.make_target('a',
                                 dependencies=[],
                                 target_type=PrepCommand,
                                 prep_executable='mv',
                                 prep_args=[
                                     '/non/existent/file/name',
                                     '/bogus/destination/place'
                                 ])

            context = self.context(target_roots=[a])
            task = RunPrepCommand(context=context, workdir='')
            task.execute()
예제 #8
0
파일: test_prep.py 프로젝트: sikopet/pants
    def test_prep_order(self):
        with temporary_dir() as workdir:
            with temporary_dir() as tmp:
                files = [os.path.join(tmp, 'file%s' % i) for i in range(3)]
                touch(files[0])
                a = self.make_target('a',
                                     dependencies=[],
                                     target_type=PrepCommand,
                                     prep_executable='mv',
                                     prep_args=[files[0], files[1]])
                b = self.make_target('b',
                                     dependencies=[a],
                                     target_type=PrepCommand,
                                     prep_executable='mv',
                                     prep_args=[files[1], files[2]])

                context = self.context(target_roots=[b])
                task = RunPrepCommand(context=context, workdir=workdir)
                task.execute()
                self.assertTrue(os.path.exists(files[2]))