| 583 | raise Error('test has no commands') |
| 584 | |
| 585 | def CreateInputFile(self): |
| 586 | gen_input_path = self.GetGeneratedInputFilename() |
| 587 | gen_input_dir = os.path.dirname(gen_input_path) |
| 588 | try: |
| 589 | os.makedirs(gen_input_dir) |
| 590 | except OSError: |
| 591 | if not os.path.isdir(gen_input_dir): |
| 592 | raise |
| 593 | |
| 594 | # Read/write as binary because spec tests may have invalid UTF-8 codes. |
| 595 | with open(gen_input_path, 'wb') as gen_input_file: |
| 596 | if self.input_filename: |
| 597 | input_path = os.path.join(REPO_ROOT_DIR, self.input_filename) |
| 598 | with open(input_path, 'rb') as input_file: |
| 599 | gen_input_file.write(input_file.read()) |
| 600 | else: |
| 601 | # add an empty line for each header line so the line numbers match |
| 602 | gen_input_file.write(('\n' * self.header.count('\n')).encode('ascii')) |
| 603 | gen_input_file.write(self.input_) |
| 604 | gen_input_file.flush() |
| 605 | return gen_input_file.name |
| 606 | |
| 607 | def Rebase(self, stdout, stderr): |
| 608 | test_path = os.path.join(REPO_ROOT_DIR, self.filename) |