(command, outfile=None)
| 120 | print("Compile tests passed.") |
| 121 | |
| 122 | def run(command, outfile=None): |
| 123 | |
| 124 | # shlex.split will preserve inner quotes |
| 125 | p0 = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) |
| 126 | |
| 127 | stdout0, stderr0 = p0.communicate() |
| 128 | rc = p0.returncode |
| 129 | p0.stdout.close() |
| 130 | p0.stderr.close() |
| 131 | |
| 132 | if outfile: |
| 133 | try: cf = open(outfile, 'wb') |
| 134 | except IOError: |
| 135 | print("ERROR: unable to open file for writing") |
| 136 | else: |
| 137 | cf.write(stdout0) |
| 138 | cf.write(stderr0) |
| 139 | cf.close() |
| 140 | else: |
| 141 | print(" ", stdout0) |
| 142 | if stderr0: |
| 143 | print(" ", stderr0) |
| 144 | |
| 145 | return rc |
| 146 | |
| 147 | if __name__ == "__main__": |
| 148 | compiletesting(sys.argv[1:]) |
no test coverage detected