예제 #1
0
 def test_simple_cmd_changed_work_dir_with_redirected_output(self):
     # create temp_file in temp_dir
     self.test_simple_cmd_changed_work_dir()
     ret = ProcessHelper.run_subprocess_cwd(self.LS_COMMAND, self.TEMP_DIR, output=self.OUT_FILE)
     assert ret == 0
     assert os.path.exists(os.path.join(self.TEMP_DIR, self.TEMP_FILE))
     assert os.path.exists(self.OUT_FILE)
     assert open(self.OUT_FILE).readline().strip("\n") == self.TEMP_FILE
예제 #2
0
 def test_simple_cmd_changed_work_dir_with_redirected_output(self):
     # create temp_file in temp_dir
     self.test_simple_cmd_changed_work_dir()
     ret = ProcessHelper.run_subprocess_cwd(self.LS_COMMAND,
                                            self.TEMP_DIR,
                                            output=self.OUT_FILE)
     assert ret == 0
     assert os.path.exists(os.path.join(self.TEMP_DIR, self.TEMP_FILE))
     assert os.path.exists(self.OUT_FILE)
     assert open(self.OUT_FILE).readline().strip("\n") == self.TEMP_FILE
예제 #3
0
 def _build_source_from_instructions(cls, instructions, source, logfile):
     """Run instructions to create source archive"""
     logger.info("Attempting to create source '%s' using instructions in comments", source)
     with TemporaryEnvironment() as tmp:
         script = os.path.join(tmp.path(), 'script.sh')
         with open(script, 'w') as f:
             f.write('#!/bin/sh -x\n')
             f.write(''.join(instructions))
             f.write('cp "{}" "{}"\n'.format(source, os.getcwd()))
         os.chmod(script, 0o755)
         result = ProcessHelper.run_subprocess_cwd(script, tmp.path(), output=logfile, shell=True)
     if result == 0 and os.path.isfile(source):
         logger.info('Source creation succeeded.')
     else:
         logger.info('Source creation failed.')
예제 #4
0
 def test_simple_cmd_changed_work_dir(self):
     os.mkdir(self.TEMP_DIR)
     ret = ProcessHelper.run_subprocess_cwd(self.TOUCH_COMMAND,
                                            self.TEMP_DIR)
     assert ret == 0
     assert os.path.exists(os.path.join(self.TEMP_DIR, self.TEMP_FILE))
예제 #5
0
 def test_simple_cmd_changed_work_dir(self):
     os.mkdir(self.TEMP_DIR)
     ret = ProcessHelper.run_subprocess_cwd(self.TOUCH_COMMAND, self.TEMP_DIR)
     assert ret == 0
     assert os.path.exists(os.path.join(self.TEMP_DIR, self.TEMP_FILE))