| 1 | #!/usr/bin/env python2
|
| 2 | """
|
| 3 | import_smoosh.py
|
| 4 |
|
| 5 | Choose between STDOUT and stdout-json assertions.
|
| 6 | """
|
| 7 | from __future__ import print_function
|
| 8 |
|
| 9 | import json
|
| 10 | import sys
|
| 11 |
|
| 12 |
|
| 13 | def main(argv):
|
| 14 | stdout_file = argv[1]
|
| 15 | with open(stdout_file) as f:
|
| 16 | expected = f.read()
|
| 17 |
|
| 18 | if expected.endswith('\n'): # not including empty
|
| 19 | print('## STDOUT:')
|
| 20 | print(expected, end='')
|
| 21 | print('## END')
|
| 22 | else:
|
| 23 | print('## stdout-json: %s' % json.dumps(expected))
|
| 24 |
|
| 25 |
|
| 26 | if __name__ == '__main__':
|
| 27 | try:
|
| 28 | main(sys.argv)
|
| 29 | except RuntimeError as e:
|
| 30 | print('FATAL: %s' % e, file=sys.stderr)
|
| 31 | sys.exit(1)
|